Board index FlightGear Development Effects and shaders

Terrain self shadowing

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

Re: What/Where did you fly today? - Part 2

Postby chris_blues » Fri Apr 12, 2013 1:47 am

WOW!! :shock:
This looks great!

Can you make this a standard? :)

This is great!!! What a wee bit more pronounced light/darkness can do!!!
Cheers!
Don't hesitate to let me know if I'm incorrect or just annoying! As long as you do it gently! :)
Debian testing 64bit - Athlon II 2x2.6GHz - 8GB RAM - GeForce GTS 450
Citation II
User avatar
chris_blues
 
Posts: 1573
Joined: Mon May 03, 2010 1:30 pm
Location: claws of real life
Callsign: chris_blues
Version: GIT
OS: Debian 8 64

Re: What/Where did you fly today? - Part 2

Postby Thorsten » Fri Apr 12, 2013 6:37 am

BTW: How do you usually create those nice "PRE/POST-Thorsten" screen shots ?


In this case it's property toggle - in order to get the visuals changing runtime, I added property-controlled ambient and diffuse light multipliers to the terrain shader and then just experimented with those - which of course allows setting them to default and any other value.

In order to gauge lighting changes, I usually do the changes to one quality level of a shader and use the quality level switch to see what it does.

In other cases, I have a few default spawn locations for benchmark testing - you'll notice that lots of shots are around KNID or KINS which are two of my benchmark locations. In this case, the default condition is usually some fixed altitude above runway.


Can you make this a standard?


It's a tricky game to get this right (and like the Outerra person, I did a bit of cherry-picking here). Let me explain what this is and what this isn't:

A local shadow model evaluates the dot product of surface normal and light direction and shades a surface if the dot product is negative. For terrain self-shading, that works reasonably well because the terrain usually is not steeper than the sun is high.

But it is fundamentally an illusion - there's nothing in the computation about things blocking light. In particular, if you have a tree on the shaded slope of a mountain, the surface of the tree facing the sun will be in light. If you have a deep gorge, the wall facing the sun will be in light. Which is to say that the illusion breaks now and then, and the visual mismatch of the breaking illusion is worse if the shade was more pronounced to begin with.

In contrast, Rembrandt uses a genuine shadow map, and Rembrandt would shade a tree on the shaded slope of a mountain. But the shadow map has a max. size of 10 km or so, so while Rembrandt shading could generate the first of my screenshots, it could not do the second where you see shadows in a scene with 100 km visibility. So Rembrandt out of the box isn't really going to help too much with terrain self-shading seen from high altitude, but it will get things more or less right in close-up scenes.

Now, the elephant in the room are clouds, haze and perception. How hard the shadows are is a function of available direct light vs. available indirect light, weighted by perception. Available indirect light depends strongly on cloud cover and haze level (in space there is zero ambient light), so in implementing this credibly, I need to automatically undo the effect smoothly when going from clear skies to overcast skies and implement haze level correctly - the shading is way too strong for even a broken cloud cover. Also, the way perception works is tricky. As long as you have the contrast to a bright surface, having a very dark shadow is okay. If you were to fly 5 minutes in the shadow of a mountain without seeing a bright surface, your eyes would adapt and you would probably judge the level of shading used as too strong (what complicates the issue is that your eyes also to some degree adapt to the actual brightness of your monitor, dependent on the real level of ambient light in your room - for instance simulated moonlight scenes work well for me when it is really night, but I can't make much out on the screen in bright daylight...). Ambient irradiance is also a function of surface orientation - obviously the sky has more stray light than the ground, which is why a vertical surface gets less ambient light than a horizontal one - which brings us ultimately to ambient occlusion problems...

So this needs to be a compromize between credible illusion and not making the flaws to obvious, it needs some scheme for following the weather and environment driven effects correctly, it needs toning down tree directional lighting (to preserve the illusion of a shaded slope better) and tweaks to the ambient irradiance functions.

Which is why I won't make it standard for a while. But it seems worthwhile working on it.
Thorsten
 
Posts: 11580
Joined: Mon Nov 02, 2009 8:33 am

Re: What/Where did you fly today? - Part 2

Postby chris_blues » Fri Apr 12, 2013 5:20 pm

Thanks for explaining! Seems like a lot of work and fine-tuning!

I sure hope to see this in action someday!!! 8)
Don't hesitate to let me know if I'm incorrect or just annoying! As long as you do it gently! :)
Debian testing 64bit - Athlon II 2x2.6GHz - 8GB RAM - GeForce GTS 450
Citation II
User avatar
chris_blues
 
Posts: 1573
Joined: Mon May 03, 2010 1:30 pm
Location: claws of real life
Callsign: chris_blues
Version: GIT
OS: Debian 8 64

Re: Terrain self shadowing

Postby Thorsten » Sun Apr 14, 2013 8:06 am

