Recommended Posts

Hello!
I wasn't sure if I should revive this old thread, so I started this thread instead.
I'm having trouble implementing the atmospheric scattering, the result is either a pitch black dome, or full white, or at best, a faint white at the suns position. I have tried several ways and techniques, but with the same result.
Mostly I've been looking at Real Time Rendering of Atmospheric Scattering Effects for Flight Simulators and the ATI paper.
But since nothing seems to help, I'm thinking maybe my constants are all wrong, or the scale is messed up.. Or am I missing something else? Here is the code for my cgFX.

The LightDir is a normalized vector (normalize(0,2,5)), and the sun color is all white. The eye is placed at (0,10,0) and the skydome is of radius 100.
Also, I've been trying to calculate the rayleigh scattering coefficient according to the formulae in the above article:
BR = (8 * PI^3 * [n^2-1]^2) / (3 * N * l^4)
l = (650nm, 610nm, 475nm)
n = refractive index of air (= 1.0008?)
N = molecular density (~2?)
Now, using this yields very high values of BR because of the l^4 factor.
Is this supposed to be measured in meters or in some other factor? Dividing by 0.000000650^4 seems bad to me.
I would really appreciate any help :)
[Edited by - Thex0 on April 5, 2006 7:27:18 PM]

0

Share this post

Link to post

Share on other sites

I can't give you details to your code, but you should implement something that allows you to change the values for BR and BM interactively (by keyboard etc.). Then, simply tune them until things look right.

g=0.3 seems a little too low. g=0.9 should be better. The effect of g is the following: If g is close to 1, you see a narrow white halo around the sun. If g is close to zero, the whole sky has a white halo.

Now, using this yields very high values of BR because of the l^4 factor.Is this supposed to be measured in meters or in some other factor? Dividing by 0.000000650^4 seems bad to me.

Usually, all quantities should be in meters, but you are right: 0.00000065^(-4) is quite small. But anyway, atmospheric scattering is a lot of parameter twiddling. You cannot expect the quantities that come out of the physical formulas to map 1-to-1 to RGB colors. This is because RGB colors are simple linear values, whereas actual perception of light densities is a very complicated process involving many non-linear things and other stuff. So simply tune parameters until it looks right.

Lutz

0

Share this post

Link to post

Share on other sites

Thank you for your input! I actually got some colors by experimenting with the constants. So now it's a nice blue sky. However, it is blue no matter where the sun is. Do I need to change my coefficients manually depending on the sun angle? As far as I could tell the coefficients would cancel out based on the distance, but I can't get that in effect.

Also I'm wondering where the zenith angle comes in place? As far as I can tell it is not part of the equation from the ATI-paper.