View Full Version : Weird Specular

08-25-2002, 03:30 AM
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 ?


08-25-2002, 04:04 AM
pictures of what you have and what you want?

08-25-2002, 04:10 AM
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 http://www.opengl.org/discussion_boards/ubb/wink.gif


08-25-2002, 04:14 AM
well, show what you do mathematical/codewise.. something went wrong, we have to find what, and without code thats really uhm.. difficult? http://www.opengl.org/discussion_boards/ubb/biggrin.gif

08-25-2002, 04:24 AM
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 http://www.opengl.org/discussion_boards/ubb/wink.gif

08-25-2002, 04:32 AM
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 http://www.opengl.org/discussion_boards/ubb/biggrin.gif god bless approx_normalize for pixelshaders.. http://www.opengl.org/discussion_boards/ubb/biggrin.gif)
if you sum them up before, and do the normalization, the direction of the halfangle gets wrong => wrong shading occurs..