View Full Version : half vector problem with directional light

06-16-2005, 09:40 PM

I am trying to integrate bump mapping and have problems with the specular highlights/half vector. I guess it is not really complicated but I just don't get it.

The objects in the scene are positioned with glRotate and glTranslate (an object is a display lists, centered around 0/0/0), and the light source is a directional light, not a point light (but I could use a far-away point light as well, if that helps).

I got the light vector in world space, and dp3'd with the tbn matrix, the diffuse lighting works. So I guess, I need the half vector in world space as well, and then multiply this with the tbn matrix and so on.

My problem is that I do not have the vertex coordinates in world space.. and after the modelview transformation, they are not in world space as well, I guess, due to the fact that the gluLookAt-call also affects the MVP.

So what to do? I somehow need the viewer/vertex and verte/light vectors in the same coordinate space to compute the half vector, but I have no idea of how to achieve this.

Thansk and regards,

06-17-2005, 12:31 AM
transform the lightpos/lightdir with modelviewinv
and then compute directions with your vertex.pos
that should make them in the same coord sys

06-17-2005, 05:34 AM
To get vertices in world space, you probably want to compute the inverse view matrix. When you transform vertices by the modelview matrix, they end up in view space. Then just transform them by the inverse view matrix and they will end up in world space.