Board index FlightGear Development Effects and shaders

Revisiting clouds

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

Revisiting clouds

Postby Thorsten » Mon Aug 20, 2018 5:02 pm

Saw this display of Mie scattering at the fringe of clouds today in reality (including the inverse thing away from the cloud with the fringe darkening) and started wondering - why is it not in FG?

Image

Of course, the answer is when we designed clouds, all had to be in the vertex shader because making a non-trivial fragment shader floored framerate - but nowadays GPUs are much faster. So I rigged some code to make the MIe term more differential - and - well, what you see above is in fact FG and not reality.

Now I need to get rid of unwanted scattering though... But it might be worth pursuing further...
Thorsten
 
Posts: 10740
Joined: Mon Nov 02, 2009 8:33 am

Re: Revisiting clouds

Postby Icecode GL » Mon Aug 20, 2018 5:07 pm

Wow, very very cool. Such a "small" thing makes a huge difference. Maybe on the left cloud it's a bit too pronounced I think, but the big one looks amazing.
Icecode GL
 
Posts: 514
Joined: Thu Aug 12, 2010 12:17 pm
Location: Spain
Callsign: icecode
Version: GIT
OS: Arch Linux

Re: Revisiting clouds

Postby wlbragg » Tue Aug 21, 2018 1:54 am

Wow, at first I thought you posted a picture of the cloud you observed in RL, really nice.
That cloud on the left must be exhibiting some of the "unwanted" scattering?
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
User avatar
wlbragg
 
Posts: 4773
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Debain/nVGT640

Re: Revisiting clouds

Postby stuart » Wed Aug 22, 2018 1:59 pm

Very beautiful indeed.

Do you think we should be looking at procedurally generating the cloud sprites rather than relying on textures?

-Stuart
G-MWLX
User avatar
stuart
Moderator
 
Posts: 1469
Joined: Wed Nov 29, 2006 9:56 am
Location: Edinburgh
Callsign: G-MWLX

Re: Revisiting clouds

Postby Lydiot » Wed Aug 22, 2018 2:13 pm

Excellent work Thorsten!
Lydiot
 
Posts: 984
Joined: Tue Oct 22, 2013 10:50 pm

Re: Revisiting clouds

Postby Thorsten » Wed Aug 22, 2018 4:46 pm

Some impressions from flight-testing:

Image
Image
Image

I was curious about the performance impact of putting much more work into the fragment shader, but at least on a high-end card it's not even measurable.

Do you think we should be looking at procedurally generating the cloud sprites rather than relying on textures?


I suspect that may be hard to do - at least I don't know how a noise function to generate all the subtlety that's in the textures should look like.

In web examples, people often use Perlin noise - but while that looks like cloud, it doesn't really look like any particular cloud type.

So if you have some idea how a suitable noise would look like I'm all ears and think it's worth trying - but for all I like painting things with math - clouds are damn complicated.

