Jump to content
  • Advertisement
Sign in to follow this  

Atmospheric Scattering Woes

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

Hi, I'm trying to implement atmospheric scattering as explained in Nielsen's paper. But so far, I'm getting some weird results: Ignore the grey bottom part par to the screen. The blue and the white part is where the sky should be. Does anyone have any idea what could be the cause of this? It's white on the horizon as it should be but instead of going from light blue to blue at the top, it seems to go from dark blue to almost black. One thing I'm not sure about is the values of some of the variables. The values I'm using seem to create very small values: sun direction: v<0,1,0> sun intensity: (1,1,1,3.7) DensityAlt: (6.5,0.716479,10440.9,5780.22) BetaRayleigh: v<2.78856e-06,3.59512e-06,9.77819e-06> BetaDashRayleigh: v<1.6643e-07,2.14568e-08,5.83593e-07> BetaMie: v<5.7406e-07,6.46105e-07,1.05143e-06> BetaDashMie: v<1.33379e-07,1.51445e-07,2.49762e-07> g: (0.999772,1.00023,0.0301826) eye position: p<0,6500,4> If anyone has some experience implementing Nelsen's method, could they post some sample values for the variables? I have a feeling I might not be picking correct values. If you guys want, i can post the part of the code that deals with the scattering but I'm pretty much using the shader code in the appendix D and E of Nielsen's paper (although it's ported to GLSL).

Share this post

Link to post
Share on other sites
So I decided to try doing preetham's method instead of Nelsen's which simplified the extinction calculation (instead of doing exp(-betaRayleigh * Sr + -betaMie * Sm) where Sr and Sm was found using some formula's in Nelsen's paper, Preetham's method uses the distance from eye to vertex). I also tinkered with some of the variables and got some decent result. :) I'm not sure what was wrong with my previous shader code >.<.

But I'm still not satisfied with this. My major concern is how large the sun is. I tried looking at screen shots of other people's implementation of Preetham's atmospheric scattering and I noticed that their sun was also very large. I tried tinkering with the variables and I can't seem to get it to a realistic size. Did anyone else ever implement Preetham's technique and manage to a realisticly sized sun?

Also, during a sunset, the sky doesn't seem to change colour properly. Here's a screenshot:

I was under the impression that Preetham's formulas for Lin, rayleigh scattering, and mie scattering was supposed to automatically handle the colour of the sky for sunsets. If so, does anyone have any suggestions or experiences on what can cause this sort of result?

Here's the values for some of the variables:
lightDir: v<6.12303e-17,-0.627966,-0.77824>
betaR + betaM: v<3.81322e-05,6.3167e-05,0.000128207>
g = 0.89999998f
betaDashR: v<2.07478e-06,3.50853e-06,7.2753e-06>
betaDashM: v<8.00273e-07,1.04067e-06,1.49857e-06>
oneOverBetaR+betaM: v<26224.6,15831,7799.87>
Sun Color Intensity: (0.9578,0.919572,0.822243,80)

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!