Sign in to follow this  
Lambo

Ashikhmin-Shirley lightning model

Recommended Posts

Hi, I'm trying to implement an anisotropic Phong BRDF lightning model [url="http://www.cs.utah.edu/~michael/brdfs/jgtbrdf.pdf"]http://www.cs.utah.e...dfs/jgtbrdf.pdf[/url]. Where specular component is defined as: [img]http://i44.tinypic.com/34yzqpz.png[/img]. I.m having problems with dot(n, h) exponent, because its numeric value is to big. Right now I think there is a problem with equation or my interpretation: according to the document Nu and Nv are freely chosen constants and can be equal, so if we chose Nu=Nv, exponent is equal to Nv whose value can range 1000, with is obviously to big and returns NaN in pow() function. Maybe someone can pinpoint my mistake?

Share this post


Link to post
Share on other sites
1000 is usually not too big for an exponent, so your mistake must be somewhere else located.
Best is you post your source code to make it easier to hunt down the prob.

Share this post


Link to post
Share on other sites
[quote]I.m having problems with dot(n, h) exponent, because its numeric value is to big[/quote]
This worries me. If your n and h are normalized, then dot(n, h) is in the range [-1,+1] so what you describe shouldn't happen.
Are you sure your vectors are normalized?

Share this post


Link to post
Share on other sites
Why not isolate the different parts of the equation?

Also, the pow function does not work with values below or equal 0 because the implementation is done with the equation exp(log(value) * value). Try to put something like this: max(dot(…), 0.0001f);

Good luck!!!

Share this post


Link to post
Share on other sites
Thanks guys! It simply was not normalized view vector, so my half vector was wrong... Paniced because if exponent would be 10000, base should not be smaller than 0.9913 or else outcome could not be expressed in sp float.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this