View Full Version : Specular Mapping in the Lighting Equation

cippyboy

03-19-2008, 06:14 AM

I was wondering what is the correct lighting equation for use with specular mapping ? I'm using something like this but the specularity doesn't seem to be too correct :

FinalColor=

AmbientLight * DiffuseTexture

+DiffuseLight * DiffuseTexture

+SpecularLight* SpecularTexture.r;

Also, where's the best place to compute the half angle ? vertex or pixel shader ?

V-man

03-19-2008, 06:37 AM

What does the specular map store?

If it is for approximating pow(), then your equation looks correct.

I have always computed half angle vector in the VS.

cippyboy

03-19-2008, 02:01 PM

Good question, I thought it was either the specular color or the shining exponent used in pow, but I'm not really sure what it is.

As a note, I already compute

SpecularLight=pow( max( 0.0, n_dot_h),shinyness);

Do you use that same equation in your specular mapping shader and everything looks ok ?

V-man

03-19-2008, 05:30 PM

Yes, except I don`t want pow to be called if value is 0.0 because it was causing to return some positive value on certain driver.

float n_dot_h= dot(halflight, normal);

if(dotproduct > 0.0)

SpecularLight=pow(n_dot_h, shinyness);

Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.