Board index FlightGear Development Effects and shaders

Atmospheric scattering, with terrain shader preview

An exciting "new" option in FlightGear, that includes reflections, lightmaps, the particle system etc.. A lot is yet to be discovered/implemented!

Atmospheric scattering, with terrain shader preview

Postby Zan » Sun Mar 06, 2011 11:21 pm

UPDATE 06.10.2011: Thorsten kindly wrote a document about light propagation in optically tick medium, see it here: http://www.phy.duke.edu/~trenk/files/light_optically_thick.pdf

UPDATE 03.05.2011: Terrain shader preview: http://www.flightgear.org/forums/viewtopic.php?f=47&t=11274&start=30#p123287

UPDATE 14.03.2011: Links to patches and shaders: http://www.flightgear.org/forums/viewtopic.php?f=47&t=11274&p=117965#p117965

Hi all.

I've been doing an atmospheric scattering shader for few weeks now, mostly after Gpu Gems article, http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter16.html. I've modeled all those equations with python and found similar functions as O'Neil to make the shader runtime.

Some screenshots:
Skydome shader starting to work:
Image

Skydome and ground shaders working, altitude is about 30km.
Image

Same as above, but this time at around 250km.
Image

I did this in a shader developing program, so it's not yet suitable for FG. It also is currently too slow as all calculations are done in fragment shader, but I might get it to work with FG in few weeks :)

Zan
Last edited by Zan on Thu Oct 06, 2011 5:23 pm, edited 3 times in total.
Zan
 
Posts: 123
Joined: Tue Oct 20, 2009 11:28 am

Re: Atmospheric scattering

Postby ASTON » Mon Mar 07, 2011 10:59 pm

Fantastic! :shock:
Keep going! 8)
ASTON
 
Posts: 12
Joined: Mon Sep 20, 2010 5:05 pm
Location: LFSR - FR
Callsign: GB-586
OS: MAC OS X

Re: Atmospheric scattering

Postby Gijs » Tue Mar 08, 2011 1:40 pm

One of my FlightGear dreams slowly becomes reality!
Looking forward to the day it does, Zan!
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9548
Joined: Tue Jul 03, 2007 3:55 pm
Location: Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: Atmospheric scattering

Postby ot-666 » Tue Mar 08, 2011 8:37 pm

Really nice :D A long missed feature.
Thanks for all the work.
Callsign: ot-666
Working on LOWI and other stuff - Custom Scenery Overlay Repo: http://gitorious.org/fgfs-custom-scenery/custom-scenery-overlay/
VMX22 - Osprey... sometimes in 2014
ot-666
 
Posts: 746
Joined: Sun Nov 08, 2009 6:14 pm
Location: Germany, Konstanz
Callsign: ot-666
IRC name: ot666
Version: GIT
OS: win7 64bit

Re: Atmospheric scattering

Postby fredb » Thu Mar 10, 2011 8:46 pm

Hi Zan,

If you look at my videos (link in sig), you'll find that my terrain engine experiment used two forms of atmospheric scattering. The oldest used O'Neil's and the more recent use Bruneton's algorithm. I found O'Neil's frustrating because his equations seemed to come from nowhere and the air "thickness" was not easily adjustable. Bruneton's is a bit better but requires more processing power and has a round earth model, which is wrong as every one know. O'Neil's should also use a spherical model.
User avatar
fredb
 
Posts: 753
Joined: Fri Dec 01, 2006 11:41 am
Location: Paris, France

Re: Atmospheric scattering

Postby ASTON » Thu Mar 10, 2011 11:16 pm

Heya Fredb, your atmospheric scattering's incredibly stunning!
Does the code is avalaible for mac user or is it only your own beta ? Will it be included in the 2.2 release?
thanks
ASTON
 
Posts: 12
Joined: Mon Sep 20, 2010 5:05 pm
Location: LFSR - FR
Callsign: GB-586
OS: MAC OS X

Re: Atmospheric scattering

Postby kyokoyama » Fri Mar 11, 2011 5:14 am

Finally, a way to fly realistically in space (maybe)!
...how'd you do this?
Look for "B-BIRD" "N127KY" or "AVA0004" -that's me.

Despite having over 1700 posts here, I am not even close to being the most skilled guy here... I'm just words and bad drawing, not experience. :P
kyokoyama
 
Posts: 1981
Joined: Sun May 03, 2009 3:16 am
Location: Earth
Callsign: B-BIRD, N127KY
Version: 2.12.1
OS: Windows Vista

Re: Atmospheric scattering

Postby Zan » Sun Mar 13, 2011 6:25 pm

Today I managed to hack the code so that skydome accepts an effect too, and ported my shader.

Here are some sneak peeks:
Image
Image
Image

