Hi,

can anyone tell me if the glLightsource[i].halfvetor is only available in GLSL or also in the OpenGL state?

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.

Thanks for your help. Altought I can’t find anything about the halfVector on this pages, even in the whole document.

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.

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

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.

ok, thanks for the confirmation! I was just confused by some of the uses I had seen.

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