Board index FlightGear Development Effects and shaders

Sunrises (version 1.3 available)

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

Re: Sunrises (download in first post)

Postby Johan G » Tue Jan 10, 2012 10:38 pm

:shock: I'm lost for words! Very impressive! :D
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: Sunrises (download in first post)

Postby sgofferj » Wed Jan 11, 2012 12:25 am

Very cool :). Rakastan! This almost calls for a "Romantic atmosphere screenshot challenge" :).
One little issue - when I set the time to "night", I get this... I suppose, that isn't intended? Although it looks kinda cool too!
Image
FG 3.1 GIT / Opensuse 12.3 / Phenom II X4 / GForce GTX560
Stefan's little Flightgear corner | The Finnish Weather Center | Wolves in Finland

Working on: EFTP
COM: IAX2:home.gofferje.net/stefan (MO-FR 0700-2000 UTC, SA+SU 0900-2000 UTC)
sgofferj
 
Posts: 789
Joined: Mon Dec 05, 2011 5:13 pm
Location: EFTP
Callsign: OH-SW
Version: 3.1 GIT
OS: Opensuse

Re: Sunrises (download in first post)

Postby Thorsten » Wed Jan 11, 2012 9:19 am

2d clouds don't seem to inherit the current light, they're probably emissive white. I'm not sure if they're actually maintained any more, if they do have a maintainer, it'd probably be a good idea to set them to the ambient light and to give them a few more interesting textures.

Anyway, there's a reason I am working on sunset/sunrise conditions... The skydome scattering shader looks much more realistic, but it needs a lot of support structure to blend properly into everything else.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Sunrises (download in first post)

Postby erik » Wed Jan 11, 2012 10:13 am

This is starting to look unreal. Or actually really real.

There was a time FlightGear 0.9.x-ish) where everything you saw and everything you heard in FlightGear was influenced by work that I'd done (pre-shaders!) but looking at this I'm glad you took over and took it to the next level. Nice work Thorsten!

Erik
Current: Parachutist, Paraglider, Pterosaur, Pilatus PC-9M and variants, ERCO Ercoupe, Fokker Dr.1, Fokker 50, Fokker 100
Less active: Cessna T-37, T-38, Santa Claus. Previous: General Dynamics F-16. Worked on: Wright Flyer
erik
 
Posts: 2244
Joined: Thu Nov 01, 2007 2:41 pm

Re: Sunrises (download in first post)

Postby Thorsten » Thu Jan 12, 2012 1:57 pm

Thanks - also for all the support from your side.

I have to say, I enjoy this a lot. I've always admired clouds and atmosphere and light effects when I was travelling by airplane, and it is great to have the chance to not simply hope that eventually someone will make a flightsim that includes all I'd like but to simply put it in myself.

Although, it is occasionally frustrating... Now that I had the skydome blend the terminator line seamlessly with the terrain edge after a long fight, the altitude dependence screws everything up of course for any really high terrain, since the skydome assumes that terrain which isn't actually loaded is at zero elevation. Which makes up for a pronounced mismatch in the Himalaya region, where even the plains reach easily 10.000 ft.

So, the skydome needs to be told the altitude of the surrounding terrain somehow. Which we can do at least withing Local Weather because the terrain presampling is running anyway and contains that info...

Also, somehow the lighting of the aircraft itself is not in sync with the terrain - possibly (again) a case of different coordinate systems. It's something that can drive me mad at times...
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Sunrises (download in first post)

Postby psadro_gm » Thu Jan 12, 2012 3:43 pm

Would a simple LOD system be useful? I've been wanting to work on one for a while, but it's such a huge undertaking. I need to finish up my current projects in the next couple of months, but would be interested in helping out.

I am thinking of a very simple proof of concept with just 2 levels of detail, where we can load very simplified terrain (2-4 triangles per tile, and a single generated low-res texture per tile). Obviously this will pop when switched to the high level of detail, and have tremendous gaps. But the transition would happen very far from the user. The terrain could then be visible to the horizon, and from space we would simply have a huge textured sphere.