As can be seen, one problem is that terrain is not rendered properly from high altitudes (too few tiles). Other than that, only needs some parameter tweaking to make it look better :)

Oh, and this breaks the non-shader implementation. I must fix that too.

Fredb: I have to Bruneton's paper an I think I'm going to implement that after I get the O'Neil's algorithm to work. I must do some hacks to get everything to work properly as FG uses so many different coordinate systems :) I indeed think that Bruneton's algorithm is more sophisticated
Zan
 
Posts: 123
Joined: Tue Oct 20, 2009 11:28 am

Re: Atmospheric scattering

Postby kyokoyama » Sun Mar 13, 2011 6:38 pm

That's amazing!
Now there just has to be a way to have something to take the place of the unmodeled tiles, and FG will have a complete Earth!
Look for "B-BIRD" "N127KY" or "AVA0004" -that's me.

Despite having over 1700 posts here, I am not even close to being the most skilled guy here... I'm just words and bad drawing, not experience. :P
kyokoyama
 
Posts: 1981
Joined: Sun May 03, 2009 3:16 am
Location: Earth
Callsign: B-BIRD, N127KY
Version: 2.12.1
OS: Windows Vista

Re: Atmospheric scattering

Postby ot-666 » Sun Mar 13, 2011 10:03 pm

wow :shock:
the first one is stunning...
Callsign: ot-666
Working on LOWI and other stuff - Custom Scenery Overlay Repo: http://gitorious.org/fgfs-custom-scenery/custom-scenery-overlay/
VMX22 - Osprey... sometimes in 2014
ot-666
 
Posts: 746
Joined: Sun Nov 08, 2009 6:14 pm
Location: Germany, Konstanz
Callsign: ot-666
IRC name: ot666
Version: GIT
OS: win7 64bit

Re: Atmospheric scattering

Postby redneck » Mon Mar 14, 2011 2:00 am

Agreed. If curt would make a changelog for each developer snapshot, I'd be sure to grab the next one that has this feature.
Call Signs: redneck, ATCredn (unspecified freq atc)
FGFSCopilot
FGFSCopilotATCEdition
System Specs
Model: Alienware M15x, OS: Windows 7 Professional 64-bit, RAM: 3 GB, CPU: Intel i3 quad core at 2.4 GHz, GPU: Nvidea GeForce GTX 460M 1.5 GB GDDR5
redneck
 
Posts: 3617
Joined: Mon Feb 02, 2009 3:17 am
Location: Pennsylvania, USA
Version: 240

Re: Atmospheric scattering

Postby planetacancun » Mon Mar 14, 2011 4:05 am

Wow! great job! Eyes watching you man! :D

Zan! take a look at my Motion blur post later when you finish this ok??? Pretty please??? :D
Callsign:Fallen-
Videos: http://youtube.com/planetacancun2
planetacancun
 
Posts: 322
Joined: Thu Jul 30, 2009 5:52 pm
Callsign: Fallen-
IRC name: Fallen-
Version: GIT
OS: Ubuntu

Re: Atmospheric scattering

Postby Zan » Mon Mar 14, 2011 4:31 pm

TYothers wrote:From what I can tell, it would involve making the "Geode" in "SGSkyDome::build" into an "EffectGeode" instead and calling "makeEffect" on some sort of read properties.


Sure, I changed dome.cxx so that Geode is EffectGeode like you already knew, and then
Code: Select all
Effect *effect = makeEffect("Effects/skydome", true);
if(effect)
    geode->setEffect(effect);


It's basically that simple :) No need to hassle with properties or anything, just give the effect name. Then you need to create the file "Effects/skydome.eff" in FG data directory and create shaders and whatever you need.

Tweaked the parameters a bit:
Image
Image

I'm trying to get the non shader version to work now, maybe then this could be pushed to git.
- Zan
Zan
 
Posts: 123
Joined: Tue Oct 20, 2009 11:28 am

Re: Atmospheric scattering

Postby HHS » Mon Mar 14, 2011 4:57 pm

Looks great!

I wonder if it looks still great with some fog and we will still have the stars. They would like look much better with the new sky!
Would it be possible to have also a sun/ lens flare effect??
Up, up and away
User avatar
HHS
 
Posts: 3625
Joined: Thu Jul 19, 2007 9:09 am
Version: GIT

Re: Atmospheric scattering

Postby fredb » Mon Mar 14, 2011 5:17 pm

With atmospheric Scattering, you have to modify all material shaders to compute fog, or air thickness, accurately.
At least you need the horizon match the skydome. Changing the skydome only is pointless IMO.
User avatar
fredb
 
Posts: 753
Joined: Fri Dec 01, 2006 11:41 am
Location: Paris, France

Next

Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 3 guests