PDA

View Full Version : Halfvector

dust
05-02-2005, 10:58 PM
Hi,
can anyone tell me if the glLightsource[i].halfvetor is only available in GLSL or also in the OpenGL state?

Relic
05-03-2005, 12:41 AM
It's available as precalculated state inside GLSL only.
Check OpenGL 2.0 specs chapter 2.14 page 62 formula (2.3).
It's the directional light non-local viewer case, which limits its use.

dust
05-03-2005, 02:29 AM

Relic
05-03-2005, 02:53 AM
Look sharper. ;)
"hi" is the thing and it's depending on the local viewer state (vbs in the spec). It's only possible to precalculate that for directional lights and non-local viewer, all other cases need the vertex eye coordinates as base for the direction vectors.
"n (.) hi" is in the specular term with the dot product defined as d1 (.) d2 = max{d1 · d2, 0} on the previous page.

groovemaster
08-10-2006, 07:54 AM
Hey all,

I just started GLSL, currently playing with the lighthouse tutorials, and I'm somewhat puzzled by this halfvector. As I understand it, in the case of a point light with position P, for a vertex V,its the normalized sum of the vectors VP and -V (the viewer is in (0,0,0) (eye coordinates, right?!)).

Thus it represents the vector halfway between vectors from V to the viewer and V to the camera/eye. I can follow the reasoning that it can't be precalculated cause you need the vertex coordinates the calculation. But wat is precalculated as being the halfvector then, and why do the lighthouse tutorials use it in their point-light-per-pixel calculations?

The code for that particular tutorial doesnt work though, the specular highlight follows the light. It only works when I compute my own halfvector. But clearly I must have missed something, cause I've only played with shaders for 2 days now, and I can't imagine myself correcting those tutorials :)

Relic
08-10-2006, 09:46 AM
As I said "It's the directional light non-local viewer case, which limits its use."
It can't be precalculated for point lights or local viewer state.
I don't know about other people's tutorials.

groovemaster
08-10-2006, 10:55 AM
ok, thanks for the confirmation! I was just confused by some of the uses I had seen.