If we get something that's workable, perhaps we can then add intermediate LOD levels, stitch gaps, etc...

Your sub-orbital experiments are leading me to believe that 16 levels of detail may not be necessary.
8.50 airport parser, textured roads and streams...
psadro_gm
 
Posts: 751
Joined: Thu Aug 25, 2011 3:23 am
Location: Atlanta, GA USA
IRC name: psadro_*
Version: git
OS: Fedora 21

Re: Sunrises (download in first post)

Postby Thorsten » Thu Jan 12, 2012 4:53 pm

Would a simple LOD system be useful?


Very - it'd ease the load on the shaders a lot, and the skydome wouldn't have to fake terrain any more. And a textured sphere from space, possibly combined with 2d orbital cloud textures, would certainly look better than a fog sphere.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Sunrises (download in first post)

Postby Thorsten » Fri Jan 13, 2012 2:15 pm

... and the next try - now the mean terrain altitude info as generated by Local Weather's presampling system is passed on to the skydome shader, which adjusts the terminator position accordingly. This is a bit better, but still generates seams at the edge of visibility, so... for the purpose of lighting computations, we force the terrain elevation at the visibility edge smoothly down to the mean value as passed to the skydome shader, and so the seams disappear again.

The only remaining problem I see now is that the light everywhere changes with aircraft altitude - so I'll wait for Erik's fix to be pushed after new features are again possible. Or maybe I'll experiment with my own light model inside the shader in the mean time just to make nice screenshots :D
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Sunrises (download in first post)

Postby Johan G » Fri Jan 13, 2012 6:03 pm

Thorsten wrote in Fri Jan 13, 2012 2:15 pm:...just to make nice screenshots :D

I wouldn't mind that. :wink:
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: Sunrises (download in first post)

Postby gluon » Sat Jan 14, 2012 10:21 am

Fantastic work Thorsten!

Here are some random thoughts:
  • Cloud coloring: Actually the color of light reaching you changes quite rapidly when increasing altitude at sunset. Take of from an airport and observe the sun color and you'll see what I mean. So the color change is not linear and only using 2 points for interpolation probably will not be correct. But give it a try anyway. It just has to look good enough and having a gradient will already make a remarkable difference.
  • When I was busy with coding the "new" sun implementation several years back I was studying the effects of sunrise and sunset quite extensively. I always had the impression that sunrises have a more rosy/pink quality while sunsets are more orangey-red. May be this is because of the earth's shadow or just because the atmosphere is cleaner after the night.
  • Actually it's not enough to just take the altitude. What you need for proper coloring is the angle between the horizon and the sun at that particular altitude. That's how the current code (based on the viewer location) also works.

    True - as Erik says what is taken in account is the angle, but actually what I did was calculate the distance the light has to travel through the atmosphere - which depends on the angle.
  • The sun implementation also considers two further things:
    1) The earth is not a perfect sphere (ellipsoid, thicker at the equator), so the path distance of the light rays will differ depending on latitude.
    2) The thickness of the atmosphere varies. It is thickest around the equator and thinnest around the poles. Since the difference is up to 10 or more kilometers this will have an impact on scattering. So both of these effects should have an influence on the amount of scattering depending on the viewers latitude.
  • And of course particle density is taken in account - both depending on the altitude (based on the standard model) and as a proxy the viewing distance. I also investigated into particle data. Emissions do make a considerable difference. For example there are spectacular sunsets in big cities like Bejing or Mexico City. I found some interesting datasets that could have been used for an implementation. But I thought this was too much work and not enough benefit.
  • Eventually we should consider unifying the color calculation of the sun and the shader. Then we could for example turn off the outer halo. This would also take care of the airplane coloring problem you mentioned (which one of the halos colors). I also always wanted to add a gradient to the sun itself (and the halos) by just adding an upper and lower color with linear interpolation. This is actually very easy to implement. But I currently don't have anything set up for developing anymore.
All in all the screenshots look very realistic already. Wow :)
gluon
 
Posts: 68
Joined: Tue Aug 18, 2009 8:43 am

