mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 09:08:22 -05:00
253 lines
5.4 KiB
Text
253 lines
5.4 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_MainTex;
|
|
vec2 uv_BumpMap;
|
|
vec3 worldRefl;
|
|
vec3 TtoW0;
|
|
vec3 TtoW1;
|
|
vec3 TtoW2;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec4 hip_pack0;
|
|
vec4 hip_screen;
|
|
vec4 TtoW0;
|
|
vec4 TtoW1;
|
|
vec4 TtoW2;
|
|
};
|
|
varying vec4 xlv_FOG;
|
|
uniform vec4 unity_Ambient;
|
|
uniform vec4 _SpecColor;
|
|
uniform float _Shininess;
|
|
uniform vec4 _ReflectColor;
|
|
uniform sampler2D _MainTex;
|
|
uniform sampler2D _LightBuffer;
|
|
uniform samplerCube _Cube;
|
|
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;
|
|
}
|
|
|
|
void surf (
|
|
in Input IN,
|
|
inout SurfaceOutput o
|
|
)
|
|
{
|
|
vec4 reflcol;
|
|
vec3 worldRefl;
|
|
vec4 c;
|
|
vec4 tex;
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex);
|
|
vec4 tmpvar_2;
|
|
tmpvar_2 = tmpvar_1;
|
|
tex = tmpvar_2;
|
|
vec4 tmpvar_3;
|
|
tmpvar_3 = (tex * _Color);
|
|
c = tmpvar_3;
|
|
vec3 tmpvar_4;
|
|
tmpvar_4 = c.xyz;
|
|
o.Albedo = tmpvar_4;
|
|
float tmpvar_5;
|
|
tmpvar_5 = tex.w;
|
|
o.Gloss = tmpvar_5;
|
|
float tmpvar_6;
|
|
tmpvar_6 = _Shininess;
|
|
o.Specular = tmpvar_6;
|
|
vec4 tmpvar_7;
|
|
tmpvar_7 = texture2D (_BumpMap, IN.uv_BumpMap);
|
|
vec4 tmpvar_8;
|
|
tmpvar_8 = UnpackNormal (tmpvar_7);
|
|
vec3 tmpvar_9;
|
|
tmpvar_9 = tmpvar_8.xyz;
|
|
vec3 tmpvar_10;
|
|
tmpvar_10 = tmpvar_9;
|
|
o.Normal = tmpvar_10;
|
|
float tmpvar_11;
|
|
tmpvar_11 = dot (IN.TtoW0, o.Normal);
|
|
float tmpvar_12;
|
|
tmpvar_12 = dot (IN.TtoW1, o.Normal);
|
|
float tmpvar_13;
|
|
tmpvar_13 = dot (IN.TtoW2, o.Normal);
|
|
vec3 tmpvar_14;
|
|
tmpvar_14.x = tmpvar_11;
|
|
tmpvar_14.y = tmpvar_12;
|
|
tmpvar_14.z = tmpvar_13;
|
|
vec3 tmpvar_15;
|
|
tmpvar_15 = reflect (IN.worldRefl, tmpvar_14);
|
|
vec3 tmpvar_16;
|
|
tmpvar_16 = tmpvar_15;
|
|
worldRefl = tmpvar_16;
|
|
vec4 tmpvar_17;
|
|
tmpvar_17 = textureCube (_Cube, worldRefl);
|
|
vec4 tmpvar_18;
|
|
tmpvar_18 = tmpvar_17;
|
|
reflcol = tmpvar_18;
|
|
vec4 tmpvar_19;
|
|
tmpvar_19 = (reflcol * tex.w);
|
|
reflcol = tmpvar_19;
|
|
vec3 tmpvar_20;
|
|
tmpvar_20 = (reflcol.xyz * _ReflectColor.xyz);
|
|
o.Emission = tmpvar_20;
|
|
float tmpvar_21;
|
|
tmpvar_21 = (reflcol.w * _ReflectColor.w);
|
|
o.Alpha = tmpvar_21;
|
|
}
|
|
|
|
vec4 LightingBlinnPhong_PrePass (
|
|
in SurfaceOutput s,
|
|
in vec4 light
|
|
)
|
|
{
|
|
vec4 c;
|
|
float spec;
|
|
float tmpvar_1;
|
|
tmpvar_1 = (light.w * s.Gloss);
|
|
spec = tmpvar_1;
|
|
vec3 tmpvar_2;
|
|
tmpvar_2 = ((s.Albedo * light.xyz) + ((light.xyz * _SpecColor.xyz) * spec));
|
|
c.xyz = tmpvar_2.xyz.xyz;
|
|
float tmpvar_3;
|
|
tmpvar_3 = (s.Alpha + (spec * _SpecColor.w));
|
|
c.w = vec4(tmpvar_3).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;
|
|
vec3 tmpvar_3;
|
|
tmpvar_3.x = IN.TtoW0.w;
|
|
tmpvar_3.y = IN.TtoW1.w;
|
|
tmpvar_3.z = IN.TtoW2.w;
|
|
vec3 tmpvar_4;
|
|
tmpvar_4 = tmpvar_3;
|
|
surfIN.worldRefl = tmpvar_4;
|
|
vec3 tmpvar_5;
|
|
tmpvar_5 = IN.TtoW0.xyz;
|
|
surfIN.TtoW0 = tmpvar_5;
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = IN.TtoW1.xyz;
|
|
surfIN.TtoW1 = tmpvar_6;
|
|
vec3 tmpvar_7;
|
|
tmpvar_7 = IN.TtoW2.xyz;
|
|
surfIN.TtoW2 = tmpvar_7;
|
|
vec3 tmpvar_8;
|
|
tmpvar_8 = vec3(0.0, 0.0, 0.0);
|
|
o.Albedo = tmpvar_8;
|
|
vec3 tmpvar_9;
|
|
tmpvar_9 = vec3(0.0, 0.0, 0.0);
|
|
o.Emission = tmpvar_9;
|
|
float tmpvar_10;
|
|
tmpvar_10 = 0.0;
|
|
o.Specular = tmpvar_10;
|
|
float tmpvar_11;
|
|
tmpvar_11 = 0.0;
|
|
o.Alpha = tmpvar_11;
|
|
float tmpvar_12;
|
|
tmpvar_12 = 0.0;
|
|
o.Gloss = tmpvar_12;
|
|
surf (surfIN, o);
|
|
vec4 tmpvar_13;
|
|
tmpvar_13 = texture2DProj (_LightBuffer, IN.hip_screen);
|
|
vec4 tmpvar_14;
|
|
tmpvar_14 = tmpvar_13;
|
|
light = tmpvar_14;
|
|
vec4 tmpvar_15;
|
|
tmpvar_15 = log2 (light);
|
|
vec4 tmpvar_16;
|
|
tmpvar_16 = -(tmpvar_15);
|
|
light = tmpvar_16;
|
|
vec3 tmpvar_17;
|
|
tmpvar_17 = (light.xyz + unity_Ambient.xyz);
|
|
light.xyz = tmpvar_17.xyz.xyz;
|
|
vec4 tmpvar_18;
|
|
tmpvar_18 = LightingBlinnPhong_PrePass (o, light);
|
|
vec4 tmpvar_19;
|
|
tmpvar_19 = tmpvar_18;
|
|
col = tmpvar_19;
|
|
vec3 tmpvar_20;
|
|
tmpvar_20 = (col.xyz + o.Emission);
|
|
col.xyz = tmpvar_20.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;
|
|
vec4 tmpvar_5;
|
|
tmpvar_5 = gl_TexCoord[1].xyzw;
|
|
vec4 tmpvar_6;
|
|
tmpvar_6 = tmpvar_5;
|
|
xlt_IN.hip_screen = tmpvar_6;
|
|
vec4 tmpvar_7;
|
|
tmpvar_7 = gl_TexCoord[2].xyzw;
|
|
vec4 tmpvar_8;
|
|
tmpvar_8 = tmpvar_7;
|
|
xlt_IN.TtoW0 = tmpvar_8;
|
|
vec4 tmpvar_9;
|
|
tmpvar_9 = gl_TexCoord[3].xyzw;
|
|
vec4 tmpvar_10;
|
|
tmpvar_10 = tmpvar_9;
|
|
xlt_IN.TtoW1 = tmpvar_10;
|
|
vec4 tmpvar_11;
|
|
tmpvar_11 = gl_TexCoord[4].xyzw;
|
|
vec4 tmpvar_12;
|
|
tmpvar_12 = tmpvar_11;
|
|
xlt_IN.TtoW2 = tmpvar_12;
|
|
vec4 tmpvar_13;
|
|
tmpvar_13 = frag_surf (xlt_IN);
|
|
vec4 tmpvar_14;
|
|
tmpvar_14 = tmpvar_13;
|
|
xl_retval = tmpvar_14;
|
|
vec4 tmpvar_15;
|
|
tmpvar_15 = xl_retval.xyzw;
|
|
vec4 tmpvar_16;
|
|
tmpvar_16 = tmpvar_15;
|
|
gl_FragData[0] = tmpvar_16;
|
|
}
|
|
|