PDA

View Full Version : Per fragment specular



dbugger
07-15-2003, 11:15 PM
Hi! After finishing the vertex program point light I decided to move on to per fragment lighting. All went well until I implemented the specular component. Now it looks like in the pictures below. Sharp borders appear where there's supposed to be a soft transition. If I set specular to 0 everything looks as it's supposed to look.
http://www.itstudents.ch/users/dave/files/pfspec0.jpg http://www.itstudents.ch/users/dave/files/pfspec1.jpg

Thanks again dave for providing web-space http://www.opengl.org/discussion_boards/ubb/smile.gif

Madoc
07-16-2003, 12:01 AM
Looks like you're getting negative values from your specular.
Try using DP3_SAT so as to clamp your result. Doesn't really look specularly lit though, just a low exponent?

Ysaneya
07-16-2003, 12:18 AM
I'd agree it looks like a clamping issue.

Y.

dbugger
07-16-2003, 12:25 AM
Thanks for your replies! Yes you're right, it's a clamping-isssue and I think I found the problem. I used the wrong specular exponent for some reason. It now looks quite ok! Thanks again.

vincoof
07-16-2003, 02:56 AM
It looks right to me.

That's how specular component is defined in OpenGL : clamped if the diffuse contribution is null (i.e. if the dot product between normal and light direction is negative).

To smoothen the clamping, you might modulate the specular contribution with this dot product. Something like :
final_specular_contribution = specular_contribution * (N_dot_L ^ 8)

vincoof
07-16-2003, 03:01 AM
dbugger: changing the specular exponent might reduce that clamping effect, but it does not disappear. If you move the light and the camera, you will sometimes notice that the specular highlight is still clamped.

dbugger
07-16-2003, 03:20 AM
Yes I know! But in the pics the exponent is *VERY* wrong. Using the correct exp (fetched from model file) the clamping can't be spotted at all.
Thanks / David