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!

Re: Revisiting clouds

Postby Icecode GL » Wed Sep 19, 2018 11:47 am

What you have described is basically what I was trying to explain.

(Of course the texture somehow needs to move with the airplane, or a set of tiles of such textures needs to be instanced and deleted,... but I believe that can be made to work).


Yeah, tiling shouldn't be a problem. Wind can also be done with UV offsets.
Icecode GL
 
Posts: 528
Joined: Thu Aug 12, 2010 12:17 pm
Location: Spain
Callsign: icecode
Version: GIT
OS: Arch Linux

Re: Revisiting clouds

Postby Thorsten » Wed Sep 19, 2018 12:12 pm

What you have described is basically what I was trying to explain.


That's good then.
Thorsten
 
Posts: 10950
Joined: Mon Nov 02, 2009 8:33 am

Re: Revisiting clouds

Postby Mihajlo » Wed Sep 19, 2018 2:18 pm

Maybe my last post had too much unnecessary details and technical things for the point I was trying to make.
To make it more clear my basic question is would volumetric clouds or a technique Thorsten is describing enable us to have different appearance of stratiform clouds based on atmospheric instability?
For example in stable weather Altostratus looks uniform and smooth from above, but in an unstable atmosphere it looks like Altocumulus castellanus with protuberances and vertical development. Currently only Cumulus clouds change while stratiform and other clouds have the same appearance.
Mihajlo
 
Posts: 53
Joined: Tue Aug 28, 2018 5:47 pm

Re: Revisiting clouds

Postby Thorsten » Wed Sep 19, 2018 2:21 pm

You don't need to wait for a new technique for that, you can do this at the simple expense of supplying better textures for the clouds we have now.

The problem is that I've done 80% of the cloud pictures the textures are based on myself, and since I don't own a plane, they're pretty much all ground-based shots. You don't see much of the top of a stratiform layer from the ground.

For the volumetric cloud, this is too detailed to answer now - theoretically many things are possible, in practice they might push framerate to an unacceptable level.
Thorsten
 
Posts: 10950
Joined: Mon Nov 02, 2009 8:33 am

Re: Revisiting clouds

Postby Mihajlo » Wed Sep 19, 2018 2:33 pm

Can't you use those pictures of the first aerial sunrise I sent you? Some of them show a stratiform layer from above in an unstable weather with nice protuberances, like the second one I linked in my earlier post.
Mihajlo
 
Posts: 53
Joined: Tue Aug 28, 2018 5:47 pm

Re: Revisiting clouds

Postby Thorsten » Wed Sep 19, 2018 2:36 pm

Extracting cloud textures from photographs is kind of... tricky. Feel free to try it though, you can just replace the current texture sheet by your version and see how it looks like, and when we have a good set, I can re-write the cloud code to get the from above vs. from below difference.
Thorsten
 
Posts: 10950
Joined: Mon Nov 02, 2009 8:33 am

Re: Revisiting clouds

Postby Mihajlo » Wed Sep 19, 2018 2:45 pm

Yes, I imagine it's tricky and my photographs are not professional level. It also occurred to me that perhaps it's possible to also reuse existing textures. I believe that we already use Cu texture for a smaller patch of Sc, and some clouds have a similar appearance from above unlike from the ground. I don't think it would be a mistake to use Cu textures (or part of it) for stratiform clouds in unstable weather as well since like I said in my earlier post Cu can protrude a stratiform layer from below,but the protuberance can also come from the stratiform layer itself, but the difference in reality is hardly distinguishable (this was mentioned in WMO cloud atlas).
Mihajlo
 
Posts: 53
Joined: Tue Aug 28, 2018 5:47 pm

Re: Revisiting clouds

Postby Thorsten » Wed Sep 19, 2018 3:02 pm

Feel free to try that as well :D

P.S.: I'm not a professional photographer either, I just sat down and experimented as well as I could.
Thorsten
 
Posts: 10950
Joined: Mon Nov 02, 2009 8:33 am

Re: Revisiting clouds

Postby Mihajlo » Wed Sep 19, 2018 3:07 pm

Maybe you are not a professional, but you are likely better than me or an average person at this since you've gone as far as to shoot a short movie with special effects.
Mihajlo
 
Posts: 53
Joined: Tue Aug 28, 2018 5:47 pm

Re: Revisiting clouds

Postby Thorsten » Wed Sep 19, 2018 5:00 pm

