# Half-Vectors

I’m useing per-pixel lighting in my engine.
For the specular component I’m calculating the half-vector for each vertex and putting it to a xyz texture coordinate.
Then this is linearly interpolated across the polygon and used to access a normalization cubemap so that the interpolated vector has always unit length.
This works fine, but the problem is the linear interpolation, because it depends on the length of the calculated half-vector how vectors are interpolated.
My half-vector is the sum of the normalized light-vector and the normalized view-vector(eye-vector) but this isn’t correct.
So my question is how to calculate the half-vectors correctly???

calc it per pixel. its the only correct way i know…

if you normalize per vertex, it will be wrong at interpolation (direction gets completely wrong => doproducts **** up => specular is at wrong place. that its not that bright anymroe because of shortened vector is your smalles problem )

so the only way is interpolate both, normalize them perpixel, and sum them up, normalize them again (with the pixelshader normalization approximation) and done… dot that…

But I don’t want to use pixel shaders.
Is there no other way?
Is there no normalization approximation that uses register combiners but no pixel shaders?What if we use the w component?
Or what if we don’t do the last normalization you suggest?
Then it will be brighter if the view- and the light-vector are more parallel, but is this a problem?
Is there anyone who has tried such things?

yes. its the same approximation
pixelshaders are textureshaders+registercombiners in opengl. and the textureshaders are yet there to sample the normalized texel from the normalizingcubemaps (without you even know it ), => the rest is in the registercombiners.

something like that you need to get into 1.5 general combiners:

v = v - (1-v.v)/2*v
or so, not that sure anymore… browse, its in here… I know what pixel shaders are. But I don’t want to use texture shaders (NV_texture_shader extension) so that it runs on < GF3. But I can use register combiner math.

you can’t do that in texshaders anyways…

just 2 normalizationcubemaps and a bit of math in the combiners…

hm… only 2 textures for <gf3… hm… to_eye could be constant (that was done for specular even in the vertexshader… local_viewer on and off)