tags:

views:

88

answers:

1

I'm playing with per pixel lighting shaders and i don't know one thing: What is half vector of light source ?

vec3 halfVector = normalize(gl_LightSource[1].halfVector.xyz);

I would like i you can explain it in math rows, i understand math better than words :)

+3  A: 

From this post:

A "halfway vector" (if you mean that by "half vector") is the unit vector at the half angle between two other vectors. Normally the halfway vector [...] is computed between the vector to the viewer v and the light source l:

h := ( v + l ) / || v + l ||

The half vector therefore is the unit angle bisector of view- and light vector.

Edit: For a complete explanation of the lighting model including the half vector, just see the Blinn-Phong wikipedia article

Dario