Half-vector for directional lights...?

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.

:eek: :eek: :eek:

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.

Am I wrong?

That is the case when GL_LIGHT_MODEL_LOCAL_VIEWER is set to false.

You’re right! Finally I found it :slight_smile:

It is also stated in 10.3.2 of Real Time Rendering 2nd Edition.

Thank you!

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.