mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-04 21:31:11 -05:00
246 lines
5.6 KiB
Text
246 lines
5.6 KiB
Text
|
struct SurfaceOutput {
|
||
|
vec3 Albedo;
|
||
|
vec3 Normal;
|
||
|
vec3 Emission;
|
||
|
float Specular;
|
||
|
float Gloss;
|
||
|
float Alpha;
|
||
|
};
|
||
|
struct Input {
|
||
|
vec2 uv_MainTex;
|
||
|
vec3 worldRefl;
|
||
|
};
|
||
|
struct v2f_surf {
|
||
|
vec4 pos;
|
||
|
float fog;
|
||
|
vec2 hip_pack0;
|
||
|
vec3 normal;
|
||
|
vec3 lightDir;
|
||
|
vec3 viewDir;
|
||
|
vec4 _LightCoord;
|
||
|
};
|
||
|
varying vec4 xlv_FOG;
|
||
|
uniform vec4 _SpecColor;
|
||
|
uniform float _Shininess;
|
||
|
uniform vec4 _ReflectColor;
|
||
|
uniform sampler2D _MainTex;
|
||
|
uniform sampler2D _LightTextureB0;
|
||
|
uniform sampler2D _LightTexture0;
|
||
|
uniform vec4 _LightColor0;
|
||
|
uniform samplerCube _Cube;
|
||
|
uniform vec4 _Color;
|
||
|
void surf (
|
||
|
in Input IN_1,
|
||
|
inout SurfaceOutput o_2
|
||
|
)
|
||
|
{
|
||
|
vec4 reflcol_3;
|
||
|
vec4 c_4;
|
||
|
vec4 tex_5;
|
||
|
vec4 tmpvar_6;
|
||
|
tmpvar_6 = texture2D (_MainTex, IN_1.uv_MainTex);
|
||
|
vec4 tmpvar_7;
|
||
|
tmpvar_7 = tmpvar_6;
|
||
|
tex_5 = tmpvar_7;
|
||
|
vec4 tmpvar_8;
|
||
|
tmpvar_8 = (tex_5 * _Color);
|
||
|
c_4 = tmpvar_8;
|
||
|
vec3 tmpvar_9;
|
||
|
tmpvar_9 = c_4.xyz;
|
||
|
o_2.Albedo = tmpvar_9;
|
||
|
float tmpvar_10;
|
||
|
tmpvar_10 = tex_5.w;
|
||
|
o_2.Gloss = tmpvar_10;
|
||
|
float tmpvar_11;
|
||
|
tmpvar_11 = _Shininess;
|
||
|
o_2.Specular = tmpvar_11;
|
||
|
vec4 tmpvar_12;
|
||
|
tmpvar_12 = textureCube (_Cube, IN_1.worldRefl);
|
||
|
vec4 tmpvar_13;
|
||
|
tmpvar_13 = tmpvar_12;
|
||
|
reflcol_3 = tmpvar_13;
|
||
|
vec4 tmpvar_14;
|
||
|
tmpvar_14 = (reflcol_3 * tex_5.w);
|
||
|
reflcol_3 = tmpvar_14;
|
||
|
vec3 tmpvar_15;
|
||
|
tmpvar_15 = (reflcol_3.xyz * _ReflectColor.xyz);
|
||
|
o_2.Emission = tmpvar_15;
|
||
|
float tmpvar_16;
|
||
|
tmpvar_16 = (reflcol_3.w * _ReflectColor.w);
|
||
|
o_2.Alpha = tmpvar_16;
|
||
|
}
|
||
|
|
||
|
float UnitySpotCookie (
|
||
|
in vec4 LightCoord_17
|
||
|
)
|
||
|
{
|
||
|
vec4 tmpvar_18;
|
||
|
tmpvar_18 = texture2D (_LightTexture0, ((LightCoord_17.xy / LightCoord_17.w) + 0.5));
|
||
|
return tmpvar_18.w;
|
||
|
}
|
||
|
|
||
|
float UnitySpotAttenuate (
|
||
|
in vec3 LightCoord_19
|
||
|
)
|
||
|
{
|
||
|
float tmpvar_20;
|
||
|
tmpvar_20 = dot (LightCoord_19, LightCoord_19);
|
||
|
vec2 tmpvar_21;
|
||
|
tmpvar_21 = vec2(tmpvar_20);
|
||
|
vec2 tmpvar_22;
|
||
|
tmpvar_22 = tmpvar_21.xy;
|
||
|
vec4 tmpvar_23;
|
||
|
tmpvar_23 = texture2D (_LightTextureB0, tmpvar_22);
|
||
|
return tmpvar_23.w;
|
||
|
}
|
||
|
|
||
|
vec4 LightingBlinnPhong (
|
||
|
in SurfaceOutput s_24,
|
||
|
in vec3 lightDir_25,
|
||
|
in vec3 viewDir_26,
|
||
|
in float atten_27
|
||
|
)
|
||
|
{
|
||
|
vec4 c_28;
|
||
|
float spec_29;
|
||
|
float nh_30;
|
||
|
float diff_31;
|
||
|
vec3 h_32;
|
||
|
vec3 tmpvar_33;
|
||
|
tmpvar_33 = normalize ((lightDir_25 + viewDir_26));
|
||
|
vec3 tmpvar_34;
|
||
|
tmpvar_34 = tmpvar_33;
|
||
|
h_32 = tmpvar_34;
|
||
|
float tmpvar_35;
|
||
|
tmpvar_35 = dot (s_24.Normal, lightDir_25);
|
||
|
float tmpvar_36;
|
||
|
tmpvar_36 = max (0.0, tmpvar_35);
|
||
|
float tmpvar_37;
|
||
|
tmpvar_37 = tmpvar_36;
|
||
|
diff_31 = tmpvar_37;
|
||
|
float tmpvar_38;
|
||
|
tmpvar_38 = dot (s_24.Normal, h_32);
|
||
|
float tmpvar_39;
|
||
|
tmpvar_39 = max (0.0, tmpvar_38);
|
||
|
float tmpvar_40;
|
||
|
tmpvar_40 = tmpvar_39;
|
||
|
nh_30 = tmpvar_40;
|
||
|
float tmpvar_41;
|
||
|
tmpvar_41 = pow (nh_30, (s_24.Specular * 128.0));
|
||
|
float tmpvar_42;
|
||
|
tmpvar_42 = (tmpvar_41 * s_24.Gloss);
|
||
|
spec_29 = tmpvar_42;
|
||
|
vec3 tmpvar_43;
|
||
|
tmpvar_43 = ((((s_24.Albedo * _LightColor0.xyz) * diff_31) + ((_LightColor0.xyz * _SpecColor.xyz) * spec_29)) * (atten_27 * 2.0));
|
||
|
c_28.xyz = tmpvar_43.xyz.xyz;
|
||
|
float tmpvar_44;
|
||
|
tmpvar_44 = (s_24.Alpha + (((_LightColor0.w * _SpecColor.w) * spec_29) * atten_27));
|
||
|
c_28.w = vec4(tmpvar_44).w;
|
||
|
return c_28;
|
||
|
}
|
||
|
|
||
|
vec4 frag_surf (
|
||
|
in v2f_surf IN_45
|
||
|
)
|
||
|
{
|
||
|
vec4 c_46;
|
||
|
vec3 lightDir_47;
|
||
|
SurfaceOutput o_48;
|
||
|
Input surfIN_49;
|
||
|
vec2 tmpvar_50;
|
||
|
tmpvar_50 = IN_45.hip_pack0.xy;
|
||
|
surfIN_49.uv_MainTex = tmpvar_50;
|
||
|
vec3 tmpvar_51;
|
||
|
tmpvar_51 = vec3(0.0, 0.0, 0.0);
|
||
|
o_48.Albedo = tmpvar_51;
|
||
|
vec3 tmpvar_52;
|
||
|
tmpvar_52 = vec3(0.0, 0.0, 0.0);
|
||
|
o_48.Emission = tmpvar_52;
|
||
|
float tmpvar_53;
|
||
|
tmpvar_53 = 0.0;
|
||
|
o_48.Specular = tmpvar_53;
|
||
|
float tmpvar_54;
|
||
|
tmpvar_54 = 0.0;
|
||
|
o_48.Alpha = tmpvar_54;
|
||
|
float tmpvar_55;
|
||
|
tmpvar_55 = 0.0;
|
||
|
o_48.Gloss = tmpvar_55;
|
||
|
vec3 tmpvar_56;
|
||
|
tmpvar_56 = IN_45.normal;
|
||
|
o_48.Normal = tmpvar_56;
|
||
|
surf (surfIN_49, o_48);
|
||
|
vec3 tmpvar_57;
|
||
|
tmpvar_57 = IN_45.lightDir;
|
||
|
lightDir_47 = tmpvar_57;
|
||
|
vec3 tmpvar_58;
|
||
|
tmpvar_58 = normalize (lightDir_47);
|
||
|
vec3 tmpvar_59;
|
||
|
tmpvar_59 = tmpvar_58;
|
||
|
lightDir_47 = tmpvar_59;
|
||
|
vec3 tmpvar_60;
|
||
|
tmpvar_60 = IN_45.viewDir.xyz;
|
||
|
vec3 tmpvar_61;
|
||
|
tmpvar_61 = normalize (tmpvar_60);
|
||
|
float tmpvar_62;
|
||
|
tmpvar_62 = UnitySpotCookie (IN_45._LightCoord);
|
||
|
float tmpvar_63;
|
||
|
tmpvar_63 = UnitySpotAttenuate (IN_45._LightCoord.xyz);
|
||
|
vec4 tmpvar_64;
|
||
|
tmpvar_64 = LightingBlinnPhong (o_48, lightDir_47, tmpvar_61, ((float((IN_45._LightCoord.z > 0.0)) * tmpvar_62) * tmpvar_63));
|
||
|
vec4 tmpvar_65;
|
||
|
tmpvar_65 = tmpvar_64;
|
||
|
c_46 = tmpvar_65;
|
||
|
float tmpvar_66;
|
||
|
tmpvar_66 = 0.0;
|
||
|
c_46.w = vec4(tmpvar_66).w;
|
||
|
return c_46;
|
||
|
}
|
||
|
|
||
|
void main ()
|
||
|
{
|
||
|
v2f_surf xlt_IN_67;
|
||
|
vec4 xl_retval_68;
|
||
|
vec4 tmpvar_69;
|
||
|
tmpvar_69 = vec4(0.0, 0.0, 0.0, 0.0);
|
||
|
xlt_IN_67.pos = tmpvar_69;
|
||
|
float tmpvar_70;
|
||
|
tmpvar_70 = xlv_FOG.x;
|
||
|
xlt_IN_67.fog = tmpvar_70;
|
||
|
vec2 tmpvar_71;
|
||
|
tmpvar_71 = gl_TexCoord[0].xy;
|
||
|
vec2 tmpvar_72;
|
||
|
tmpvar_72 = tmpvar_71;
|
||
|
xlt_IN_67.hip_pack0 = tmpvar_72;
|
||
|
vec3 tmpvar_73;
|
||
|
tmpvar_73 = gl_TexCoord[1].xyz;
|
||
|
vec3 tmpvar_74;
|
||
|
tmpvar_74 = tmpvar_73;
|
||
|
xlt_IN_67.normal = tmpvar_74;
|
||
|
vec3 tmpvar_75;
|
||
|
tmpvar_75 = gl_TexCoord[2].xyz;
|
||
|
vec3 tmpvar_76;
|
||
|
tmpvar_76 = tmpvar_75;
|
||
|
xlt_IN_67.lightDir = tmpvar_76;
|
||
|
vec3 tmpvar_77;
|
||
|
tmpvar_77 = gl_TexCoord[3].xyz;
|
||
|
vec3 tmpvar_78;
|
||
|
tmpvar_78 = tmpvar_77;
|
||
|
xlt_IN_67.viewDir = tmpvar_78;
|
||
|
vec4 tmpvar_79;
|
||
|
tmpvar_79 = gl_TexCoord[4].xyzw;
|
||
|
vec4 tmpvar_80;
|
||
|
tmpvar_80 = tmpvar_79;
|
||
|
xlt_IN_67._LightCoord = tmpvar_80;
|
||
|
vec4 tmpvar_81;
|
||
|
tmpvar_81 = frag_surf (xlt_IN_67);
|
||
|
vec4 tmpvar_82;
|
||
|
tmpvar_82 = tmpvar_81;
|
||
|
xl_retval_68 = tmpvar_82;
|
||
|
vec4 tmpvar_83;
|
||
|
tmpvar_83 = xl_retval_68.xyzw;
|
||
|
vec4 tmpvar_84;
|
||
|
tmpvar_84 = tmpvar_83;
|
||
|
gl_FragData[0] = tmpvar_84;
|
||
|
}
|
||
|
|