YAAS - Yet Another Atmospheric Scattering thing

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. :slight_smile:

Here are some pics:


11 Likes

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.

Links here:
https://simsilica-tools.googlecode.com/svn/trunk/IsoSurfaceDemo/release/ScatteringDemo-Windows.zip
https://simsilica-tools.googlecode.com/svn/trunk/IsoSurfaceDemo/release/ScatteringDemo-Linux.zip
https://simsilica-tools.googlecode.com/svn/trunk/IsoSurfaceDemo/release/ScatteringDemo-MacOSX.zip

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. :slight_smile: If not then we can still turn this car right around and go home…

1 Like

Works perfectly on windows.
With scattering : 2078
Without :2118

EDIT : the resolution is 1280 x 720 btw

@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”

I can confirm there is no difference when I look at the sky with no ground in the view

Full screen on my cheap video card (ati-radeon hd 5670):
Flat shaded checked: 440
Not flat shaded checked: 420

My video card kind of only displays a dot when flat shaded is checked (in case not normal).

Around 450 when looking vertically up… about same nbrs active or desactive.

Numbers vary by around 40, constantly changing, so my numbers are a lil meh precise.

Anyway, it’s beautiful.

@loopies said: Full screen on my cheap video card (ati-radeon hd 5670): Flat shaded: 440 Not flat shaded: 420

My video card kind of only displays a dot when flat shaded is checked, which explains my bizarre results.

Around 460 when looking vertically up… about same nbrs active or desactive.

Achievement unlocked: “First ATI test!”

Thanks! :slight_smile: Makes me feel better to know it runs on at least one ATI card.

So far, we are finding that you can get pretty skies for free… which is nice.

@loopies said: nvm rewriting the post

D’oh!

Hehe, sorry, I read wrongly about what the checking did so rewrote after reading skills improved :D.

@loopies said: Hehe, sorry, I read wrongly about what the checking did so rewrote after reading skills improved :D.

Heheh. Thanks for checking. I’ll let you keep your achievement since you’re still the first ATI user to report. :slight_smile:

“Flat shaded” should show solid blue sky with a small white dot where the sun would be… and flat brown ground.

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.

OSX 1.9.3, 2.8GHz, Intel Iris 1536MB

Fullscreen, native resolution 2560x1440: ~175 fps
Fullscreen, native resolution 2560x1440, flat shaded: ~178 fps

Very performant and good looking, well done!

EDIT:
Actually FPS rises to around 200 if I leave it on for a few minutes =)

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.

@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.

Oh, and thanks for testing it guys.

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…

@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…

Yay. Achievement unlocked: “First intel tester.”

Thanks for confirming it works.

Tested on Debian 64 bits:
Flat Shaded checked: ~850 FPS
Flat Shaded unchecked: ~1000 FPS

Graphical Card: NVIDIA GTX570M
Resolution: 1280 x 720

@pspeed said: Yay. Achievement unlocked: "First intel tester."

Thanks for confirming it works.


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..

Then with Windows 8.1
Intel
Flat Shaded uncheked : 160(horizon) , 180 (sky)
Flat Shaded checked : 169(horizon) , 174(sky)
NVidia gt540M
Flat Shaded uncheked : 395(horizon) , 400 (sky)
Flat Shaded checked : 399(horizon) , 415(sky)

res: 1366x768

Consider that the values are approximated . Anyway I played with the setting and I can obtain preatty awesome atmospheres , great great job!