Half-vector, in the Blinn-Phong illumination model, is a vector half way between eye and light vectors.
What I dont understand is, eye vector (a vector point from point to camera) being different at each vertex (even for a directional light!), halfvector should be different TOO.
Why is halfVector an vec4 attribute for light then?
What is the value stored?
I can’t find any explanation on the web!
Thanks in advance.
Probably an approximation for performance, like the old school glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, true or false) in classic opengl.
Obviously this approximation gets wronger for larger FOV, and at the sides. Center of view is still mostly correct.
I dont know for sure, but my guess is that halfvector is interpolated per vertex so it should be accessed by a fragment shader. makes more sense for it to be considered an attribute of the current light, rather than a vertex attribute which could be associated with different lights.
I don’t think so, because if you use ShaderGen to generate the fixed functionality emulating shader, it uses the half-vector in the vertex shader.
By the way, I discovered that in the fixed functionality the eye is defined (and NOT calculated!!) in this way:
eye = vec3 (0.0, 0.0, 1.0);
It is a vector: not a point!
Then I think that in the “eye space”, the eye can be considered something like is a plane, like in an orthographic projection.
So, both the directional light direction and eye are two constant vectors constant for each vertex in the scene.