Weird Specular

Hi, im implementing a per-pixel lighting solution in my litle engine.
im using half-vector to aproximate specular reflections, but it looks strange, my specular highlights have a spherical aspect (instead of something elipsoidal i think).

is this correct ?


pictures of what you have and what you want?

Hi dave

hum, my spec highlights look something like, imagine a flat plane, now imagine a specular highlight that’s totaly spherical (literally).
i’ve opened 3dmax3 meanwhile and been playing around with lights and the specular should be elipsoidal (or something like that, my english sucks ass a bit).

any thoughts, suggestions are welcome


well, show what you do mathematical/codewise… something went wrong, we have to find what, and without code thats really uhm… difficult?

hello again

im computing light and half vector in a vertex shader, then light and half vector’s are normalized with a normalization cube map.

the math is something like:
light vector= light pos- vertex pos

half vector= eye pos-vertex pos
half vector+= ligth vector

then stuff is transformed into tangent space and saved in respective output registers.

then in pixel shader, i compute:

normalized light vector (dot3) normal map
normalized half vector (dot3) normal map
aproximate spec to ^16

and sum results (no decal & ambient)

any thoughts ?

tks again btw

hm sounds okay… if you tesselate the geometry to near_to_perpixel triangles, does it get bether? normally, you would need to calculate the halfangle perpixel, means normalizing point_to_light and point_to_eye perpixel, and then summing them up (and normalize again god bless approx_normalize for pixelshaders… )
if you sum them up before, and do the normalization, the direction of the halfangle gets wrong => wrong shading occurs…