Sign in to follow this  

oNeil: Atmospheric scattering not working properly

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

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