Hello,
Can you help me to understand what this shader does? Apparently, it should have something to do with the effect indicated by the arrow below but I’m unable to restore its functionality.
Thanks,
Alberto
Fragment:
uniform sampler2D texture;
varying vec4 position;
varying vec3 normal;
void main(void)
{
vec4 color = texture2DProj(texture, gl_TexCoord[0]);
vec3 fnormal = normalize(normal);
vec3 light = normalize((gl_LightSource[0].position * position.w - gl_LightSource[0].position.w * position).xyz);
vec3 view = -normalize(position.xyz);
vec3 halfway = normalize(light + view);
float diffuse = max(dot(fnormal, light), 0.0);
float specular = pow(max(dot(fnormal, halfway), 0.0), gl_FrontMaterial.shininess);
gl_FragColor = gl_LightSource[0].ambient * color + gl_LightSource[0].diffuse * diffuse * color + gl_FrontLightProduct[0].specular * specular;
}
Vertex:
varying vec4 position;
varying vec3 normal;
void main(void)
{
position = gl_ModelViewMatrix * gl_Vertex;
normal = normalize(gl_NormalMatrix * gl_Normal);
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_Position = ftransform();
}