I was recently side tracked while converting my marching cubes stuff over to its new open sourced home. I got to the point where I needed a sky dome and stuff and I thought I’d play with atmospheric scattering a bit.
Like many others, this implementation is based on the GPU Gems 2 article. I think there are some things about it that are still not quite right but the optimized equations he uses are a bit hard for me to unravel. But I get some useful looking results.
Note: in these pictures there is no filter, no post processing, no sun geometry, etc. Just a sky dome, some ground objects, and two shaders. The ground isn’t even lit… it’s just getting its coloring directly from the atmospheric functions.
The sun also just falls out of the math.
I have the Rayleigh scattering constant turned up kind of high because I think it makes for more interesting horizons. Also, while we’re on the subject the “boxes” represent ground that are really large and really far away. For perspective, I think the math works like this:
…if the planet’s radius is: 6378100 meters then those are like 63 km away or something. I may redo the math after I’ve had more sleep.
So, I’ve temporarily turned my IsoSurfaceDemo into a scattering demo in the hopes that many of you kind folks might try it locally to see if the shaders blow up.
Also, if you think about it and are really generous (and it runs at all), I’d be interested in knowing the difference between your FPS with the “Flat Shaded” toggle on and off. When that toggle is on, it turns scattering off completely. Bonus points if you do one just looking at the sky, too.
On my machine, the sky scattering costs nothing. I get the same FPS whether it’s a flat blue sky or a scattered sky. There is about 100 FPS overhead (out of 1500 FPS) for the visible ground.
Thanks a heap of bunches for the help.
Edit: if you kids are good, I’ll even explain what the parameters mean. If not then we can still turn this car right around and go home…
@nehon said:
Works perfectly on windows.
With scattering : 2078
Without :2118
http://imgur.com/a/hJNhz
Thanks! You are the man.
So, your with/without is even less different than mine when the ground is in the picture. I can probably guess that if you look straight up at the sky there will be no difference at all.
Thanks again for testing. Achievement unlocked: “First responder”
OSX 10.9.3 AMD Radeon HD 6770M
Fullscreen (external screen) 1920x1200 - around 330 (±20) FPS. The scattering overhead is close to nothing. Maybe 5-10% but FPS jumps up & down a little depending on where I’m looking so it’s probably just jitter caused by other things. Great work.
@jayfella said:
I get strange results, I was expecting higher numbers from my rig. It might be the beta drivers I'm running.
win8.1, 4.5GHz i7, ati 7950
1920x1080 - 920 fps on, 950 off.
The ground is apparently more expensive than the sky… well certainly the difference is. You can try looking directly at the sky just to see the difference in the sky.
The ground scene is not a very efficient scene anyway and I suspect if the atmospherics were added to normal a Lighting-style shader that the difference would disappear.
Intel HD 4000 - 340 fps, seems to be the same with or without
NVIDIA GTX 660M - capped to 120 fps, this is due to the dual-card setup with the nvidia having to go through the intel…
@Momoko_Fan said:
Tested on Linux x64, full screen 1080p
Intel HD 4000 - 340 fps, seems to be the same with or without
NVIDIA GTX 660M - capped to 120 fps, this is due to the dual-card setup with the nvidia having to go through the intel…
You mean first “Linux Intel tester”. The Linux and Windows versions of Intel drivers are written by a completely different band of bandits… They are probably situated on opposite sides of the planet too…
@Momoko_Fan said:
You mean first "Linux Intel tester". The Linux and Windows versions of Intel drivers are written by a completely different band of bandits.. They are probably situated on opposite sides of the planet too..