Jump to content
  • Advertisement
Sign in to follow this  

oNeil: Atmospheric scattering not working properly

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


Im actually trying to get atmospheric scattering working in my program. I use the glsl shaders, which are released by oNeil. But something is not right and i get bad results. I have attached them to this posting.

I have read alot about people having trouble with these shaders, especially with finding the right parameter settings. so i think this might be my problem, too. So here are my parameters. They are so far exactly the same as in oNeils test program.

m_nSamples = 10; // Number of sample rays to use in integral equation
m_Kr = 0.0025f; // Rayleigh scattering constant
m_Kr4PI = m_Kr*4.0f*3.1415;
m_Km = 0.0015f; // Mie scattering constant
m_Km4PI = m_Km*4.0f*3.1415;
m_ESun = 15.0f; // Sun brightness constant
m_g = -0.95f; // The Mie phase asymmetry factor

m_fInnerRadius = 10.0f;
m_fOuterRadius = 10.25f;
m_fScale = 1 / (m_fOuterRadius - m_fInnerRadius);

m_fWavelength[0] = 0.650f; // 650 nm for red
m_fWavelength[1] = 0.570f; // 570 nm for green
m_fWavelength[2] = 0.475f; // 475 nm for blue
m_fWavelength4[0] = powf(m_fWavelength[0], 4.0f);
m_fWavelength4[1] = powf(m_fWavelength[1], 4.0f);
m_fWavelength4[2] = powf(m_fWavelength[2], 4.0f);

m_fRayleighScaleDepth = 0.25f;
m_fMieScaleDepth = 0.1f;

I have added some extra code to pass in the correct camera position:

float x = -GlobalInformation::xdist;
float y = -GlobalInformation::ydist;
float z = -GlobalInformation::zdist;

float mag = sqrt(x*x+y*y+z*z); //magnitude
float mag2 = mag*mag; //squared magnitude

There is another thing odd: When i change the parameters, it seems to has no effect on the rendering.

Do you have any suggestions what might be wrong?


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!