Sign in to follow this  

Calculate light color from light direction and Nishita's sky model

This topic is 823 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

Hello everyone!

 

I recently implemented an atmosphere renderer using Nishita's method as depicted in this blog. Everything looks gorgeous but there is one thing, which puzzles me.

The colors of the environment are all calculated just fine but I always assume, that the sun's color is pure white. This works fine as long as it is day but during sunsets or sunrises my color assumption leads to bright white objects while the sky is red.

So I need to adjust the sun color in respect to the position of the sun.

Can I somehow use Nishita's atmospheric scattering algorithm to calculate the light color? Or are there other, fast methods to calculate a realistic light color?

 

Thanks in advance!

Share this post


Link to post
Share on other sites

Proper solution would raymarch from each shaded position to edge of atmosphere and calculate how much is left from pure white light. To approximate this you can just raymarch from sea level(or camera level) to edge of atmosphere and use that value for everywhere. But do not feed this value to sky model but just for direct lighting.

Share this post


Link to post
Share on other sites

As far as i remeber, CryTek(wich used Nishita's model aswell) just averaged pixels at horizon level and used that as the sun color. So i assume that works quite well(did for them)

Else you would have to get the average color of the complete sky hemisphere

Share this post


Link to post
Share on other sites


Else you would have to get the average color of the complete sky hemisphere

That's not particularly hard to do either: you render the sky to a cube-map, and then use that to lookup the light colour based on the light direction.

 

This is roughly the same process used for light probes in modern engines.

Share this post


Link to post
Share on other sites

Else you would have to get the average color of the complete sky hemisphere

But that would give average skylight color which would be quite blue. Sun color is what is left from white light after transmittance and absorption.

Share this post


Link to post
Share on other sites

As far as i remeber, CryTek(wich used Nishita's model aswell) just averaged pixels at horizon level and used that as the sun color. So i assume that works quite well(did for them)

Else you would have to get the average color of the complete sky hemisphere

We actually only used the average for fog/scattering, not for the sun color. :)

Share this post


Link to post
Share on other sites

Buuut it should work for sun color aswell :D

What i've done in the past was(used gpu Gems2 approach) use mie coefficents(the 1/wavelength^4 was rayleigh i think) and some sort of mie phase function and averaged some rays around the sunlight direction.

Worked okayish and the blue tone was only noticeable on the clouds.

Other than that, depending on how realistic it should be, you could compute it for a ray towards the sun and desaturate it based dot(sundir,up) with some smoothstep function.

Share this post


Link to post
Share on other sites

This topic is 823 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.

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