I'm following this tutorial to calculate the specular color of a vertex.
I use OpenGL 2.1 with GLSL version 120.
This is the formula that I apply:
spec= (R*eye)^s * Ls * Lm
L= direction vector light-vertex;
N= vector normal;
eye= direction vector vertex-eye;
R= -2N * (L*N) + L;
Now the problem is that following this way I need to multiply a vec3 for a vec4.
This is what I tried to do:
vec4 L= normalize(gl_LightSource.position - gl_Position); vec3 N= normalize (gl_NormalMatrix * gl_Normal); vec4 eye= normalize(-gl_Position); vec4 R= -2.0*N*(L*N)+L; // Syntax error: N is a vec3 vec4 spec= (R*eye)* gl_LightSource.specular;
I wouldn't get a vec3 result when calculating the specular value, this value I would be ignoring the alpha value. How do I go around this?