Specular per-pixel lighting problem

Originally posted by Jan2000:
[b]mikeman: Maybe you should post your code. There is nothing left, i could think of.

However, it is absolutely logical, that you have to normalize the view and light-vector. Take a piece of paper and draw it. It will become very clear, why the one will result in defined (and consistant) behaviour and the other one not.
Because if the view or light-vector have diferent lengths (which happens when the viewer moves, or the light), the half-vector will change, although it shouldn´t, because only the DIRECTION matters, not the length. After a normalization it is always correct.

Jan.[/b]
I just realized that the specular highlights of 2) will increase in size when moving away from the light source and decreasing when moving towards it which is not what we want, right? (noone seen this other post? hehe)

Originally posted by mikeman:
[b] [quote]Originally posted by Jens Scheddin:
// Calculate light vector (L)
“SUB lightVec, lightPos, iPos;”
// Calculate half-angle vector (H)
“SUB halfVec, viewPos, iPos;”
“ADD halfVec, lightVec, halfVec;”

When you’re calculating halfangle,you MUST normalize L and V in order to get correct results.
What you(and I) are doing works in some cases,where L and V have similar lengths.If,for example,L is long and V is much sorter,you end up with H=L.This,of course,is wrong.The thing is,normalizing L and V is more wrong(!!),since,as it turns out,doing non-linear math in VP is a deadly sin(if you want your lighting to be tesselation-indepedent).[/b][/QUOTE]Right. Finally, i agree now :slight_smile:

PK: Now i remember. Anisotropic lighting is all about simulation of surface roughness.