And then I normalize the halfAngle inside the pixel shader.  I get very nice specular highlight. 

Now.  I think I should normalize the light vector and then multiply (light + eyeVec) by 0.5 to get the 'correct' halfAngle vector inside the vertex shader. 
Unfortuantly, when I try this, the specular highlight doesn't show up very well at all.  If the angle between the halfangle and normal is very small it'll show up, otherwise it disappears. 
So the question is why is this happening.  My first theory is that I'm losing precion if the length of these vectors is too small when outputed the from the vertex shader, but I'm not sure if that makes sense. 
Anyone have any ideas.  Do you normalize all your vectors before outputing them from the vertex shader? 

skynet

06-30-2005, 12:58 PM

Both, eyeVec qand light need to be normalized (or better to say: equal in length) in order to produce a correct halfvec.  Muliplying with 0.5 gains nothing useful, youŽd just make the vector shorter.  Renormalizing it in the fragment shader will set its length back to 1 anyway. 

MalcolmB

06-30-2005, 01:14 PM

Ya, the 0.5 is just a hack to get a 'close to normalized' vector since the two vectors I'm adding together are both normalized in this case.  With or without the 0.5 though I still get bad results when this vector is normalized. 

Humus

07-01-2005, 12:10 PM

Judging your code above I don't see either light.xyz or eyeVec being normalized.  You need to do:

halfAngle = normalize(light.xyz) + normalize(eyeVec);

MalcolmB

07-04-2005, 01:14 PM

Well I am normalizing the eye vector with the line:

vec3 eyeVec = normalize(-eyePos.xyz);

But remember that my problem is that the lights look bad when things are normalized (just like the code you gave Hummus). 
Here is my entire shader:

Here are some videos of the results I get. 
This is a single quad, 8x8 units wide centerd at (0,0,0).  The camera is at (0,0,10).  The light is at (x,0,1) and travels from about -5 to 5 in the x direction. 

This video is when both light and eyeVec are normalized in the vertex shader.  These are the bad results I'm getting when I'm doing the right thing.  Notice how you can see the tesselated triagles as the light moves across.  This is why the post is titled 'interpation precision'
normalized (http://www.derivativeinc.com/temp/normalized.mov)