mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-12 09:11:18 -05:00
240 lines
4.9 KiB
Text
240 lines
4.9 KiB
Text
|
struct SurfaceOutput {
|
||
|
vec3 Albedo;
|
||
|
vec3 Normal;
|
||
|
vec3 Emission;
|
||
|
float Specular;
|
||
|
float Gloss;
|
||
|
float Alpha;
|
||
|
};
|
||
|
struct Input {
|
||
|
vec2 uv_MainTex;
|
||
|
vec2 uv_BumpMap;
|
||
|
vec2 uv_Illum;
|
||
|
vec3 viewDir;
|
||
|
};
|
||
|
struct v2f_surf {
|
||
|
vec4 pos;
|
||
|
float fog;
|
||
|
vec4 hip_pack0;
|
||
|
vec2 hip_pack1;
|
||
|
vec3 viewDir;
|
||
|
vec4 hip_screen;
|
||
|
};
|
||
|
varying vec4 xlv_FOG;
|
||
|
uniform vec4 unity_Ambient;
|
||
|
uniform sampler2D _ParallaxMap;
|
||
|
uniform float _Parallax;
|
||
|
uniform sampler2D _MainTex;
|
||
|
uniform sampler2D _LightBuffer;
|
||
|
uniform sampler2D _Illum;
|
||
|
uniform vec4 _Color;
|
||
|
uniform sampler2D _BumpMap;
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
vec2 ParallaxOffset (
|
||
|
in float h,
|
||
|
in float height,
|
||
|
in vec3 viewDir
|
||
|
)
|
||
|
{
|
||
|
vec3 v;
|
||
|
float tmpvar_1;
|
||
|
tmpvar_1 = ((h * height) - (height / 2.0));
|
||
|
h = tmpvar_1;
|
||
|
vec3 tmpvar_2;
|
||
|
tmpvar_2 = normalize (viewDir);
|
||
|
vec3 tmpvar_3;
|
||
|
tmpvar_3 = tmpvar_2;
|
||
|
v = tmpvar_3;
|
||
|
float tmpvar_4;
|
||
|
tmpvar_4 = (v.z + 0.42);
|
||
|
v.z = vec3(tmpvar_4).z;
|
||
|
return (h * (v.xy / v.z));
|
||
|
}
|
||
|
|
||
|
void surf (
|
||
|
in Input IN,
|
||
|
inout SurfaceOutput o
|
||
|
)
|
||
|
{
|
||
|
vec4 c;
|
||
|
vec2 offset;
|
||
|
float h;
|
||
|
vec4 tmpvar_1;
|
||
|
tmpvar_1 = texture2D (_ParallaxMap, IN.uv_BumpMap);
|
||
|
float tmpvar_2;
|
||
|
tmpvar_2 = tmpvar_1.w;
|
||
|
h = tmpvar_2;
|
||
|
vec2 tmpvar_3;
|
||
|
tmpvar_3 = ParallaxOffset (h, _Parallax, IN.viewDir);
|
||
|
vec2 tmpvar_4;
|
||
|
tmpvar_4 = tmpvar_3;
|
||
|
offset = tmpvar_4;
|
||
|
vec2 tmpvar_5;
|
||
|
tmpvar_5 = (IN.uv_MainTex + offset);
|
||
|
IN.uv_MainTex = tmpvar_5;
|
||
|
vec2 tmpvar_6;
|
||
|
tmpvar_6 = (IN.uv_BumpMap + offset);
|
||
|
IN.uv_BumpMap = tmpvar_6;
|
||
|
vec2 tmpvar_7;
|
||
|
tmpvar_7 = (IN.uv_Illum + offset);
|
||
|
IN.uv_Illum = tmpvar_7;
|
||
|
vec4 tmpvar_8;
|
||
|
tmpvar_8 = texture2D (_MainTex, IN.uv_MainTex);
|
||
|
vec4 tmpvar_9;
|
||
|
tmpvar_9 = (tmpvar_8 * _Color);
|
||
|
c = tmpvar_9;
|
||
|
vec3 tmpvar_10;
|
||
|
tmpvar_10 = c.xyz;
|
||
|
o.Albedo = tmpvar_10;
|
||
|
vec4 tmpvar_11;
|
||
|
tmpvar_11 = texture2D (_Illum, IN.uv_Illum);
|
||
|
vec3 tmpvar_12;
|
||
|
tmpvar_12 = (c.xyz * tmpvar_11.w);
|
||
|
o.Emission = tmpvar_12;
|
||
|
float tmpvar_13;
|
||
|
tmpvar_13 = c.w;
|
||
|
o.Alpha = tmpvar_13;
|
||
|
vec4 tmpvar_14;
|
||
|
tmpvar_14 = texture2D (_BumpMap, IN.uv_BumpMap);
|
||
|
vec4 tmpvar_15;
|
||
|
tmpvar_15 = UnpackNormal (tmpvar_14);
|
||
|
vec3 tmpvar_16;
|
||
|
tmpvar_16 = tmpvar_15.xyz;
|
||
|
vec3 tmpvar_17;
|
||
|
tmpvar_17 = tmpvar_16;
|
||
|
o.Normal = tmpvar_17;
|
||
|
}
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
vec4 frag_surf (
|
||
|
in v2f_surf IN
|
||
|
)
|
||
|
{
|
||
|
vec4 col;
|
||
|
vec4 light;
|
||
|
SurfaceOutput o;
|
||
|
Input surfIN;
|
||
|
vec2 tmpvar_1;
|
||
|
tmpvar_1 = IN.hip_pack0.xy;
|
||
|
surfIN.uv_MainTex = tmpvar_1;
|
||
|
vec2 tmpvar_2;
|
||
|
tmpvar_2 = IN.hip_pack0.zw;
|
||
|
surfIN.uv_BumpMap = tmpvar_2;
|
||
|
vec2 tmpvar_3;
|
||
|
tmpvar_3 = IN.hip_pack1.xy;
|
||
|
surfIN.uv_Illum = tmpvar_3;
|
||
|
vec3 tmpvar_4;
|
||
|
tmpvar_4 = IN.viewDir;
|
||
|
surfIN.viewDir = tmpvar_4;
|
||
|
vec3 tmpvar_5;
|
||
|
tmpvar_5 = vec3(0.0, 0.0, 0.0);
|
||
|
o.Albedo = tmpvar_5;
|
||
|
vec3 tmpvar_6;
|
||
|
tmpvar_6 = vec3(0.0, 0.0, 0.0);
|
||
|
o.Emission = tmpvar_6;
|
||
|
float tmpvar_7;
|
||
|
tmpvar_7 = 0.0;
|
||
|
o.Specular = tmpvar_7;
|
||
|
float tmpvar_8;
|
||
|
tmpvar_8 = 0.0;
|
||
|
o.Alpha = tmpvar_8;
|
||
|
float tmpvar_9;
|
||
|
tmpvar_9 = 0.0;
|
||
|
o.Gloss = tmpvar_9;
|
||
|
surf (surfIN, o);
|
||
|
vec4 tmpvar_10;
|
||
|
tmpvar_10 = texture2DProj (_LightBuffer, IN.hip_screen);
|
||
|
vec4 tmpvar_11;
|
||
|
tmpvar_11 = tmpvar_10;
|
||
|
light = tmpvar_11;
|
||
|
vec4 tmpvar_12;
|
||
|
tmpvar_12 = log2 (light);
|
||
|
vec4 tmpvar_13;
|
||
|
tmpvar_13 = -(tmpvar_12);
|
||
|
light = tmpvar_13;
|
||
|
vec3 tmpvar_14;
|
||
|
tmpvar_14 = (light.xyz + unity_Ambient.xyz);
|
||
|
light.xyz = tmpvar_14.xyz.xyz;
|
||
|
vec4 tmpvar_15;
|
||
|
tmpvar_15 = LightingLambert_PrePass (o, light);
|
||
|
vec4 tmpvar_16;
|
||
|
tmpvar_16 = tmpvar_15;
|
||
|
col = tmpvar_16;
|
||
|
vec3 tmpvar_17;
|
||
|
tmpvar_17 = (col.xyz + o.Emission);
|
||
|
col.xyz = tmpvar_17.xyz.xyz;
|
||
|
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;
|
||
|
vec4 tmpvar_3;
|
||
|
tmpvar_3 = gl_TexCoord[0].xyzw;
|
||
|
vec4 tmpvar_4;
|
||
|
tmpvar_4 = tmpvar_3;
|
||
|
xlt_IN.hip_pack0 = tmpvar_4;
|
||
|
vec2 tmpvar_5;
|
||
|
tmpvar_5 = gl_TexCoord[1].xy;
|
||
|
vec2 tmpvar_6;
|
||
|
tmpvar_6 = tmpvar_5;
|
||
|
xlt_IN.hip_pack1 = tmpvar_6;
|
||
|
vec3 tmpvar_7;
|
||
|
tmpvar_7 = gl_TexCoord[2].xyz;
|
||
|
vec3 tmpvar_8;
|
||
|
tmpvar_8 = tmpvar_7;
|
||
|
xlt_IN.viewDir = tmpvar_8;
|
||
|
vec4 tmpvar_9;
|
||
|
tmpvar_9 = gl_TexCoord[3].xyzw;
|
||
|
vec4 tmpvar_10;
|
||
|
tmpvar_10 = tmpvar_9;
|
||
|
xlt_IN.hip_screen = 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;
|
||
|
}
|
||
|
|