Game Development Community

Rayleigh scattering

by Sean Buffington · in Torque Game Engine Advanced · 06/03/2005 (1:05 am) · 9 replies

I would like to recreate the Rayleigh scattering effect in TSE. For those not familiar with this effect, it is what makes the sky blue and mountains purple, etc. Essentially I would like mountains at a far distance from the camera to look hazy and shifted in color.

Would the existing fog system work for this, and if so any ideas on approximate settings which might reproduce this effect? My attempts with the fog system have failed since it tends to just obscure things entirely with an ugly solid color at a certain distance. Would this be a job for a shader?

Any ideas?

Thanks,
Sean

About the author

Recent Threads


#1
06/03/2005 (4:23 am)
Http://www.gamedev.net/reference/articles/article2093.asp
#2
06/03/2005 (7:19 am)
Hrmmmm....seems like Ben had something like this implemented during IGDC last year for the new terrain engine demos. or maybe it was the beer.

Anybody (sober) remember?
#3
06/03/2005 (10:58 am)
No, Rayleigh scattering can't be approximated with fog... or at least very well. I tried to implement this once before in my own engine and found it quite difficult to get something that worked well. It's a very touchy algo in my experience.

For Torque i believe the skybox would have to be replaced with a sky dome as the algo is highly dependent on the distance to the geometry. Maybe that could be faked thru a good shader, but it would have to operate per-pixel then and i don't believe that would work for even mid range shader card. If i remember correctly it can work on a 1.1 shader which is nice.

I would love to see it in there. Someone got time to try this?
#4
06/03/2005 (4:33 pm)
Yeah, I'm afraid this is probably going to be well above my level of coding skills. Just imagine what TSE would look like with Rayleigh and Mie scattering, volumetric clouds and dynamic lighting. One stop shop for realistic atmospheric reproduction. And your sunrises/sunsets would always be unique and quite spectacular as well.
#5
06/06/2005 (1:15 pm)
Ben had it working a while ago. It is pretty touchy and doesn't give a lot of control to artists who would want specific colors in place. The biggest problem though is that you have to run the scattering shader on top of *everything* water, terrain, buildings, players, trees, etc. Not too speedy on ps 1.1 or 2.0 cards.
#6
06/06/2005 (1:37 pm)
Post your shader Ben! =)
#7
06/10/2005 (3:46 am)
:P

I have to rewrite them; I lost that work to a HD crash a while back. Got a rough approximation working again in a few hours on the drive to GDC. If I have time I want to make it work even better, but it's not trivial to wire into Torque in way that would be usable to people other than me... :-/
#8
06/10/2005 (10:25 am)
It seems that it would have to be added to each render call as another RenderImage. Sort of like the glow pass.
#9
06/10/2005 (2:19 pm)
This whole render-pass thing has actually been much on my mind and we are planning on finding a better, more general solution to the problem, because right now, with render passes, that's very "current-generation" with regard to the way we are doing it. Things will be done differently next gen, and it'd be good to have a solution that will work for legacy as well as next-gen hardware.