mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-01 11:56:58 -05:00
311 lines
6 KiB
Text
311 lines
6 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_MainTex;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
vec3 _ShadowCoord0;
|
|
vec3 _ShadowCoord1;
|
|
vec3 _ShadowCoord2;
|
|
vec3 _ShadowCoord3;
|
|
vec2 _ShadowZFade;
|
|
};
|
|
uniform sampler2D _ShadowMapTexture;
|
|
uniform vec4 _ProjectionParams;
|
|
uniform sampler2D _MainTex;
|
|
uniform vec4 _LightSplitsNear;
|
|
uniform vec4 _LightSplitsFar;
|
|
uniform vec4 _LightShadowData;
|
|
uniform vec4 _Color;
|
|
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;
|
|
}
|
|
|
|
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 * _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;
|
|
}
|
|
|
|
vec2 EncodeFloatRG (
|
|
in float v
|
|
)
|
|
{
|
|
vec2 enc;
|
|
float kEncodeBit;
|
|
vec2 kEncodeMul;
|
|
vec2 tmpvar_1;
|
|
tmpvar_1 = vec2(1.0, 255.0);
|
|
kEncodeMul = tmpvar_1;
|
|
float tmpvar_2;
|
|
tmpvar_2 = 0.00392157;
|
|
kEncodeBit = tmpvar_2;
|
|
vec2 tmpvar_3;
|
|
tmpvar_3 = (kEncodeMul * v);
|
|
enc = tmpvar_3;
|
|
vec2 tmpvar_4;
|
|
tmpvar_4 = fract (enc);
|
|
vec2 tmpvar_5;
|
|
tmpvar_5 = tmpvar_4;
|
|
enc = tmpvar_5;
|
|
float tmpvar_6;
|
|
tmpvar_6 = (enc.x - (enc.y * kEncodeBit));
|
|
enc.x = tmpvar_6;
|
|
return enc;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN
|
|
)
|
|
{
|
|
vec4 res;
|
|
float faded;
|
|
float shadow;
|
|
vec4 coord;
|
|
vec4 weights;
|
|
vec4 far;
|
|
vec4 near;
|
|
vec4 z;
|
|
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;
|
|
surf (surfIN, o);
|
|
vec4 tmpvar_6;
|
|
tmpvar_6 = vec4(IN._ShadowZFade.x);
|
|
vec4 tmpvar_7;
|
|
tmpvar_7 = tmpvar_6;
|
|
z = tmpvar_7;
|
|
bvec4 tmpvar_8;
|
|
tmpvar_8 = greaterThanEqual (z, _LightSplitsNear);
|
|
vec4 tmpvar_9;
|
|
tmpvar_9 = vec4(tmpvar_8).xyzw;
|
|
vec4 tmpvar_10;
|
|
tmpvar_10 = tmpvar_9;
|
|
near = tmpvar_10;
|
|
bvec4 tmpvar_11;
|
|
tmpvar_11 = lessThan (z, _LightSplitsFar);
|
|
vec4 tmpvar_12;
|
|
tmpvar_12 = vec4(tmpvar_11).xyzw;
|
|
vec4 tmpvar_13;
|
|
tmpvar_13 = tmpvar_12;
|
|
far = tmpvar_13;
|
|
vec4 tmpvar_14;
|
|
tmpvar_14 = (near * far);
|
|
weights = tmpvar_14;
|
|
vec4 tmpvar_15;
|
|
tmpvar_15.w = 1.0;
|
|
tmpvar_15.xyz = ((((IN._ShadowCoord0 * weights.x) + (IN._ShadowCoord1 * weights.y)) + (IN._ShadowCoord2 * weights.z)) + (IN._ShadowCoord3 * weights.w)).xyz;
|
|
vec4 tmpvar_16;
|
|
tmpvar_16 = tmpvar_15;
|
|
coord = tmpvar_16;
|
|
vec4 tmpvar_17;
|
|
tmpvar_17 = texture2D (_ShadowMapTexture, coord.xy);
|
|
float tmpvar_18;
|
|
if ((tmpvar_17.x < coord.z)) {
|
|
tmpvar_18 = _LightShadowData.x;
|
|
} else {
|
|
tmpvar_18 = 1.0;
|
|
};
|
|
float tmpvar_19;
|
|
tmpvar_19 = tmpvar_18;
|
|
shadow = tmpvar_19;
|
|
float tmpvar_20;
|
|
tmpvar_20 = xll_saturate (IN._ShadowZFade.y);
|
|
float tmpvar_21;
|
|
tmpvar_21 = xll_saturate ((shadow + tmpvar_20));
|
|
float tmpvar_22;
|
|
tmpvar_22 = tmpvar_21;
|
|
faded = tmpvar_22;
|
|
float tmpvar_23;
|
|
tmpvar_23 = faded;
|
|
res.x = tmpvar_23;
|
|
float tmpvar_24;
|
|
tmpvar_24 = 1.0;
|
|
res.y = vec2(tmpvar_24).y;
|
|
vec2 tmpvar_25;
|
|
tmpvar_25 = EncodeFloatRG ((1.0 - (z * _ProjectionParams.w)).x);
|
|
vec2 tmpvar_26;
|
|
tmpvar_26 = tmpvar_25;
|
|
res.zw = tmpvar_26.xxxy.zw;
|
|
return res;
|
|
}
|
|
|
|
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;
|
|
vec3 tmpvar_2;
|
|
tmpvar_2 = gl_TexCoord[0].xyz;
|
|
vec3 tmpvar_3;
|
|
tmpvar_3 = tmpvar_2;
|
|
xlt_IN._ShadowCoord0 = tmpvar_3;
|
|
vec3 tmpvar_4;
|
|
tmpvar_4 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_5;
|
|
tmpvar_5 = tmpvar_4;
|
|
xlt_IN._ShadowCoord1 = tmpvar_5;
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_7;
|
|
tmpvar_7 = tmpvar_6;
|
|
xlt_IN._ShadowCoord2 = tmpvar_7;
|
|
vec3 tmpvar_8;
|
|
tmpvar_8 = gl_TexCoord[3].xyz;
|
|
vec3 tmpvar_9;
|
|
tmpvar_9 = tmpvar_8;
|
|
xlt_IN._ShadowCoord3 = tmpvar_9;
|
|
vec2 tmpvar_10;
|
|
tmpvar_10 = gl_TexCoord[4].xy;
|
|
vec2 tmpvar_11;
|
|
tmpvar_11 = tmpvar_10;
|
|
xlt_IN._ShadowZFade = tmpvar_11;
|
|
vec4 tmpvar_12;
|
|
tmpvar_12 = frag_surf (xlt_IN);
|
|
vec4 tmpvar_13;
|
|
tmpvar_13 = tmpvar_12;
|
|
xl_retval = tmpvar_13;
|
|
vec4 tmpvar_14;
|
|
tmpvar_14 = xl_retval.xyzw;
|
|
vec4 tmpvar_15;
|
|
tmpvar_15 = tmpvar_14;
|
|
gl_FragData[0] = tmpvar_15;
|
|
}
|
|
|