And right there you have it - much of my time goes into producing said movie.

You're maybe kind of hoping that you supply the idea and a few pictures, I do the actual work, and admittedly I probably would even do the work faster than most because I have some experience already, but... time. It takes me several hours to extract a good texture from cloud footage and try it out - hours which I could spend working on the Shuttle, or implement some new rendering idea, or track some bug, or teach someone how to do a good display effect,...

Or work on the next episode of my movie.

it doesn't scale if I do every bit of work just because I might do it faster than others. This isn't coding exotic physics problems (which really only few here can do), it's extracting a texture from a photograph. It's tedious, tricky, yes - but you don't need any special education to figure this out.

And, to say it bluntly, I'm fairly happy with the weather 'as is', and whenever I'm not I go about fixing by myself.

So even if it takes you three times as long as me to extract the textures, it's still your best bet to get them. Because for me it's just not anywhere a priority. I'm ready to give you help should you need any, or to implement it if you come up with a texture sheet. But I'm not going to work on this for any time soon myself. Because there's just too much other stuff I'd like to do.
Thorsten
 
Posts: 10950
Joined: Mon Nov 02, 2009 8:33 am

Re: Revisiting clouds

Postby Mihajlo » Wed Sep 19, 2018 6:04 pm

Thorsten, that's completely understandable. I was just raising some points, and I'm not expecting you do this yourself just because I mentioned it. I fully understand that if the idea is not a priority, you won't work on it anytime soon. I do think it's worth for it if I can supply an idea and pictures and you implement it someday, but again even if you don't that's also fine and perfectly understandable and while I am hoping you'll do someday I am not having any real expectations. It's just a collection of ideas on how to further increase realism (which again may not be your top priority), and admittedly some of them are perhaps simply nice to have rather than a must.I also know it's easier to come up with something than to actually implement it). Sometimes even if it's a good idea it doesn't get implemented for various reasons.
I'm also happy with the weather system. Thinking of ways on how to improve doesn't mean I'm unsatisfied. Again it's to help make the weather system and ALS even more realistic.
Also I think you misunderstood my last post. I wasn't implying that you should extract cloud textures because you are faster, more experienced and knowledgeable with camera. I said that because I got the impression that you were being modest with your camera skills when comparing yourself to me and are most likely a lot better than me at this, even if you are not a professional, but I didn't mean it in the context of cloud texture extraction at all.
If I do decide to work on cloud textures myself and get stuck I'll ask for help then. Thanks for the offer.
Mihajlo
 
Posts: 53
Joined: Tue Aug 28, 2018 5:47 pm

Re: Revisiting clouds

Postby Thorsten » Thu Sep 20, 2018 4:53 am

@IcecodeGL:

Framerates are bad as well because the ray marcher currently runs 256 samples per pixel every frame.


Some random observations which might help to speed up the numerics:

1) We should be able to cut the integrals and no longer sample beyond a certain threshold - if the ray is already in the 99% opaque zone it really doesn't matter how the sky looks beyond that point. This ought to drop a lot of samples for opaque clouds in the sky. That holds for both sampling along view direction and the nested samples towards the sun.

2) We should be able eventually to do a quick check whether a sampling point is 'clear' and not evaluate any more complicated noise for that point (another question is whether the GPU drivers play along here...)

3) It might be possible to sample the sunward rays in a simplified density distribution and not use the full noise for that - should make each sample cheaper to obtain

4) I've once toyed with heightmaps on the terrain and had the opportunity to compare lookup performance of procedural and texture-based map. What happened surprised me a bit - while a single texture lookup was more expensive than the procedural value, the situation reversed for multiple samples - 20 lookups on the texture were a lot cheaper than 20 computations of the function.

I've learned later that it makes a substantial difference for the GPU whether a texture is 'hot' in memory or not - if that is still true, it might gain a lot to have the coarse cloud shape in a texture and sample shadowing over that.
Thorsten
 
Posts: 10950
Joined: Mon Nov 02, 2009 8:33 am

Re: Revisiting clouds

Postby Icecode GL » Thu Sep 20, 2018 8:31 am

1) We should be able to cut the integrals and no longer sample beyond a certain threshold - if the ray is already in the 99% opaque zone it really doesn't matter how the sky looks beyond that point. This ought to drop a lot of samples for opaque clouds in the sky. That holds for both sampling along view direction and the nested samples towards the sun.


