Hey guys,
I've been following oskar's youtube tutorials on lwjgl and they have been working great, and now I'm trying to learn shaders because I want to get into shadow mapping soon. They have been working fine, but now my shader.vert file will not compile for me....
varying vec3 color;
void main() {
vec3 vertexPosition = (gl_ModelViewMatrix * gl_Vertex).xyz;
vec3 lightDirection = normalize(gl_LightSource[0].position.xyz - vertexPosition);
vec3 surfaceNormal = (gl_NormalMatrix * gl_Normal).xyz;
float diffuseLightIntensity = max(0.0f, dot(surfaceNormal, lightDirection);
color.rgb = diffuseLightIntensity * gl_Color.rgb;
color += gl_LightModel.ambient.rgb;
vec3 reflectionDirection = normalize(reflect(-lightDirection, surfaceNormal));
float specular = max(0, dot(surfaceNormal, reflectionDirection));
if(diffuseLightIntensity != 0)
{
float fspecular = pow(specular, gl_FrontMaterial.shininess);
color.rgb += vec3(fspecular, fspecular, fspecular);
}
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
When I delete everything after the surfaceNormal everything works fine for me, so the problem has to be the diffuseLightIntensity, but I cannot figure out how to solve it...
Thanks for the help,
pfolder