Jump to content
  • Advertisement
Sign in to follow this  
Funkymunky

Spherical Harmonics Cubemap

This topic is 1045 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am working on generating a spherical harmonics irradiance environment map for diffuse lighting.  I've read various papers on the topic ([1], [2], [3], [4]), and I've set to work implementing the process as a set of compute shaders.  I'm struggling with getting the right result.

 

I've iterated over an input cubemap and generated 9 coefficients each for R, G, and B.  I have a function to evaluate the coefficients for a direction.  When generating the output cubemap, do I just store this evaluation at each texel, or do I store the evaluation multiplied by the corresponding texel read from the input cubemap?

Share this post


Link to post
Share on other sites
Advertisement

Then how do I apply the coefficients?  I thought section 3.2 of this paper was telling me how to get the irradiance using the coefficients in a matrix and the normal of the object being lit.  It made sense to me then to generate an irradiance environment cubemap that cached all the normal directions I might sample for.

Share this post


Link to post
Share on other sites

MJP, you are the man.  I had to change CosineA2 to be Pi * 0.25f, which corresponds with the 1, 2/3, 1/4 bands.  But it works!  I am digesting the paper you linked me to, and I still have to adjust for the high dynamic range of the cubemaps I'm testing with, as a lot of the stuff ends up over-exposed.  But it's definitely looking much better:

 

adoowGt.jpg

 

Thanks for your help!

Edited by Funkymunky

Share this post


Link to post
Share on other sites

I had to change CosineA2 to be Pi * 0.25f, which corresponds with the 1, 2/3, 1/4 bands


Whoops, sorry about that! I corrected the code, in case anybody else looks at this thread later on.

Either way, I'm glad that you got it to work!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!