mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-29 02:55:36 -05:00
295 lines
5.5 KiB
Text
295 lines
5.5 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_MainTex;
|
|
vec3 worldPos;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec2 hip_pack0;
|
|
vec3 worldPos;
|
|
vec4 hip_screen;
|
|
vec3 hip_lmapFade;
|
|
};
|
|
varying vec4 xlv_FOG;
|
|
uniform sampler2D unity_LightmapInd;
|
|
uniform sampler2D unity_Lightmap;
|
|
uniform sampler2D _MainTex;
|
|
uniform sampler2D _LightBuffer;
|
|
void xll_clip (
|
|
in float x
|
|
)
|
|
{
|
|
if ((x < 0.0)) {
|
|
discard;
|
|
};
|
|
}
|
|
|
|
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
|
|
)
|
|
{
|
|
float tmpvar_1;
|
|
tmpvar_1 = fract (((IN.worldPos.y + (IN.worldPos.z * 0.1)) * 5.0));
|
|
xll_clip ((tmpvar_1 - 0.5));
|
|
vec4 tmpvar_2;
|
|
tmpvar_2 = texture2D (_MainTex, IN.uv_MainTex);
|
|
vec3 tmpvar_3;
|
|
tmpvar_3 = tmpvar_2.xyz;
|
|
o.Albedo = tmpvar_3;
|
|
}
|
|
|
|
vec4 LightingLambert_PrePass (
|
|
in SurfaceOutput s,
|
|
in vec4 light
|
|
)
|
|
{
|
|
vec4 c;
|
|
vec3 tmpvar_1;
|
|
tmpvar_1 = (s.Albedo * light.xyz);
|
|
c.xyz = tmpvar_1.xyz.xyz;
|
|
float tmpvar_2;
|
|
tmpvar_2 = s.Alpha;
|
|
c.w = vec4(tmpvar_2).w;
|
|
return c;
|
|
}
|
|
|
|
vec3 DecodeLightmap (
|
|
in vec4 color
|
|
)
|
|
{
|
|
return (2.0 * color.xyz);
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN
|
|
)
|
|
{
|
|
vec4 col;
|
|
vec3 lm;
|
|
vec3 lmIndirect;
|
|
vec3 lmFull;
|
|
vec4 light;
|
|
SurfaceOutput o;
|
|
Input surfIN;
|
|
vec2 tmpvar_1;
|
|
tmpvar_1 = IN.hip_pack0.xy;
|
|
surfIN.uv_MainTex = tmpvar_1;
|
|
vec3 tmpvar_2;
|
|
tmpvar_2 = IN.worldPos;
|
|
surfIN.worldPos = 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;
|
|
surf (surfIN, o);
|
|
vec4 tmpvar_8;
|
|
tmpvar_8 = texture2DProj (_LightBuffer, IN.hip_screen);
|
|
vec4 tmpvar_9;
|
|
tmpvar_9 = tmpvar_8;
|
|
light = tmpvar_9;
|
|
vec4 tmpvar_10;
|
|
tmpvar_10 = log2 (light);
|
|
vec4 tmpvar_11;
|
|
tmpvar_11 = -(tmpvar_10);
|
|
light = tmpvar_11;
|
|
vec4 tmpvar_12;
|
|
tmpvar_12 = texture2D (unity_Lightmap, IN.hip_lmapFade.xy);
|
|
vec3 tmpvar_13;
|
|
tmpvar_13 = DecodeLightmap (tmpvar_12);
|
|
vec3 tmpvar_14;
|
|
tmpvar_14 = tmpvar_13;
|
|
lmFull = tmpvar_14;
|
|
vec4 tmpvar_15;
|
|
tmpvar_15 = texture2D (unity_LightmapInd, IN.hip_lmapFade.xy);
|
|
vec3 tmpvar_16;
|
|
tmpvar_16 = DecodeLightmap (tmpvar_15);
|
|
vec3 tmpvar_17;
|
|
tmpvar_17 = tmpvar_16;
|
|
lmIndirect = tmpvar_17;
|
|
float tmpvar_18;
|
|
tmpvar_18 = xll_saturate (IN.hip_lmapFade.z);
|
|
vec3 tmpvar_19;
|
|
tmpvar_19 = vec3(tmpvar_18);
|
|
vec3 tmpvar_20;
|
|
tmpvar_20 = mix (lmIndirect, lmFull, tmpvar_19);
|
|
vec3 tmpvar_21;
|
|
tmpvar_21 = tmpvar_20;
|
|
lm = tmpvar_21;
|
|
vec3 tmpvar_22;
|
|
tmpvar_22 = (light.xyz + lm);
|
|
light.xyz = tmpvar_22.xyz.xyz;
|
|
vec4 tmpvar_23;
|
|
tmpvar_23 = LightingLambert_PrePass (o, light);
|
|
vec4 tmpvar_24;
|
|
tmpvar_24 = tmpvar_23;
|
|
col = tmpvar_24;
|
|
return col;
|
|
}
|
|
|
|
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.worldPos = tmpvar_6;
|
|
vec4 tmpvar_7;
|
|
tmpvar_7 = gl_TexCoord[2].xyzw;
|
|
vec4 tmpvar_8;
|
|
tmpvar_8 = tmpvar_7;
|
|
xlt_IN.hip_screen = tmpvar_8;
|
|
vec3 tmpvar_9;
|
|
tmpvar_9 = gl_TexCoord[3].xyz;
|
|
vec3 tmpvar_10;
|
|
tmpvar_10 = tmpvar_9;
|
|
xlt_IN.hip_lmapFade = tmpvar_10;
|
|
vec4 tmpvar_11;
|
|
tmpvar_11 = frag_surf (xlt_IN);
|
|
vec4 tmpvar_12;
|
|
tmpvar_12 = tmpvar_11;
|
|
xl_retval = tmpvar_12;
|
|
vec4 tmpvar_13;
|
|
tmpvar_13 = xl_retval.xyzw;
|
|
vec4 tmpvar_14;
|
|
tmpvar_14 = tmpvar_13;
|
|
gl_FragData[0] = tmpvar_14;
|
|
}
|
|
|