mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-29 02:55:36 -05:00
197 lines
4.3 KiB
Text
197 lines
4.3 KiB
Text
|
struct SurfaceOutput {
|
||
|
vec3 Albedo;
|
||
|
vec3 Normal;
|
||
|
vec3 Emission;
|
||
|
float Specular;
|
||
|
float Gloss;
|
||
|
float Alpha;
|
||
|
};
|
||
|
struct Input {
|
||
|
vec2 uv_MainTex;
|
||
|
vec2 uv2_LightMap;
|
||
|
};
|
||
|
struct v2f_surf {
|
||
|
vec4 pos;
|
||
|
float fog;
|
||
|
vec2 hip_pack0;
|
||
|
vec3 normal;
|
||
|
vec3 lightDir;
|
||
|
vec4 _LightCoord;
|
||
|
};
|
||
|
varying vec4 xlv_FOG;
|
||
|
uniform sampler2D _MainTex;
|
||
|
uniform sampler2D _LightTextureB0;
|
||
|
uniform sampler2D _LightTexture0;
|
||
|
uniform sampler2D _LightMap;
|
||
|
uniform vec4 _LightColor0;
|
||
|
uniform vec4 _Color;
|
||
|
void surf (
|
||
|
in Input IN_1,
|
||
|
inout SurfaceOutput o_2
|
||
|
)
|
||
|
{
|
||
|
vec4 lm_3;
|
||
|
vec4 tmpvar_4;
|
||
|
tmpvar_4 = texture2D (_MainTex, IN_1.uv_MainTex);
|
||
|
vec3 tmpvar_5;
|
||
|
tmpvar_5 = _Color.xyz;
|
||
|
vec3 tmpvar_6;
|
||
|
tmpvar_6 = (tmpvar_4.xyz * tmpvar_5);
|
||
|
o_2.Albedo = tmpvar_6;
|
||
|
vec4 tmpvar_7;
|
||
|
tmpvar_7 = texture2D (_LightMap, IN_1.uv2_LightMap);
|
||
|
vec4 tmpvar_8;
|
||
|
tmpvar_8 = tmpvar_7;
|
||
|
lm_3 = tmpvar_8;
|
||
|
vec3 tmpvar_9;
|
||
|
tmpvar_9 = (lm_3.xyz * o_2.Albedo.xyz);
|
||
|
o_2.Emission = tmpvar_9;
|
||
|
float tmpvar_10;
|
||
|
tmpvar_10 = (lm_3.w * _Color.w);
|
||
|
o_2.Alpha = tmpvar_10;
|
||
|
}
|
||
|
|
||
|
float UnitySpotCookie (
|
||
|
in vec4 LightCoord_11
|
||
|
)
|
||
|
{
|
||
|
vec4 tmpvar_12;
|
||
|
tmpvar_12 = texture2D (_LightTexture0, ((LightCoord_11.xy / LightCoord_11.w) + 0.5));
|
||
|
return tmpvar_12.w;
|
||
|
}
|
||
|
|
||
|
float UnitySpotAttenuate (
|
||
|
in vec3 LightCoord_13
|
||
|
)
|
||
|
{
|
||
|
float tmpvar_14;
|
||
|
tmpvar_14 = dot (LightCoord_13, LightCoord_13);
|
||
|
vec2 tmpvar_15;
|
||
|
tmpvar_15 = vec2(tmpvar_14);
|
||
|
vec2 tmpvar_16;
|
||
|
tmpvar_16 = tmpvar_15.xy;
|
||
|
vec4 tmpvar_17;
|
||
|
tmpvar_17 = texture2D (_LightTextureB0, tmpvar_16);
|
||
|
return tmpvar_17.w;
|
||
|
}
|
||
|
|
||
|
vec4 LightingLambert (
|
||
|
in SurfaceOutput s_18,
|
||
|
in vec3 lightDir_19,
|
||
|
in float atten_20
|
||
|
)
|
||
|
{
|
||
|
vec4 c_21;
|
||
|
float diff_22;
|
||
|
float tmpvar_23;
|
||
|
tmpvar_23 = dot (s_18.Normal, lightDir_19);
|
||
|
float tmpvar_24;
|
||
|
tmpvar_24 = max (0.0, tmpvar_23);
|
||
|
float tmpvar_25;
|
||
|
tmpvar_25 = tmpvar_24;
|
||
|
diff_22 = tmpvar_25;
|
||
|
vec3 tmpvar_26;
|
||
|
tmpvar_26 = ((s_18.Albedo * _LightColor0.xyz) * ((diff_22 * atten_20) * 2.0));
|
||
|
c_21.xyz = tmpvar_26.xyz.xyz;
|
||
|
float tmpvar_27;
|
||
|
tmpvar_27 = s_18.Alpha;
|
||
|
c_21.w = vec4(tmpvar_27).w;
|
||
|
return c_21;
|
||
|
}
|
||
|
|
||
|
vec4 frag_surf (
|
||
|
in v2f_surf IN_28
|
||
|
)
|
||
|
{
|
||
|
vec4 c_29;
|
||
|
vec3 lightDir_30;
|
||
|
SurfaceOutput o_31;
|
||
|
Input surfIN_32;
|
||
|
vec2 tmpvar_33;
|
||
|
tmpvar_33 = IN_28.hip_pack0.xy;
|
||
|
surfIN_32.uv_MainTex = tmpvar_33;
|
||
|
vec3 tmpvar_34;
|
||
|
tmpvar_34 = vec3(0.0, 0.0, 0.0);
|
||
|
o_31.Albedo = tmpvar_34;
|
||
|
vec3 tmpvar_35;
|
||
|
tmpvar_35 = vec3(0.0, 0.0, 0.0);
|
||
|
o_31.Emission = tmpvar_35;
|
||
|
float tmpvar_36;
|
||
|
tmpvar_36 = 0.0;
|
||
|
o_31.Specular = tmpvar_36;
|
||
|
float tmpvar_37;
|
||
|
tmpvar_37 = 0.0;
|
||
|
o_31.Alpha = tmpvar_37;
|
||
|
float tmpvar_38;
|
||
|
tmpvar_38 = 0.0;
|
||
|
o_31.Gloss = tmpvar_38;
|
||
|
vec3 tmpvar_39;
|
||
|
tmpvar_39 = IN_28.normal;
|
||
|
o_31.Normal = tmpvar_39;
|
||
|
surf (surfIN_32, o_31);
|
||
|
vec3 tmpvar_40;
|
||
|
tmpvar_40 = IN_28.lightDir;
|
||
|
lightDir_30 = tmpvar_40;
|
||
|
vec3 tmpvar_41;
|
||
|
tmpvar_41 = normalize (lightDir_30);
|
||
|
vec3 tmpvar_42;
|
||
|
tmpvar_42 = tmpvar_41;
|
||
|
lightDir_30 = tmpvar_42;
|
||
|
float tmpvar_43;
|
||
|
tmpvar_43 = UnitySpotCookie (IN_28._LightCoord);
|
||
|
float tmpvar_44;
|
||
|
tmpvar_44 = UnitySpotAttenuate (IN_28._LightCoord.xyz);
|
||
|
vec4 tmpvar_45;
|
||
|
tmpvar_45 = LightingLambert (o_31, lightDir_30, ((float((IN_28._LightCoord.z > 0.0)) * tmpvar_43) * tmpvar_44));
|
||
|
vec4 tmpvar_46;
|
||
|
tmpvar_46 = tmpvar_45;
|
||
|
c_29 = tmpvar_46;
|
||
|
float tmpvar_47;
|
||
|
tmpvar_47 = 0.0;
|
||
|
c_29.w = vec4(tmpvar_47).w;
|
||
|
return c_29;
|
||
|
}
|
||
|
|
||
|
void main ()
|
||
|
{
|
||
|
v2f_surf xlt_IN_48;
|
||
|
vec4 xl_retval_49;
|
||
|
vec4 tmpvar_50;
|
||
|
tmpvar_50 = vec4(0.0, 0.0, 0.0, 0.0);
|
||
|
xlt_IN_48.pos = tmpvar_50;
|
||
|
float tmpvar_51;
|
||
|
tmpvar_51 = xlv_FOG.x;
|
||
|
xlt_IN_48.fog = tmpvar_51;
|
||
|
vec2 tmpvar_52;
|
||
|
tmpvar_52 = gl_TexCoord[0].xy;
|
||
|
vec2 tmpvar_53;
|
||
|
tmpvar_53 = tmpvar_52;
|
||
|
xlt_IN_48.hip_pack0 = tmpvar_53;
|
||
|
vec3 tmpvar_54;
|
||
|
tmpvar_54 = gl_TexCoord[1].xyz;
|
||
|
vec3 tmpvar_55;
|
||
|
tmpvar_55 = tmpvar_54;
|
||
|
xlt_IN_48.normal = tmpvar_55;
|
||
|
vec3 tmpvar_56;
|
||
|
tmpvar_56 = gl_TexCoord[2].xyz;
|
||
|
vec3 tmpvar_57;
|
||
|
tmpvar_57 = tmpvar_56;
|
||
|
xlt_IN_48.lightDir = tmpvar_57;
|
||
|
vec4 tmpvar_58;
|
||
|
tmpvar_58 = gl_TexCoord[3].xyzw;
|
||
|
vec4 tmpvar_59;
|
||
|
tmpvar_59 = tmpvar_58;
|
||
|
xlt_IN_48._LightCoord = tmpvar_59;
|
||
|
vec4 tmpvar_60;
|
||
|
tmpvar_60 = frag_surf (xlt_IN_48);
|
||
|
vec4 tmpvar_61;
|
||
|
tmpvar_61 = tmpvar_60;
|
||
|
xl_retval_49 = tmpvar_61;
|
||
|
vec4 tmpvar_62;
|
||
|
tmpvar_62 = xl_retval_49.xyzw;
|
||
|
vec4 tmpvar_63;
|
||
|
tmpvar_63 = tmpvar_62;
|
||
|
gl_FragData[0] = tmpvar_63;
|
||
|
}
|
||
|
|