mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 17:18:12 -05:00
319 lines
6.1 KiB
Text
319 lines
6.1 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_BumpMap;
|
|
vec3 viewDir;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec2 hip_pack0;
|
|
vec3 lightDir;
|
|
vec4 _LightCoord;
|
|
};
|
|
varying vec4 xlv_FOG;
|
|
uniform float _RimPower;
|
|
uniform vec4 _RimColor;
|
|
uniform sampler2D _MainTex;
|
|
uniform sampler2D _LightTextureB0;
|
|
uniform sampler2D _LightTexture0;
|
|
uniform vec4 _LightColor0;
|
|
uniform sampler2D _BumpMap;
|
|
float xll_saturate (
|
|
in float x
|
|
)
|
|
{
|
|
float tmpvar_1;
|
|
tmpvar_1 = clamp (x, 0.0, 1.0);
|
|
return tmpvar_1;
|
|
}
|
|
|
|
vec2 xll_saturate (
|
|
in vec2 x
|
|
)
|
|
{
|
|
vec2 tmpvar_1;
|
|
tmpvar_1 = clamp (x, 0.0, 1.0);
|
|
return tmpvar_1;
|
|
}
|
|
|
|
vec3 xll_saturate (
|
|
in vec3 x
|
|
)
|
|
{
|
|
vec3 tmpvar_1;
|
|
tmpvar_1 = clamp (x, 0.0, 1.0);
|
|
return tmpvar_1;
|
|
}
|
|
|
|
vec4 xll_saturate (
|
|
in vec4 x
|
|
)
|
|
{
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = clamp (x, 0.0, 1.0);
|
|
return tmpvar_1;
|
|
}
|
|
|
|
mat2 xll_saturate (
|
|
in mat2 m
|
|
)
|
|
{
|
|
vec2 tmpvar_1;
|
|
tmpvar_1 = clamp (m[0], 0.0, 1.0);
|
|
vec2 tmpvar_2;
|
|
tmpvar_2 = clamp (m[1], 0.0, 1.0);
|
|
mat2 tmpvar_3;
|
|
vec2 tmpvar_4;
|
|
tmpvar_4 = tmpvar_1;
|
|
tmpvar_3[0] = tmpvar_4;
|
|
vec2 tmpvar_5;
|
|
tmpvar_5 = tmpvar_2;
|
|
tmpvar_3[1] = tmpvar_5;
|
|
return tmpvar_3;
|
|
}
|
|
|
|
mat3 xll_saturate (
|
|
in mat3 m
|
|
)
|
|
{
|
|
vec3 tmpvar_1;
|
|
tmpvar_1 = clamp (m[0], 0.0, 1.0);
|
|
vec3 tmpvar_2;
|
|
tmpvar_2 = clamp (m[1], 0.0, 1.0);
|
|
vec3 tmpvar_3;
|
|
tmpvar_3 = clamp (m[2], 0.0, 1.0);
|
|
mat3 tmpvar_4;
|
|
vec3 tmpvar_5;
|
|
tmpvar_5 = tmpvar_1;
|
|
tmpvar_4[0] = tmpvar_5;
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = tmpvar_2;
|
|
tmpvar_4[1] = tmpvar_6;
|
|
vec3 tmpvar_7;
|
|
tmpvar_7 = tmpvar_3;
|
|
tmpvar_4[2] = tmpvar_7;
|
|
return tmpvar_4;
|
|
}
|
|
|
|
mat4 xll_saturate (
|
|
in mat4 m
|
|
)
|
|
{
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = clamp (m[0], 0.0, 1.0);
|
|
vec4 tmpvar_2;
|
|
tmpvar_2 = clamp (m[1], 0.0, 1.0);
|
|
vec4 tmpvar_3;
|
|
tmpvar_3 = clamp (m[2], 0.0, 1.0);
|
|
vec4 tmpvar_4;
|
|
tmpvar_4 = clamp (m[3], 0.0, 1.0);
|
|
mat4 tmpvar_5;
|
|
vec4 tmpvar_6;
|
|
tmpvar_6 = tmpvar_1;
|
|
tmpvar_5[0] = tmpvar_6;
|
|
vec4 tmpvar_7;
|
|
tmpvar_7 = tmpvar_2;
|
|
tmpvar_5[1] = tmpvar_7;
|
|
vec4 tmpvar_8;
|
|
tmpvar_8 = tmpvar_3;
|
|
tmpvar_5[2] = tmpvar_8;
|
|
vec4 tmpvar_9;
|
|
tmpvar_9 = tmpvar_4;
|
|
tmpvar_5[3] = tmpvar_9;
|
|
return tmpvar_5;
|
|
}
|
|
|
|
vec4 UnpackNormal (
|
|
in vec4 packednormal
|
|
)
|
|
{
|
|
vec4 normal;
|
|
vec2 tmpvar_1;
|
|
tmpvar_1 = ((packednormal.wy * 2.0) - 1.0);
|
|
normal.xy = tmpvar_1.xy.xy;
|
|
float tmpvar_2;
|
|
tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y)));
|
|
float tmpvar_3;
|
|
tmpvar_3 = tmpvar_2;
|
|
normal.z = vec3(tmpvar_3).z;
|
|
return normal;
|
|
}
|
|
|
|
void surf (
|
|
in Input IN,
|
|
inout SurfaceOutput o
|
|
)
|
|
{
|
|
float rim;
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = texture2D (_MainTex, IN.uv_BumpMap);
|
|
vec3 tmpvar_2;
|
|
tmpvar_2 = tmpvar_1.xyz;
|
|
o.Albedo = tmpvar_2;
|
|
vec4 tmpvar_3;
|
|
tmpvar_3 = texture2D (_BumpMap, IN.uv_BumpMap);
|
|
vec4 tmpvar_4;
|
|
tmpvar_4 = UnpackNormal (tmpvar_3);
|
|
vec3 tmpvar_5;
|
|
tmpvar_5 = tmpvar_4.xyz;
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = tmpvar_5;
|
|
o.Normal = tmpvar_6;
|
|
vec3 tmpvar_7;
|
|
tmpvar_7 = normalize (IN.viewDir);
|
|
float tmpvar_8;
|
|
tmpvar_8 = dot (tmpvar_7, o.Normal);
|
|
float tmpvar_9;
|
|
tmpvar_9 = xll_saturate (tmpvar_8);
|
|
float tmpvar_10;
|
|
tmpvar_10 = (1.0 - tmpvar_9);
|
|
rim = tmpvar_10;
|
|
float tmpvar_11;
|
|
tmpvar_11 = pow (rim, _RimPower);
|
|
vec3 tmpvar_12;
|
|
tmpvar_12 = (_RimColor.xyz * tmpvar_11);
|
|
o.Emission = tmpvar_12;
|
|
}
|
|
|
|
float UnitySpotCookie (
|
|
in vec4 LightCoord
|
|
)
|
|
{
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = texture2D (_LightTexture0, ((LightCoord.xy / LightCoord.w) + 0.5));
|
|
return tmpvar_1.w;
|
|
}
|
|
|
|
float UnitySpotAttenuate (
|
|
in vec3 LightCoord
|
|
)
|
|
{
|
|
float tmpvar_1;
|
|
tmpvar_1 = dot (LightCoord, LightCoord);
|
|
vec2 tmpvar_2;
|
|
tmpvar_2 = vec2(tmpvar_1);
|
|
vec2 tmpvar_3;
|
|
tmpvar_3 = tmpvar_2.xy;
|
|
vec4 tmpvar_4;
|
|
tmpvar_4 = texture2D (_LightTextureB0, tmpvar_3);
|
|
return tmpvar_4.w;
|
|
}
|
|
|
|
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;
|
|
SurfaceOutput o;
|
|
Input surfIN;
|
|
vec2 tmpvar_1;
|
|
tmpvar_1 = IN.hip_pack0.xy;
|
|
surfIN.uv_BumpMap = tmpvar_1;
|
|
vec3 tmpvar_2;
|
|
tmpvar_2 = vec3(0.0, 0.0, 0.0);
|
|
o.Albedo = tmpvar_2;
|
|
vec3 tmpvar_3;
|
|
tmpvar_3 = vec3(0.0, 0.0, 0.0);
|
|
o.Emission = tmpvar_3;
|
|
float tmpvar_4;
|
|
tmpvar_4 = 0.0;
|
|
o.Specular = tmpvar_4;
|
|
float tmpvar_5;
|
|
tmpvar_5 = 0.0;
|
|
o.Alpha = tmpvar_5;
|
|
float tmpvar_6;
|
|
tmpvar_6 = 0.0;
|
|
o.Gloss = 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 = UnitySpotCookie (IN._LightCoord);
|
|
float tmpvar_11;
|
|
tmpvar_11 = UnitySpotAttenuate (IN._LightCoord.xyz);
|
|
vec4 tmpvar_12;
|
|
tmpvar_12 = LightingLambert (o, lightDir, ((float((IN._LightCoord.z > 0.0)) * tmpvar_10) * tmpvar_11));
|
|
vec4 tmpvar_13;
|
|
tmpvar_13 = tmpvar_12;
|
|
c = tmpvar_13;
|
|
float tmpvar_14;
|
|
tmpvar_14 = 0.0;
|
|
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;
|
|
vec3 tmpvar_5;
|
|
tmpvar_5 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = tmpvar_5;
|
|
xlt_IN.lightDir = tmpvar_6;
|
|
vec4 tmpvar_7;
|
|
tmpvar_7 = gl_TexCoord[2].xyzw;
|
|
vec4 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;
|
|
}
|
|
|