mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 17:18:12 -05:00
192 lines
3.7 KiB
Text
192 lines
3.7 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_MainTex;
|
|
vec4 color;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec2 hip_pack0;
|
|
vec4 lop_color;
|
|
vec3 normal;
|
|
vec3 vlight;
|
|
vec4 _ShadowCoord;
|
|
};
|
|
varying vec4 xlv_FOG;
|
|
uniform vec4 _WorldSpaceLightPos0;
|
|
uniform sampler2D _ShadowMapTexture;
|
|
uniform sampler2D _MainTex;
|
|
uniform vec4 _LightColor0;
|
|
uniform float _Cutoff;
|
|
void xll_clip (
|
|
in float x
|
|
)
|
|
{
|
|
if ((x < 0.0)) {
|
|
discard;
|
|
};
|
|
}
|
|
|
|
float unitySampleShadow (
|
|
in vec4 shadowCoord
|
|
)
|
|
{
|
|
float shadow;
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = texture2DProj (_ShadowMapTexture, shadowCoord);
|
|
float tmpvar_2;
|
|
tmpvar_2 = tmpvar_1.x;
|
|
shadow = tmpvar_2;
|
|
return shadow;
|
|
}
|
|
|
|
void surf (
|
|
in Input IN,
|
|
inout SurfaceOutput o
|
|
)
|
|
{
|
|
vec4 c;
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex);
|
|
vec4 tmpvar_2;
|
|
tmpvar_2 = (tmpvar_1 * IN.color);
|
|
c = tmpvar_2;
|
|
vec3 tmpvar_3;
|
|
tmpvar_3 = c.xyz;
|
|
o.Albedo = tmpvar_3;
|
|
float tmpvar_4;
|
|
tmpvar_4 = c.w;
|
|
o.Alpha = tmpvar_4;
|
|
}
|
|
|
|
vec4 LightingLambert (
|
|
in SurfaceOutput s,
|
|
in vec3 lightDir,
|
|
in float atten
|
|
)
|
|
{
|
|
vec4 c;
|
|
float diff;
|
|
float tmpvar_1;
|
|
tmpvar_1 = dot (s.Normal, lightDir);
|
|
float tmpvar_2;
|
|
tmpvar_2 = max (0.0, tmpvar_1);
|
|
float tmpvar_3;
|
|
tmpvar_3 = tmpvar_2;
|
|
diff = tmpvar_3;
|
|
vec3 tmpvar_4;
|
|
tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0));
|
|
c.xyz = tmpvar_4.xyz.xyz;
|
|
float tmpvar_5;
|
|
tmpvar_5 = s.Alpha;
|
|
c.w = vec4(tmpvar_5).w;
|
|
return c;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN
|
|
)
|
|
{
|
|
vec4 c;
|
|
float atten;
|
|
SurfaceOutput o;
|
|
Input surfIN;
|
|
vec2 tmpvar_1;
|
|
tmpvar_1 = IN.hip_pack0.xy;
|
|
surfIN.uv_MainTex = tmpvar_1;
|
|
vec4 tmpvar_2;
|
|
tmpvar_2 = IN.lop_color;
|
|
surfIN.color = tmpvar_2;
|
|
vec3 tmpvar_3;
|
|
tmpvar_3 = vec3(0.0, 0.0, 0.0);
|
|
o.Albedo = tmpvar_3;
|
|
vec3 tmpvar_4;
|
|
tmpvar_4 = vec3(0.0, 0.0, 0.0);
|
|
o.Emission = tmpvar_4;
|
|
float tmpvar_5;
|
|
tmpvar_5 = 0.0;
|
|
o.Specular = tmpvar_5;
|
|
float tmpvar_6;
|
|
tmpvar_6 = 0.0;
|
|
o.Alpha = tmpvar_6;
|
|
float tmpvar_7;
|
|
tmpvar_7 = 0.0;
|
|
o.Gloss = tmpvar_7;
|
|
vec3 tmpvar_8;
|
|
tmpvar_8 = IN.normal;
|
|
o.Normal = tmpvar_8;
|
|
surf (surfIN, o);
|
|
xll_clip ((o.Alpha - _Cutoff));
|
|
float tmpvar_9;
|
|
tmpvar_9 = unitySampleShadow (IN._ShadowCoord);
|
|
float tmpvar_10;
|
|
tmpvar_10 = tmpvar_9;
|
|
atten = tmpvar_10;
|
|
vec4 tmpvar_11;
|
|
tmpvar_11 = LightingLambert (o, _WorldSpaceLightPos0.xyz, atten);
|
|
vec4 tmpvar_12;
|
|
tmpvar_12 = tmpvar_11;
|
|
c = tmpvar_12;
|
|
vec3 tmpvar_13;
|
|
tmpvar_13 = (c.xyz + (o.Albedo * IN.vlight));
|
|
c.xyz = tmpvar_13.xyz.xyz;
|
|
float tmpvar_14;
|
|
tmpvar_14 = o.Alpha;
|
|
c.w = vec4(tmpvar_14).w;
|
|
return c;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN;
|
|
vec4 xl_retval;
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN.pos = tmpvar_1;
|
|
float tmpvar_2;
|
|
tmpvar_2 = xlv_FOG.x;
|
|
xlt_IN.fog = tmpvar_2;
|
|
vec2 tmpvar_3;
|
|
tmpvar_3 = gl_TexCoord[0].xy;
|
|
vec2 tmpvar_4;
|
|
tmpvar_4 = tmpvar_3;
|
|
xlt_IN.hip_pack0 = tmpvar_4;
|
|
vec4 tmpvar_5;
|
|
tmpvar_5 = gl_Color.xyzw;
|
|
vec4 tmpvar_6;
|
|
tmpvar_6 = tmpvar_5;
|
|
xlt_IN.lop_color = tmpvar_6;
|
|
vec3 tmpvar_7;
|
|
tmpvar_7 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_8;
|
|
tmpvar_8 = tmpvar_7;
|
|
xlt_IN.normal = tmpvar_8;
|
|
vec3 tmpvar_9;
|
|
tmpvar_9 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_10;
|
|
tmpvar_10 = tmpvar_9;
|
|
xlt_IN.vlight = tmpvar_10;
|
|
vec4 tmpvar_11;
|
|
tmpvar_11 = gl_TexCoord[3].xyzw;
|
|
vec4 tmpvar_12;
|
|
tmpvar_12 = tmpvar_11;
|
|
xlt_IN._ShadowCoord = tmpvar_12;
|
|
vec4 tmpvar_13;
|
|
tmpvar_13 = frag_surf (xlt_IN);
|
|
vec4 tmpvar_14;
|
|
tmpvar_14 = tmpvar_13;
|
|
xl_retval = tmpvar_14;
|
|
vec4 tmpvar_15;
|
|
tmpvar_15 = xl_retval.xyzw;
|
|
vec4 tmpvar_16;
|
|
tmpvar_16 = tmpvar_15;
|
|
gl_FragData[0] = tmpvar_16;
|
|
}
|
|
|