mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 09:08:22 -05:00
116 lines
2.4 KiB
Text
116 lines
2.4 KiB
Text
struct v2f {
|
|
vec4 pos;
|
|
float fog;
|
|
vec2 bumpuv[2];
|
|
vec3 viewDir;
|
|
};
|
|
varying vec4 xlv_FOG;
|
|
uniform vec4 _horizonColor;
|
|
uniform sampler2D _ColorControl;
|
|
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;
|
|
}
|
|
|
|
vec4 frag (
|
|
in v2f i
|
|
)
|
|
{
|
|
vec4 col;
|
|
vec4 water;
|
|
float fresnel;
|
|
vec3 bump;
|
|
vec3 bump2;
|
|
vec3 bump1;
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = texture2D (_BumpMap, i.bumpuv[0]);
|
|
vec4 tmpvar_2;
|
|
tmpvar_2 = UnpackNormal (tmpvar_1);
|
|
vec3 tmpvar_3;
|
|
tmpvar_3 = tmpvar_2.xyz;
|
|
bump1 = tmpvar_3;
|
|
vec4 tmpvar_4;
|
|
tmpvar_4 = texture2D (_BumpMap, i.bumpuv[1]);
|
|
vec4 tmpvar_5;
|
|
tmpvar_5 = UnpackNormal (tmpvar_4);
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = tmpvar_5.xyz;
|
|
bump2 = tmpvar_6;
|
|
vec3 tmpvar_7;
|
|
tmpvar_7 = ((bump1 + bump2) * 0.5);
|
|
bump = tmpvar_7;
|
|
float tmpvar_8;
|
|
tmpvar_8 = dot (i.viewDir, bump);
|
|
float tmpvar_9;
|
|
tmpvar_9 = tmpvar_8;
|
|
fresnel = tmpvar_9;
|
|
vec2 tmpvar_10;
|
|
tmpvar_10.x = fresnel;
|
|
tmpvar_10.y = fresnel;
|
|
vec4 tmpvar_11;
|
|
tmpvar_11 = texture2D (_ColorControl, tmpvar_10);
|
|
vec4 tmpvar_12;
|
|
tmpvar_12 = tmpvar_11;
|
|
water = tmpvar_12;
|
|
vec3 tmpvar_13;
|
|
tmpvar_13 = vec3(water.w);
|
|
vec3 tmpvar_14;
|
|
tmpvar_14 = mix (water.xyz, _horizonColor.xyz, tmpvar_13);
|
|
vec3 tmpvar_15;
|
|
tmpvar_15 = tmpvar_14;
|
|
col.xyz = tmpvar_15.xyz.xyz;
|
|
float tmpvar_16;
|
|
tmpvar_16 = _horizonColor.w;
|
|
col.w = vec4(tmpvar_16).w;
|
|
return col;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f xlt_i;
|
|
vec4 xl_retval;
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_i.pos = tmpvar_1;
|
|
float tmpvar_2;
|
|
tmpvar_2 = xlv_FOG.x;
|
|
xlt_i.fog = tmpvar_2;
|
|
vec2 tmpvar_3;
|
|
tmpvar_3 = gl_TexCoord[0].xy;
|
|
vec2 tmpvar_4;
|
|
tmpvar_4 = tmpvar_3;
|
|
xlt_i.bumpuv[0] = tmpvar_4;
|
|
vec2 tmpvar_5;
|
|
tmpvar_5 = gl_TexCoord[1].xy;
|
|
vec2 tmpvar_6;
|
|
tmpvar_6 = tmpvar_5;
|
|
xlt_i.bumpuv[1] = tmpvar_6;
|
|
vec3 tmpvar_7;
|
|
tmpvar_7 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_8;
|
|
tmpvar_8 = tmpvar_7;
|
|
xlt_i.viewDir = tmpvar_8;
|
|
vec4 tmpvar_9;
|
|
tmpvar_9 = frag (xlt_i);
|
|
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;
|
|
}
|
|
|