Been experimenting with this a bit more (completely ambient channel tree shading, then reducing ambient light for terrain and oversaturating diffuse light, making this dependent on sun angle (to account for perception weighting of indirect light at predawn) and cloud cover (to account for different stray light). Up to a 10 minute stretch at dawn/dusk where only the red channel oversaturates and white surfaces get an unrealistic greenish hue, this looks really good.

Here's some more results:

Image
Image

Image
Image


Some typo in the shader code - direct light at sunrise, way too strong:

Image

And... there's nothing magic about the Outerra terrain detail resolution. We can do noise maps at very small scales, and the shadows will follow accordingly (and I could do this down to a millimeter scale if needed) - but this brings out the limitations of other scene elements - trees have limited resolution, and out mesh, even with custom scenery resolution, looks blocky when studied from very close up.

Image

It's mainly a question of where a flightsim should dump resources into.
Thorsten
 
Posts: 11580
Joined: Mon Nov 02, 2009 8:33 am

Postby Hooray » Sun Apr 14, 2013 9:31 am

Image

Looks like your previously mentioned LotR background is having an effect here? :lol:
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11738
Joined: Tue Mar 25, 2008 8:40 am

Re: Terrain self shadowing

Postby marco » Tue Aug 13, 2013 8:04 pm

The second of these Images looks stunning to me ....
The textures of the different terrain-classes blend so smoothly it looks really natural.
What's the magic behind this?
marco
 
Posts: 69
Joined: Sat Feb 12, 2011 10:09 pm
Location: EDDR
Version: Git
OS: openSuSE 13.2

Re: Terrain self shadowing

Postby Hooray » Tue Aug 13, 2013 8:34 pm

marco wrote in Tue Aug 13, 2013 8:04 pm:What's the magic behind this?


  • powerful computer with a state-of-the-art GPU
  • an artistic eye
  • programming experience
  • GLSL knowledge
  • and looking at his code, a PhD in maths seems to come in handy, too ..
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11738
Joined: Tue Mar 25, 2008 8:40 am

Re: Terrain self shadowing

Postby Johan G » Wed Aug 14, 2013 7:12 am

I would guess that to most of us Thorsten is a bit of a mathemagician.* :wink:

A lot of the things he have done with the weather and visuals are really stunning, and as Hooray mentions he seems to have the rare combination of artistic sense, maths and physics knowledge and the coding skills to get a lot closer to where he wants than many other of us. (Mostly speaking for myself here though. :wink: )

I am really amazed at many of his screenshots, and it has been a pleasure to follow some topics, most of all A local weather system (v1.4 available), Sunrises (version 1.3 available) and Sunset art gallery. This topic ain't that bad either. :D

Thank you Thorsten! :D

* I'm thinking of Arthur C. Clarke's third law: Any sufficiently advanced technology is indistinguishable from magic.
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)
Johan G
Moderator
 
Posts: 5691
Joined: Fri Aug 06, 2010 5:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 3.0.0
OS: Windows 7, 32 bit

Re: Terrain self shadowing

Postby marco » Wed Aug 14, 2013 1:13 pm

@ Thorsten: are there any chances for your changes to make it to git? If not, could you make your changes public for those who'd like to implement them too?

cheers, Marco
marco
 
Posts: 69
Joined: Sat Feb 12, 2011 10:09 pm
Location: EDDR
Version: Git
OS: openSuSE 13.2

Re: Terrain self shadowing

Postby Thorsten » Wed Aug 14, 2013 3:06 pm

@ Thorsten: are there any chances for your changes to make it to git?


That's all part of what is rolled out with the next release, the shaders have been on GIT a few days after I wrote and tested them (I have commit rights to FGData these days, so usually stuff gets out as soon as it looks bug-freee and stable).

You get the visuals by switching Atmospheric Light Scattering on at highest quality level.

I would guess that to most of us Thorsten is a bit of a mathemagician


:-) I guess mostly it's down to an ability to see a scene in nature, translate what I see mentally into the set of equations that govern it, and translate these into an algorithm which renders it - and backwards without actually writing anything or running code. Which seems a bit like magic, but I have a very visual way of solving physics problems (which is, I gather from talking to others, somewhat unusual for a theoretical physicist, most solve problems symbolically) which helps here.

But I do like the term, it's rather charming...
Thorsten
 
Posts: 11580
Joined: Mon Nov 02, 2009 8:33 am

Re: Terrain self shadowing

Postby Hooray » Wed Aug 14, 2013 3:45 pm

Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11738
Joined: Tue Mar 25, 2008 8:40 am

Re: Terrain self shadowing

Postby chris_blues » Wed Aug 14, 2013 11:25 pm

Thank You Sir!
Don't hesitate to let me know if I'm incorrect or just annoying! As long as you do it gently! :)
Debian testing 64bit - Athlon II 2x2.6GHz - 8GB RAM - GeForce GTS 450
Citation II
User avatar
chris_blues
 
Posts: 1573
Joined: Mon May 03, 2010 1:30 pm
Location: claws of real life
Callsign: chris_blues
Version: GIT
OS: Debian 8 64

Previous

Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 1 guest