Jump to content
Sign in to follow this  
cepact

imagine the weather with 24 layers of overcast clouds

Recommended Posts

As I understand volumetric rendering is done by ray casting, and clouds are simply boxes with 3D texture. So having more clouds won't result in having more vertices, but it will increase the ray computations on the shaders

Edited by cepact

Share this post


Link to post
Share on other sites
1 hour ago, Noooch said:

I still can't understand how the weather doesn't affect performance. This was the major problem for all the current sims...

That has everything to do with clouds being sprites in most simulators. Sprites can be costly to render due to needing a lot of draw calls and taking transparency into consideration if I remember correctly. A different rendering technique can thus look way better and have way better performance. 

  • Like 1

Share this post


Link to post
Share on other sites

My best research indicates to me that they're using a new-ish technique for volumetric rendering called raymarching. Now, raymarching is actually quite an old technique related to raycasting, but instead of tracing each ray's complete travel across the scene including various bounces, raymarching casts a ray for each pixel towards the object, and then "marches" down the ray at discrete steps, and stops when the distance to the object is sufficiently small (but not exact). Recently some more enterprising devs have come up with ways to make this work on modern GPUs in inventive ways. This makes raymarching much faster than newer ray tracing techniques, but less precise. For rendering volumes, you simply continue marching down the ray at your discrete steps until you've exited the interior of the object.

For objects such as smoke and clouds, that have very undefined edges, this works great, because you get to pick a step size that is sufficiently large to be performant, and the lack of defined edges makes the low precision of large steps a somewhat non-issue. Then, the shader can do calculations based on the various textures of the cloud to come up with a color based on how many steps ended up inside the volume; this number of steps can be used to determine how much to darken the pixel, apply scattering approximations, etc.

Similarly, you get shadows from volumes very easily using this technique as well: simply do the same procedure, except casting the ray from the light source.

Now, if that still sounds very much like a decent amount of cost, even with those optimizations considered, you would definitely be correct. However, there are other cheats you can make:

  • Use a huge step size until you enter a volume, and then switch to the normal step size
  • Stop bothering to calculate anything once the pixel is fully occluded (an alpha of 1)
  • Render the cloud pass as a low resolution, since clouds have no sharp edges
  • Render far away clouds (which is normally most of them) by just updating every other or every 4th pixel per frame

Guerilla Games has an excellent technical presentation on these techniques and how they applied them to Horizon Zero Dawn: https://www.guerrilla-games.com/read/the-real-time-volumetric-cloudscapes-of-horizon-zero-dawn

-Matt N

  • Like 3
  • Upvote 1

Share this post


Link to post
Share on other sites

Well, frankly I didn't understand anything but it seems to be a very efficient technique. But does that mean that clouds don't have any hit on performance ? Because the ones who have tried the sim said so...

Share this post


Link to post
Share on other sites
3 minutes ago, Noooch said:

Well, frankly I didn't understand anything but it seems to be a very efficient technique. But does that mean that clouds don't have any hit on performance ? Because the ones who have tried the sim said so...

I would not say that would be accurate, no. Rendering clouds in this way will certainly impact your rendering times, without a doubt. For Horizon Zero Dawn, the Guerilla devs said this was about 2ms out of their 15ms budget. I expect that MSFS would be in the same ballpark. They may have additional optimizations I or others haven't considered, however.

That being said, rendering clouds in this way can be much better in the worst case, because you don't have to calculate the transparency of each pixel by checking against potentially a ton of cloud sprite textures. Texture lookups are comparatively expensive and the way those are rendered doesn't give you a lot of easy optimizations; you just have to draw all the cloud sprites on top of each other, no matter how many there are. With the raymarching shader technique, the number of cloud layers being rendered behind each other doesn't really have any particular detrimental effect. So whereas before, overcast was always a worst case, needing a bunch of clouds and textures to simulate a saturated cloud cover, with this technique, overcast is almost a best case, since the shader will just ask "Can the cloud pass possibly make the pixel I'm checking any more opaque?" If not, just bail out and stop trying to march through the rest of the volume.

-Matt N

  • Like 2

Share this post


Link to post
Share on other sites
10 minutes ago, Noooch said:

Well, frankly I didn't understand anything but it seems to be a very efficient technique. But does that mean that clouds don't have any hit on performance ? Because the ones who have tried the sim said so...

Everything you draw has a hit on performance, the hit might not be noticeable though in case the technique is very efficient. Using a different technique may have a different impact than what we are used to. With the raymarching approach an overcast cloud deck might draw faster than scattered clouds which is quite the opposite from what we are used to in our current sims. Only time will tell if the clouds will have a big impact on our frame rates, but it is actually possible that you might not notice much of an impact. 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...