tmason

09-08-2014, 06:31 AM

Hello,

I have been trying to get my head around light half-vectors for a minute now but I still don't understand it. Here is what I found on a StackExchange article:

Link: http://stackoverflow.com/questions/3744038/what-is-half-vector-in-modern-glsl

http://www.lighthouse3d.com/opengl/glsl/index.php?ogldir2 reports that half vector in OpenGL context is 'Eye position - Light position' but then it goes on to say 'luckily OpenGL calculates it for us' [which is now deprecated].

How can, practically be calculated (a simple example would be greatly appreciated) [mainly, it puzzles me what "Eye" is and how it can be derived].

At the moment I managed to make specular calculations work (with good visual result) with half vector being equal to Light where Light is

vec3 Light = normalize(light_position - vec3(out_Vertex));

Now, I've no idea why that worked.

[If at least I knew what "Eye" is and how it can be derived practically.]

My two questions are:

In the above code, is the "out_Vertex" the vPosition that is coming in for the geometry?

I don't have a light position in my GLSL shader but it seems based on the above example I need one. Am I correct? Or do I need to send a light position to the GLSL fragment shader as well?

Thank you for any input you can provide on this.

I have been trying to get my head around light half-vectors for a minute now but I still don't understand it. Here is what I found on a StackExchange article:

Link: http://stackoverflow.com/questions/3744038/what-is-half-vector-in-modern-glsl

http://www.lighthouse3d.com/opengl/glsl/index.php?ogldir2 reports that half vector in OpenGL context is 'Eye position - Light position' but then it goes on to say 'luckily OpenGL calculates it for us' [which is now deprecated].

How can, practically be calculated (a simple example would be greatly appreciated) [mainly, it puzzles me what "Eye" is and how it can be derived].

At the moment I managed to make specular calculations work (with good visual result) with half vector being equal to Light where Light is

vec3 Light = normalize(light_position - vec3(out_Vertex));

Now, I've no idea why that worked.

[If at least I knew what "Eye" is and how it can be derived practically.]

My two questions are:

In the above code, is the "out_Vertex" the vPosition that is coming in for the geometry?

I don't have a light position in my GLSL shader but it seems based on the above example I need one. Am I correct? Or do I need to send a light position to the GLSL fragment shader as well?

Thank you for any input you can provide on this.