Skip to main content
GameDev.net gamedev.net
🔒 Locked

Atmospheric Scattering

Started by Dev_NightDreamer Nov 24, 2015 at 11:54 AM 10 replies 11.9k views
Original Post
Dev_NightDreamer
Dev_NightDreamer

Hello everyone,

there's something special I want to implement, but that I can't understand: atmospheric scattering.

My goal is, to achieve a sky background, where I can adjust the color gradients/etc. parameters.

Therefore I googled and found a lot of interesting stuff: Sean O'Neills GPU Gems 2 - accurate atmospheric scattering.

1. Question) Why is everything I found regarding the implementation stuff from before 2012?

Now I had a problem: the shader described is only the SkyFromSpace shader.

This was fixed, after I found the link to the download section.

Then there came up another problem: almost everyone got the tip: visit his website and download the improved version.

2. Question) How should I visit Sean O'Neills old website, if the website is now a website for casinos?

TLDR:

Have anyone an idea how to get the source for Sean O'Neills implementation 'SkyFromAtmosphere' in OpenGL?

Or better: an actual tutorial for atmospheric scattering?

Or is there something better these days? (<- that's why everything is from before 2012?)

Thanks in advance,

NightDreamer

swiftcoder
swiftcoder

Therefore I googled and found a lot of interesting stuff: Sean O'Neills GPU Gems 2 - accurate atmospheric scattering.
1. Question) Why is everything I found regarding the implementation stuff from before 2012?

Sean's been out of the planet rendering game for a while before that (largely due to time pressure). I used to correspond with him back in 2009'ish, haven't done so in recent years.

Then there came up another problem: almost everyone got the tip: visit his website and download the improved version.
2. Question) How should I visit Sean O'Neills old website, if the website is now a website for casinos?

His website went offline a few years ago. Luckily, a ton of people incorporated his shaders into their projects, any many of those are hosted on GitHub. Try this one for size.

Or is there something better these days? (<- that's why everything is from before 2012?)

Yes, actually, there are a couple of other options, depending on what you are looking for.

The absolute state-of-the-art is Eric Bruneton's work on atmospheric rendering. He has implemented a much more complete scattering model, which looks absolutely gorgeous, though the implementation is a tad more complex.

If you want a cheaper approximation of scattering (maybe for a mobile game), then Alex Peterson did a very credible job of faking it via texture lookup. I've implemented these before, and they look pretty damn good for the ease of use and performance.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
Dev_NightDreamer
Dev_NightDreamer

Hello swiftcoder,

thank you for replying. That makes a lot more clear.




Yes, actually, there are a couple of other options, depending on what you are looking for.

The absolute state-of-the-art is Eric Bruneton's work on atmospheric rendering. He has implemented a much more complete scattering model, which looks absolutely gorgeous, though the implementation is a tad more complex.

If you want a cheaper approximation of scattering (maybe for a mobile game), then Alex Peterson did a very credible job of faking it via texture lookup. I've implemented these before, and they look pretty damn good for the ease of use and performance.

I think Eric Bruneton's work (which looks indeed extremely awesome) isn't a good solution for a game, isn't it?

And the second approach from Alex Peterson shows only the perspective from the sky.

In my use case it would be rendered to a screen filling quad to be the background sky in a game with day/night cycles. :)

swiftcoder
swiftcoder




I think Eric Bruneton's work (which looks indeed extremely awesome) isn't a good solution for a game, isn't it?

That depends on you target hardware. Maybe not a good solution for mobile, but it's very achievable for a PC game.

Keep in mind that he developed the technique back in 2008 - it ran on consumer hardware back then, and we've now had 7 years of GPU development on top of that.




And the second approach from Alex Peterson shows only the perspective from the sky.

Alex's shaders work fine from the ground too - take a look at the video in his earlier blog post. I use them for seamless ground->space transitions, and they work fine with some minor tweaks to their alpha transparency.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
Dev_NightDreamer
Dev_NightDreamer

That depends on you target hardware. Maybe not a good solution for mobile, but it's very achievable for a PC game.

Keep in mind that he developed the technique back in 2008 - it ran on consumer hardware back then, and we've now had 7 years of GPU development on top of that.

Okay, that's a good point. Although I'm developing on a GTX980Ti. smile.png

I'll try Eric Bruneton's approach first. If I got problems, I will ask again and/or try Alex Peterson's (btw: I'm aboslutely a fan of his program Spacescape)

Unfortunately I couldn't get his sample project/code working.

I've made a new VS2013 project, copied all his files, included GLEW and Glut but can't find the library/headers for "tiffio.h"...

EDIT:

Also (if I commented all the texture loading stuff out) the linker complains about missing functions in glut, which can't be the case, due to the fact, that I'm successfully linking to the glut.lib and including the glut.h

Dev_NightDreamer
Dev_NightDreamer

i believe Rayleigh(sp?) in-scattering is the specific effect you want.

Yep, Rayleigh scattering in interaction with Mie scattering, like Sean and Eric (and almost everyone I read about) used, if I understood that correctly. smile.png

EDIT:
I realised, that Eric used 4-5 shader programs in his demo. Are they all needed? Or is only one program for the sky?

cgrant
cgrant




I realised, that Eric used 4-5 shader programs in his demo. Are they all needed? Or is only one program for the sky?


I suggest you actually look into the fundamentals of atmosphere scattering before delving into actually implementation as you are most likely going to confuse yourself and eventually get discourage. The principles/basis behind atmospheric scattering is the same across implementation since they are based ( some more loosely than others ), on the actual physical laws governing scattering in a participating medium.



I realised, that Eric used 4-5 shader programs in his demo. Are they all needed? Or is only one program for the sky?


This goes back to what I initially said.. Yes all the programs are required as they are use in the pre-computation phase to generate the scattering tables.
Dev_NightDreamer
Dev_NightDreamer




I suggest you actually look into the fundamentals of atmosphere scattering before delving into actually implementation as you are most likely going to confuse yourself and eventually get discourage. The principles/basis behind atmospheric scattering is the same across implementation since they are based ( some more loosely than others ), on the actual physical laws governing scattering in a participating medium.

Personally I get way more confused, looking at those publications. :)

I need actual implementations to fully understand things like that.



This goes back to what I initially said.. Yes all the programs are required as they are use in the pre-computation phase to generate the scattering tables.

Okay. If I understand it correctly, Sean O'Neill wasn't using precomputed scattering tables, was he?

swiftcoder
swiftcoder

Okay. If I understand it correctly, Sean O'Neill wasn't using precomputed scattering tables, was he?

Not the published implementation, no. I believe there was an earlier version that did use a lookup table.

However, keep in mind that he avoided the lookup table by effectively ignoring the other 2 dimensions addressed by Bruneton's 4D lookup table, and heavily quantized the remaining axes, so there is a noticeable reduction in accuracy and fidelity.
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
Dev_NightDreamer
Dev_NightDreamer




However, keep in mind that he avoided the lookup table by effectively ignoring the other 2 dimensions addressed by Bruneton's 4D lookup table, and heavily quantized the remaining axes, so there is a noticeable reduction in accuracy and fidelity.

Okay, yeah, I think I will stick to Bruneton's implementation for a while. But it's quite heavy. Any tipps/tricks for this? :)

cgrant
cgrant

Correction and sorry for the confusion..For some reason I gave the response ( in regards to the multiple shader ) in reference to the Eric Bruneton PreComputed Atmospheric scattering so I apologize for making you even more confused. O'neal's implementation doesn't use any pre-computation, just a few assumption's for simplification.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.