I can’t seem to get compute the right half vector, where L = light vector, V = view vector and H =L + V. Am I doing this correctly?
Vertex shader:
varying vec3 v;
...
v = vec3(gl_ModelViewMatrix * gl_Vertex);
Fragment shader
varying vec3 v;
...
vec3 L = normalize(gl_LightSource[0].position.xyz - v);
vec3 V = normalize(-v);
vec3 H = normalize(L + V);
I found an Orange book example that is similar but requires eyePosition:
// extract positions from input uniforms
vec3 lightPosition = gl_LightSource[0].position.xyz;
vec3 eyePosition = -osg_ViewMatrix[3].xyz / osg_ViewMatrix[3].w;
// H = halfway vector between light and viewer from vertex
vec3 P = vec3(gl_ModelViewMatrix * gl_Vertex);
vec3 L = normalize(lightPosition - P);
vec3 V = normalize(eyePosition - P);
vec3 H = L + V;
thanks