Yeah, I'm already breaking from the loop when the density reaches 1.0 for the view rays. I should do the same for the nested rays.


I actually started using noise functions first, but the performance was more than terrible (single-digits for 64 samples or so). In the end I decided to try using textures like they do in Horizon Zero Dawn, and the performance gains were amazing. With 512 samples I end up in single digits, but with 16/32 samples (which is the target number for samples) the performance drop is negligible (1 or 2 ms depending on the scene and coverage). The only problem is that since I can't figure out how to store a 3D texture and upload it to the Effects framework, I'm currently reading from a tiled 2D texture where each tile represents each depth layer. This can lead to artifacts (you can see some lines that indicate the transition between one layer and the other) and a slight performance drop since there is no hardware accelerated interpolation.

Another problem with using textures is their low resolution. Clouds can appear kind of blocky sometimes (you can see that in the pictures I posted earlier). The presentation Mihajlo linked earlier solves that by mixing the final density with a higher resolution "turbulence" texture that adds some movement to the blocky texels.

The trick to make these clouds work is some kind of temporal reprojection, either via accumulative blending across multiple frames and averaging the positions or by performing a reduced sample count and reprojecting the previous frame. In the end it's about reducing the amount of samples the GPU has to do every frame, one way or another.
Icecode GL
 
Posts: 528
Joined: Thu Aug 12, 2010 12:17 pm
Location: Spain
Callsign: icecode
Version: GIT
OS: Arch Linux

Re: Revisiting clouds

Postby Thorsten » Thu Sep 20, 2018 11:43 am

Don;t be blinded by solutions others have used... I believe 3d textures don't lead anywhere for us.

The thing is that you don't need to sample the view ray over the same density distribution that you use to evaluate the shadow rays. The shadow ray resolution will almost inevitably suck because your sampling points are far apart - so this might well be evaluated using a texture whereas the view ray is evaluated over texture + noise, bulkiness won't be apparent because of your low resolution.

Which texture?

In the proposed scheme, we have (a bunch of) 2d textures at 50 m resolution which tells us where the clouds are and how dense they are. So we can simply use the parameter that tells us how high to draw the clouds in combination with their density and position to evaluate the shadow rays - clouds aren't 'weird' 3d objects that can have any shape, their opaque core at least has a certain shape that's bulky (no holes in the middle) and getting smaller towards the upper edge, and we can use that information to cast everything into a 2d problem.

So all this needs is a number of 2d texture lookups till you exit the layer with the ray (or saturate). No need to fiddle with 3d textures, they're poorly suited for the task.
Thorsten
 
Posts: 10950
Joined: Mon Nov 02, 2009 8:33 am

Re: Revisiting clouds

Postby Icecode GL » Thu Sep 20, 2018 12:20 pm

Don;t be blinded by solutions others have used... I believe 3d textures don't lead anywhere for us.


I've experimented with quite a few variations, including something similar to what you are describing. In my opinion 3D (or fake 3D) textures are the way to go to describe the general shape of the clouds. Complicated noise functions are too slow to evaluate, much slower than a texture fetch.

In the proposed scheme, we have (a bunch of) 2d textures at 50 m resolution which tells us where the clouds are and how dense they are. So we can simply use the parameter that tells us how high to draw the clouds in combination with their density and position to evaluate the shadow rays


I'm already doing that. The base cloud shape is being modulated by a 2D coverage texture/noise function.

clouds aren't 'weird' 3d objects that can have any shape, their opaque core at least has a certain shape that's bulky (no holes in the middle) and getting smaller towards the upper edge, and we can use that information to cast everything into a 2d problem.


I don't think a cloud shape is as simple as that. You need to have some kind of noise function to modulate the density in the height axis.

So all this needs is a number of 2d texture lookups till you exit the layer with the ray (or saturate).


Well, some 2D textures stacked on top of each other make up a 3D texture... In general I think you are trying to optimize something that doesn't need optimization. The current technique runs really fast on a low sample count, and I don't think you'll be able to further decrease the amount of work done per sample, not without compromising how good the clouds look.

I don't have access to the code right now, but I'll post it as soon as possible so you can have a look and see how things are currently done, even though you won't be able to try it out.
Icecode GL
 
Posts: 528
Joined: Thu Aug 12, 2010 12:17 pm
Location: Spain
Callsign: icecode
Version: GIT
OS: Arch Linux

PreviousNext

Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 2 guests