Re: Sunrises (download in first post)

Postby Thorsten » Sat Jan 14, 2012 2:01 pm

Cloud coloring: Actually the color of light reaching you changes quite rapidly when increasing altitude at sunset. Take of from an airport and observe the sun color and you'll see what I mean. So the color change is not linear and only using 2 points for interpolation probably will not be correct.


Yes, I've worked that out on the way home yesterday. What should enter the color model is the length of the light through the atmosphere. We can't do that, we can do it for the local position of the airplane, but not for every pixel in the scenery.

So it has to be an effective shadow 'wedge', the projection of which on the ground is the terminator, and where you are in this 3d shadow wedge determines (aproximately) light intensity *and* color. Inside this wedge, the effective forward shift in shadowing conditions goes like sqrt(2 * R * altitude) with altitude where R is the Earth radius - if you plot that, you note that indeed that is a rapidly growing function initially.

1) The earth is not a perfect sphere (ellipsoid, thicker at the equator), so the path distance of the light rays will differ depending on latitude.

2) The thickness of the atmosphere varies. It is thickest around the equator and thinnest around the poles. Since the difference is up to 10 or more kilometers this will have an impact on scattering. So both of these effects should have an influence on the amount of scattering depending on the viewers latitude.


I suspect the variation of lighting with aerosols and water vapour is *much* more significant than that, so unless we start getting control over those, there's no need to delve into this.

The problem is, quite simply stated, that you need to compute a different color for every point in the scene - not just for the sun, or for the airplane position - for a suborbital view for an area of ~200.000 km^2 actual scenery and 3.200.000 km^2 skydome posing as scenery and all in all ~2.000.000 pixels with 20+ fps. So whatever scheme you have better be *really, really* fast, and that means approximations to geometry and plausible-looking schemes instead of actual calculations.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Sunrises (download in first post)

Postby Thorsten » Sun Jan 15, 2012 7:55 pm

Okay, I have a working implementation of a lightfield which is based on the (rgb) values of the default Flightgear lighting on the ground and extrapolates that forward/backward from the sun and in altitude based on effective angle with the sun, taking the surface normal with the sun into account to generate some shade where it should be,

In other words, each position you see gets approximately the light assigned which would be computed if you would be in that position. This makes no difference during the day, but is quite dramatic at sunrise/set since the light 100 km or 1 km higher towards the sun is completely different from the light at the current position.

It actually looks sort of okay from low altitude - the colors are maybe a bit larger than life...

Light illuminating as a function of altitude:

Just dawn:

Image

A bit later:

Image

Yet a bit later:

Image

The terminator is now nicely shaped by mountain ridges with seamless blending that the visibility range. The colors just look very wrong from high altitude.

Image

I've been thinking for a few hours what is wrong here, since these *are* pretty much the colors Flightgear would put on the ground, and they don't look bad on the ground or from low altitude, till I figures out that you would see the whole scene from high altitude through a (much thinner) layer of brightly illuminated haze, effectively leading to an altitude-dependent de-saturation of the colors - which is presumably just what is missing. I'll try that next...

Another cute thing is that it's quite easy to add moonlight to the night side - just some background diffuse light term will do nicely.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Sunrises (download in first post)

Postby Zan » Sun Jan 15, 2012 9:39 pm

Whoa, this looks very spectacular. The colors make those shots very lively. Now just to add project Rembrandt to that.... it would look awesome.

Btw, do you think the terminator would come free with real shadows, or is it somehow different phenomenom?

Zan
Zan
 
Posts: 123
Joined: Tue Oct 20, 2009 11:28 am

Re: Sunrises (download in first post)

Postby fredb » Sun Jan 15, 2012 10:13 pm

Real shadows have a very small radius. 15km at most
User avatar
fredb
 
Posts: 753
Joined: Fri Dec 01, 2006 11:41 am
Location: Paris, France

Re: Sunrises (download in first post)

Postby Johan G » Mon Jan 16, 2012 6:45 am

Lovely, Thorsten. :D
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

PreviousNext

Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 10 guests

cron