varying vec3 n, l, h; #vertex void main() { n = normalize(gl_NormalMatrix * gl_Normal); l = normalize(vec3(gl_LightSource[0].position) - vec3(gl_ModelViewMatrix * gl_Vertex)); h = normalize(gl_LightSource[0].halfVector.xyz); gl_TexCoord[0] = vec4(gl_Vertex.x + gl_Vertex.z, gl_Vertex.y - gl_Vertex.z, 0.0, 0.0); gl_Position = ftransform(); } #fragment uniform sampler2D tex; uniform float a; void main() { float d, s; vec3 nn; // distortion texture lookup nn = vec3(texture2D(tex, vec2(gl_TexCoord[0]))); nn -= vec3(0.5, 0.5, 0.5); // lighting nn = normalize(n + 0.25 * nn); d = dot(nn, normalize(l)); if (d > 0.0) { s = pow(max(dot(nn, normalize(h)), 0.0), 100.0); } else { s = 0.0; d = 0.0; } // color assembly nn = vec3(1.0, 1.0, 1.0) * d; + vec3(3.0, 3.0, 3.0) * s; gl_FragColor = vec4(nn, a); }