(Actually, once we do more cloud stuff in the fragment shader, the thought crossed my mind to completely re-vamp the clouds to hand different metadata to the shaders. But I've shied away from that - clouds are too important an element of flight to break them for low performance systems...)
Thorsten
 
Posts: 10740
Joined: Mon Nov 02, 2009 8:33 am

Re: Revisiting clouds

Postby Icecode GL » Wed Aug 22, 2018 6:33 pm

I can see that some of the clouds in the foreground are receiving unwanted scattering since they aren't aware of their depth, i.e. they don't know what is in front or behind them.

Do you have a planned solution or may I suggest several Compositor-based solutions?
Icecode GL
 
Posts: 514
Joined: Thu Aug 12, 2010 12:17 pm
Location: Spain
Callsign: icecode
Version: GIT
OS: Arch Linux

Re: Revisiting clouds

Postby Thorsten » Wed Aug 22, 2018 7:43 pm

I can see that some of the clouds in the foreground are receiving unwanted scattering since they aren't aware of their depth, i.e. they don't know what is in front or behind them.


To my mild surprise, real clouds actually do that (or at least close enough) when the light isn't exactly falling through the cloud - we've had pretty much the same weather in reality today, and I got to do plenty of comparisons stepping outside. You can often see bright filaments of cloud right in front of a dark background.

(I haven't figured out the precise mechanism yet, but I am sure of the phenomenon by now).

So the current level of scattering from the back is maybe unexpected but no longer entirely unwanted (we know where in the cloud a sprite is, so I have some means of dialing the suppression factors on average).

As for getting it even more precise:

I suspect doing things like a second pass over the clouds might be prohibitively expensive (if that is what you have in mind)... So my current thinking rather goes to supplying a cloud meta description that allows more detailed shading.
Thorsten
 
Posts: 10740
Joined: Mon Nov 02, 2009 8:33 am

Re: Revisiting clouds

Postby Icecode GL » Wed Aug 22, 2018 7:52 pm

I suspect doing things like a second pass over the clouds might be prohibitively expensive (if that is what you have in mind)...


I was thinking of a depth pre-pass on the clouds only, which is basically free since the shaders aren't executed at all and the culling is very fast because the cloud geometry is very simple. The "normal" cloud pass can then use this depth information.

We haven't had cloudy days here for a while, so I can't say for sure if that scattering is present or not, but to my untrained eye it still looks kind of unnatural. I'd still try to at least tone it down a bit. My two cents of course. :)
Icecode GL
 
Posts: 514
Joined: Thu Aug 12, 2010 12:17 pm
Location: Spain
Callsign: icecode
Version: GIT
OS: Arch Linux

Re: Revisiting clouds

Postby Thorsten » Thu Aug 23, 2018 4:50 am

I was thinking of a depth pre-pass on the clouds only, which is basically free since the shaders aren't executed at all and the culling is very fast because the cloud geometry is very simple. The "normal" cloud pass can then use this depth information.


Unfortunately a pass without shader gives you the depth information for the blocky outlines of the texture-carrier quads - lots of straight lines in there... if the info is meaningful at all, because the clouds use the vertex shader to actually position and orient them. Moreover, it means that also very translucent clouds which do not block light suddenly acquire the ability to do so.

What you actually want is the integral of texture alpha along the light ray (which is really too expensive to get) - hence my idea of modeling this independent of the rendering process by utilizing the meta-description of the cloud.

but to my untrained eye it still looks kind of unnatural


I readily agree -it's weird. Googling a bit to find a picture to show what I observed, this comes a bit close - on average the outlines are bright, but there's plenty of intruding filaments and unexpected brightness as well.

Image

So yeah, I don't get the balance completely right at the moment, but clouds casting shadows on clouds (even themselves) is really a tough computational problem...
Thorsten
 
Posts: 10740
Joined: Mon Nov 02, 2009 8:33 am

Re: Revisiting clouds

Postby Icecode GL » Thu Aug 23, 2018 1:45 pm

What you actually want is the integral of texture alpha along the light ray (which is really too expensive to get)


That sounds like raymarching to me, although that would change how clouds are being rendered a bit too much, maybe too much for what you are trying to accomplish. If your meta-description approach gets the job done well enough, I guess that's good enough for now.

I readily agree -it's weird. Googling a bit to find a picture to show what I observed, this comes a bit close - on average the outlines are bright, but there's plenty of intruding filaments and unexpected brightness as well.


I think the issue here is something resembling the uncanny valley but for clouds. Scattering on the fringe of the clouds is a real life phenomenon which can add more realism to the end result in some cloud configurations. However, in other not so realistic looking cloud configurations, the fringe scattering can worsen the end result instead of improving it, since it's a realistic feature applied on top of a not-so-realistic base. It's like adding very realistic face features to a plastic doll, it looks creepy. I'm not sure if this gets my point across, but I think that's the reason it looks weird in some situations.
Icecode GL
 
Posts: 514
Joined: Thu Aug 12, 2010 12:17 pm
Location: Spain
Callsign: icecode
Version: GIT
OS: Arch Linux

Re: Revisiting clouds

Postby Thorsten » Thu Aug 23, 2018 2:15 pm

However, in other not so realistic looking cloud configurations, the fringe scattering can worsen the end result instead of improving it


Quite so.

Though I believe it's simply a focus issue - the fringe scattering generates a series of high-contrast lines between the bright fringe and the dark cloud, so any viewer's attention will be directly there - perception won't gloss over it, it has to 'make sense' and be interpreted.

Like low sunlight, that's a high-risk/high-gain feature - if it works it's great, if it's wrong it tends to be spectacularly wrong (incidentially, that's the reason ALS is not rendering a huge class of situations it could possibly render, because I don't know how to make the weather system drive these situations without stumbling into the spectacularly wrong pit).

Anyway, I just took a series of pics of 'weird' but real lighting - I'll post this later, I need the other computer which has the driver for the camcorder installed.
Thorsten
 
Posts: 10740
Joined: Mon Nov 02, 2009 8:33 am

Re: Revisiting clouds

Postby Thorsten » Thu Aug 23, 2018 2:46 pm

Okay, that's a real one of today (I didn't have to wait long, essentially I just took three different shy shots - this was just the mmost dramatic illustration).

Right in the middle, bright filaments right behind a dark cloud tower - extremely high contrasts close by. On the lower right, another bright filament before the central cloud tower is partially obscured by another dark one.

The lower left has more smallish examples of bright stuff intruding.

Image

Probably the real depth ordering of the clouds is much different from what one would intuitively assume and the different parts are much more widely spaced in z-direction than they seem (?)
Thorsten
 
Posts: 10740
Joined: Mon Nov 02, 2009 8:33 am

Re: Revisiting clouds

Postby Thorsten » Thu Aug 23, 2018 2:58 pm

And that's how (unassuming in comparison...) the meta-description based shading model looks like

Image

The effect on some stratiform clouds - one has to climb above the lower layer to see it...

Image

(that's actually a fairly complicated picture with many different types of scattering and shading seen - and while certainly not perfect, by and large it works for me.
Thorsten
 
Posts: 10740
Joined: Mon Nov 02, 2009 8:33 am

Re: Revisiting clouds

Postby Icecode GL » Thu Aug 23, 2018 4:03 pm

Don't know how you achieved it, but it looks a lot like the photo you posted. Amazing results Thorsten, as always.
Icecode GL
 
Posts: 514
Joined: Thu Aug 12, 2010 12:17 pm
Location: Spain
Callsign: icecode
Version: GIT
OS: Arch Linux

Next

Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 2 guests