mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 09:08:22 -05:00
162 lines
3.3 KiB
Text
162 lines
3.3 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec4 screenPos;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec3 normal;
|
|
vec3 lightDir;
|
|
vec3 _LightCoord;
|
|
};
|
|
varying vec4 xlv_FOG;
|
|
uniform sampler2D _MainTex;
|
|
uniform sampler2D _LightTextureB0;
|
|
uniform samplerCube _LightTexture0;
|
|
uniform vec4 _LightColor0;
|
|
void surf (
|
|
in Input IN,
|
|
inout SurfaceOutput o
|
|
)
|
|
{
|
|
vec2 uv;
|
|
vec2 tmpvar_1;
|
|
tmpvar_1 = (IN.screenPos.xy / IN.screenPos.w);
|
|
uv = tmpvar_1;
|
|
vec2 tmpvar_2;
|
|
tmpvar_2 = (uv * vec2(2.0, 1.0));
|
|
uv = tmpvar_2;
|
|
vec3 tmpvar_3;
|
|
tmpvar_3 = vec3(0.5, 0.5, 0.5);
|
|
o.Albedo = tmpvar_3;
|
|
vec4 tmpvar_4;
|
|
tmpvar_4 = texture2D (_MainTex, uv);
|
|
vec3 tmpvar_5;
|
|
tmpvar_5 = (tmpvar_4.xyz * 0.5);
|
|
o.Emission = tmpvar_5;
|
|
}
|
|
|
|
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;
|
|
vec3 lightDir;
|
|
Input surfIN;
|
|
SurfaceOutput o;
|
|
vec3 tmpvar_1;
|
|
tmpvar_1 = vec3(0.0, 0.0, 0.0);
|
|
o.Albedo = tmpvar_1;
|
|
vec3 tmpvar_2;
|
|
tmpvar_2 = vec3(0.0, 0.0, 0.0);
|
|
o.Emission = tmpvar_2;
|
|
float tmpvar_3;
|
|
tmpvar_3 = 0.0;
|
|
o.Specular = tmpvar_3;
|
|
float tmpvar_4;
|
|
tmpvar_4 = 0.0;
|
|
o.Alpha = tmpvar_4;
|
|
float tmpvar_5;
|
|
tmpvar_5 = 0.0;
|
|
o.Gloss = tmpvar_5;
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = IN.normal;
|
|
o.Normal = tmpvar_6;
|
|
surf (surfIN, o);
|
|
vec3 tmpvar_7;
|
|
tmpvar_7 = IN.lightDir;
|
|
lightDir = tmpvar_7;
|
|
vec3 tmpvar_8;
|
|
tmpvar_8 = normalize (lightDir);
|
|
vec3 tmpvar_9;
|
|
tmpvar_9 = tmpvar_8;
|
|
lightDir = tmpvar_9;
|
|
float tmpvar_10;
|
|
tmpvar_10 = dot (IN._LightCoord, IN._LightCoord);
|
|
vec2 tmpvar_11;
|
|
tmpvar_11 = vec2(tmpvar_10);
|
|
vec2 tmpvar_12;
|
|
tmpvar_12 = tmpvar_11.xy;
|
|
vec4 tmpvar_13;
|
|
tmpvar_13 = texture2D (_LightTextureB0, tmpvar_12);
|
|
vec4 tmpvar_14;
|
|
tmpvar_14 = textureCube (_LightTexture0, IN._LightCoord);
|
|
vec4 tmpvar_15;
|
|
tmpvar_15 = LightingLambert (o, lightDir, (tmpvar_13.w * tmpvar_14.w));
|
|
vec4 tmpvar_16;
|
|
tmpvar_16 = tmpvar_15;
|
|
c = tmpvar_16;
|
|
float tmpvar_17;
|
|
tmpvar_17 = 0.0;
|
|
c.w = vec4(tmpvar_17).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;
|
|
vec3 tmpvar_3;
|
|
tmpvar_3 = gl_TexCoord[0].xyz;
|
|
vec3 tmpvar_4;
|
|
tmpvar_4 = tmpvar_3;
|
|
xlt_IN.normal = tmpvar_4;
|
|
vec3 tmpvar_5;
|
|
tmpvar_5 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = tmpvar_5;
|
|
xlt_IN.lightDir = tmpvar_6;
|
|
vec3 tmpvar_7;
|
|
tmpvar_7 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_8;
|
|
tmpvar_8 = tmpvar_7;
|
|
xlt_IN._LightCoord = tmpvar_8;
|
|
vec4 tmpvar_9;
|
|
tmpvar_9 = frag_surf (xlt_IN);
|
|
vec4 tmpvar_10;
|
|
tmpvar_10 = tmpvar_9;
|
|
xl_retval = tmpvar_10;
|
|
vec4 tmpvar_11;
|
|
tmpvar_11 = xl_retval.xyzw;
|
|
vec4 tmpvar_12;
|
|
tmpvar_12 = tmpvar_11;
|
|
gl_FragData[0] = tmpvar_12;
|
|
}
|
|
|