bgfx/examples/runtime/shaders/gles/fs_bump.bin

103 lines
4 KiB
Text
Raw Normal View History

2012-10-28 00:34:41 -04:00
#ifdef GL_ES
precision highp float;
#endif // GL_ES
uniform vec4 u_lightRgbInnerR[4];
uniform vec4 u_lightPosRadius[4];
uniform sampler2D u_texNormal;
uniform sampler2D u_texColor;
varying vec2 v_texcoord0;
varying vec3 v_tangent;
varying vec3 v_normal;
varying vec3 v_view;
varying vec3 v_wpos;
void main ()
{
mat3 tmpvar_1;
tmpvar_1[0] = v_tangent;
tmpvar_1[1] = ((v_normal.yzx * v_tangent.zxy) - (v_normal.zxy * v_tangent.yzx));
tmpvar_1[2] = v_normal;
vec3 tmpvar_2;
tmpvar_2 = normalize(((2.0 * texture2D (u_texNormal, v_texcoord0).xyz) - 1.0));
vec3 tmpvar_3;
tmpvar_3 = (u_lightPosRadius[0].xyz - v_wpos);
float edge0_4;
edge0_4 = u_lightRgbInnerR[0].w;
float t_5;
t_5 = max (min ((((sqrt(dot (tmpvar_3, tmpvar_3)) / u_lightPosRadius[0].w) - edge0_4) / (1.0 - edge0_4)), 1.0), 0.0);
vec3 tmpvar_6;
tmpvar_6 = (tmpvar_1 * normalize(tmpvar_3));
float tmpvar_7;
tmpvar_7 = dot (tmpvar_2, tmpvar_6);
vec2 tmpvar_8;
tmpvar_8.x = tmpvar_7;
tmpvar_8.y = dot ((tmpvar_6 - ((2.0 * tmpvar_7) * tmpvar_2)), v_view);
vec4 tmpvar_9;
tmpvar_9.xw = vec2(1.0, 1.0);
tmpvar_9.y = max (0.0, tmpvar_7);
tmpvar_9.z = (float((tmpvar_7 >= 0.0)) * max (0.0, tmpvar_8.y));
vec3 tmpvar_10;
tmpvar_10 = (u_lightPosRadius[1].xyz - v_wpos);
float edge0_11;
edge0_11 = u_lightRgbInnerR[1].w;
float t_12;
t_12 = max (min ((((sqrt(dot (tmpvar_10, tmpvar_10)) / u_lightPosRadius[1].w) - edge0_11) / (1.0 - edge0_11)), 1.0), 0.0);
vec3 tmpvar_13;
tmpvar_13 = (tmpvar_1 * normalize(tmpvar_10));
float tmpvar_14;
tmpvar_14 = dot (tmpvar_2, tmpvar_13);
vec2 tmpvar_15;
tmpvar_15.x = tmpvar_14;
tmpvar_15.y = dot ((tmpvar_13 - ((2.0 * tmpvar_14) * tmpvar_2)), v_view);
vec4 tmpvar_16;
tmpvar_16.xw = vec2(1.0, 1.0);
tmpvar_16.y = max (0.0, tmpvar_14);
tmpvar_16.z = (float((tmpvar_14 >= 0.0)) * max (0.0, tmpvar_15.y));
vec3 tmpvar_17;
tmpvar_17 = (u_lightPosRadius[2].xyz - v_wpos);
float edge0_18;
edge0_18 = u_lightRgbInnerR[2].w;
float t_19;
t_19 = max (min ((((sqrt(dot (tmpvar_17, tmpvar_17)) / u_lightPosRadius[2].w) - edge0_18) / (1.0 - edge0_18)), 1.0), 0.0);
vec3 tmpvar_20;
tmpvar_20 = (tmpvar_1 * normalize(tmpvar_17));
float tmpvar_21;
tmpvar_21 = dot (tmpvar_2, tmpvar_20);
vec2 tmpvar_22;
tmpvar_22.x = tmpvar_21;
tmpvar_22.y = dot ((tmpvar_20 - ((2.0 * tmpvar_21) * tmpvar_2)), v_view);
vec4 tmpvar_23;
tmpvar_23.xw = vec2(1.0, 1.0);
tmpvar_23.y = max (0.0, tmpvar_21);
tmpvar_23.z = (float((tmpvar_21 >= 0.0)) * max (0.0, tmpvar_22.y));
vec3 tmpvar_24;
tmpvar_24 = (u_lightPosRadius[3].xyz - v_wpos);
float edge0_25;
edge0_25 = u_lightRgbInnerR[3].w;
float t_26;
t_26 = max (min ((((sqrt(dot (tmpvar_24, tmpvar_24)) / u_lightPosRadius[3].w) - edge0_25) / (1.0 - edge0_25)), 1.0), 0.0);
vec3 tmpvar_27;
tmpvar_27 = (tmpvar_1 * normalize(tmpvar_24));
float tmpvar_28;
tmpvar_28 = dot (tmpvar_2, tmpvar_27);
vec2 tmpvar_29;
tmpvar_29.x = tmpvar_28;
tmpvar_29.y = dot ((tmpvar_27 - ((2.0 * tmpvar_28) * tmpvar_2)), v_view);
vec4 tmpvar_30;
tmpvar_30.xw = vec2(1.0, 1.0);
tmpvar_30.y = max (0.0, tmpvar_28);
tmpvar_30.z = (float((tmpvar_28 >= 0.0)) * max (0.0, tmpvar_29.y));
vec4 tmpvar_31;
tmpvar_31 = texture2D (u_texColor, v_texcoord0);
vec4 result_32;
result_32.xyz = pow (tmpvar_31.xyz, vec3(2.2, 2.2, 2.2));
result_32.w = tmpvar_31.w;
gl_FragColor.xyz = (max (vec3(0.05, 0.05, 0.05), (((((u_lightRgbInnerR[0].xyz * max (0.0, clamp (tmpvar_9.y, 0.0, 1.0))) * (1.0 - (t_5 * (t_5 * (3.0 - (2.0 * t_5)))))) + ((u_lightRgbInnerR[1].xyz * max (0.0, clamp (tmpvar_16.y, 0.0, 1.0))) * (1.0 - (t_12 * (t_12 * (3.0 - (2.0 * t_12))))))) + ((u_lightRgbInnerR[2].xyz * max (0.0, clamp (tmpvar_23.y, 0.0, 1.0))) * (1.0 - (t_19 * (t_19 * (3.0 - (2.0 * t_19))))))) + ((u_lightRgbInnerR[3].xyz * max (0.0, clamp (tmpvar_30.y, 0.0, 1.0))) * (1.0 - (t_26 * (t_26 * (3.0 - (2.0 * t_26)))))))) * result_32.xyz);
gl_FragColor.w = 1.0;
vec4 result_33;
result_33.xyz = pow (gl_FragColor.xyz, vec3(0.454545, 0.454545, 0.454545));
result_33.w = gl_FragColor.w;
gl_FragColor = result_33;
}