Mie Scattering at Horizon

Started by
12 comments, last by jcabeleira 14 years, 1 month ago
I have a flat terrain heightmap, and I color the skyline using atmospheric scattering methods. With just Rayleigh scattering, my horizon is whitish, which is correct. When I add in Mie scattering, the horizon darkens. I stepped through my code to see why this is happening, and it is because the Mie atmosphere density is "thicker at ground (more thicker than Rayleigh)" and so more light is removed due to the extinction part of the calculations. Mie and Rayleigh particles are combined in the extinction process and so it also affects the rayleigh scattering. I have downloaded an implementation similar to mine and it has the same affect, although they sort of hide it with some geometry at the bottom of the screen to hide the horizon. Anyway, is this a normal side effect of only taking into consideration single scattering instead of multiscattering? I can work around it with some fudge factor scalars to still get pretty results, but I want to make sure I don't have an error.
-----Quat
Advertisement
Hello once again, Quat.

The problem you describe is a tipical one when you're developing an atmospheric scattering algorithm and it isn't caused by the fact that you're using single scattering.
Probably your sky is getting darker at the horizon because you have excessive concentration values of molecules or aerosols. You'll have to find a better balance between these two values by trial and error, since this hasn't anything to do with physical accuracy, until you achieve good visual results. Don't worry if you take lots of time until you get a good balance, this is more of an art than a science.

Good luck, and don't forget to post your results when you get them right! ;)
Thanks, that is one thing that has really been throwing me off. Some of the papers start off very physics like, but all the implementations I have seen use fudge factors.
-----Quat
Lol, yeah, I've been through that also.
Most papers use lots of mathematical and physics garbage, like complex integrals, to make formal descriptions about atmospheric scattering but in practice atmospheric scattering is quite easy to understand after you get it right.
So, the formality of the nasty integrals ends up being unnecessary since they are hard to understand and they aren't all that physically accurate anyway (they just describe an approximation, not the real behaviour of light).

So, one of the main difficulties that people face when implementing atmospheric scattering is that they don't know which unit system or representation they should use to accurately represent things like light radiation, aerosols/molecules densities and other stuff. But there's no use in using accurate unit systems or measures since the algorithm itself is not completely accurate anyway.

But there's one thing that you have to be careful with: although physical accuracy isn't all that important, you do have to represent your colors with High Dynamic Range and apply a tone mapping operator (like the one I told you about in a previous thread) on them to get reallistic results.
Quote:
you do have to represent your colors with High Dynamic Range and apply a tone mapping operator (like the one I told you about in a previous thread) on them to get reallistic results.


Yes, I have been using the one in Sean O'Neil's GPU Gems 2 chapter. One thing I am still having trouble with...I am able to get an orangish sunset near the horizon, but I would like to "lift it up a bit". In other words, I would like to get the orangeish sunset without having to be as near to the horizon as I currently do (not just the sun itself but the sky color in general around the horizon). I was able to get it a little bit by modifying H0 in the exp(-h/H0) expression used for the atmosphere density for Rayleigh.
-----Quat
Well I'm not sure if that's wrong, the horizon tends to get orange only when the sun is already very near it. But could you post a screenshot showing how near your sun has to be for the horizon to get orange?


and here is without the terrain (not sure if it is supposed to be black below the horizon--I'm currently looking into this):



and I want it to be more like this:


-----Quat
Your screenshots are looking very good and the horizon is getting reddish at the right sun position, so don't worry about it. The only problem I see is that your Mie scattering is way too intense but if you scale it down with a constant it will look fine.

About the photo you showed, that's an hard sunset to get through the usual atmospheric scattering algorithm since is not a common one, it is very intense and dramatic with a very reddish look not only above the horizon but on the whole sky.
On the other hand, your implementation is generating the orange tone at the right time of day and giving a natural and more common sunset which I personally think it is much more desirable.

Anyway, if you really want to achieve the kind of sunset like the one on the photo you just have to play with your parameters of the Mie and Rayleigh scatterers concentrations. I'm not sure if this will be suficient to achieve the effect but you shouldn't modify your code to get it since your code is already providing very reallistic sunsets.
Thanks for your reply. Unfortunately, the boss wants a sunset like in the pic :)

I played with the atmospheric density function (as a function of height) and was able to get the sky to turn orangish earlier (with the sun higher), however that change also affects the sky when it is at other positions, which I didn't like. I may end up adding a weight variable to help control this that is a function of the sun angle with respect to the "up" axis.




Also, does your sky go black below the horizon?


Although not necessary at the moment, I have also seen images of some purple sunsets and some other possible rare situations. The whole physics seems very complicated to come with a general model for all this haha.



[Edited by - Quat on March 17, 2010 11:46:42 AM]
-----Quat
Yes, changing the parameters to get the desired sunset will affect the sky for the rest of the day cycle. As you said, perhaps its better if you use a function or something to control the density of the scatterers along the day, which I supose it is not a bad solution anyway since it's probably what happens in reality.

No, my sky doesn't look black below the horizon, it looks red... very red. And that makes sense since the light is traversing huge amounts of air. Perhaps you have a look at your code to see whats wrong. Are you performing any kind of light-ray to earth collision detection?

About the purple sunset, I've never heard of such thing. I belive that photo is manipulated to achieve that color. Many of these photographs of sunsets use HDR tricks to generate "fantasy" looks and so they shouldn't be used as reference.

This topic is closed to new replies.

Advertisement