View Full Version : Half-Vectors

07-26-2002, 02:10 AM
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???

07-26-2002, 03:09 AM
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 http://www.opengl.org/discussion_boards/ubb/wink.gif)

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..

07-26-2002, 07:25 AM
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?

07-26-2002, 08:18 AM
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 http://www.opengl.org/discussion_boards/ubb/wink.gif), => 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.. http://www.opengl.org/discussion_boards/ubb/smile.gif

07-26-2002, 11:05 AM
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.

07-26-2002, 03:05 PM
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)