Procedural Cloud Rendering

Started by
4 comments, last by Willywill 8 years, 9 months ago

Hello everyone,

I completed my sky rendering and I am pleased with the results. However, it obviously lacks any sort of clouds which are greatly needed for the rainy scenes planned.

wLAQ4PQ.jpg

My goal for the clouds were to have them be computed procedurally on the GPU using a noise function that closely represented real-life clouds, and of course doing shading that is photorealistic.

The clouds need to be:

  • Dynamic
  • Accurately shaped
  • Realistically shaded
  • Cast shadows
  • Contains info about occluding the sun (used later in AO shader)

Luckily, I have found someone else's solution who created essentially everything I was after. The link can be found below.

http://www.digitalrune.com/Support/Blog/tabid/719/EntryId/186/Cloud-Layer.aspx

I am stuck on how to create the cloud layer but I have a few ideas. To start with the clouds themselves, my initial idea is to have some sort of altitude parameter that controls the height in world space where the clouds are located. The these clouds are created on the fly using X amount of octaves of some noise function and are raymarched for gathering density, making the bottom part of the clouds darker.

Shading wise shouldn't be too hard. I can reuse my phase function for the sun lighting perhaps, but I'm mostly concerned with rendering the clouds themselves. This is the part I struggle the most with.

I'm lost at understanding how I project the clouds into the sky dynamically. For my sky I used world space frustum corners and created it as a post-process. I would like to do the same for the clouds somehow. I understand that this doesn't seem practical but it works really well for my application.

I also struggle with understanding how to raymarch the clouds to get a density value controlling how dark the clouds look and such.

I hope this made some sense, I struggle with coming up with good ways to explain it because this is my first time doing cloud rendering. If possible, showing code is the most helpful!

Thank you everyone, I hope to see your responses.

Advertisement

That's awesome. I need To figure out the skys at some point, so maybe we can trade a bit of info.

The standard approach usually used by most people for noise clouds has a major problem. The approach only creates Alto- and cirrus- type clouds most effectively... Which are Middle to high altitude. But luckily someone already figured it out.

There is a resource to use in Game Programming Gems 5, that does go over this, they also go over the lighting. Essentially, what the cloud layer is treated as is a really high plane that streatches pretty far.

What was done is they procedurally generated and animated a noise texture on the GPU.

They've composites multiple precomputed (I'm not sure if this is literally precomputed on disk or something. The book was written in the age of Directx 9.... so... yeah. I'd bet you can compute it on the GPU and cache it) noise textures together at different octaves and weights.

Octaves controls the details, with each octave adding more and more detail. They've stopped at 8.

Cloud lighting is a tad bit tricky, and it might just be easier to look at the code then to explain.

Hi Willywill,

I think you and I might be using the same sky implementation (Bruneton) for our engines. It definitely produces really great looking skies and makes night/day transitions painless, but obviously leaves something to be desired when it comes to clouds and anything else in the sky. Fortunately there are a couple of way you can address this, from very simple to quite complex.

The simpler solutions would be either something like Tangletail suggested, or a similar implementation to these two rastertek tutorials:

http://www.rastertek.com/tertut11.html

http://www.rastertek.com/tertut12.html

The gist is, you use a noise texture tiled over a large plane in the sky to give the illusions of clouds floating above, or even a few different ones to modulate each other and create the illusion of clouds forming and dissipating. Tangletail mentioned the limitations this has, in that the clouds generally look like altocumulus (puffy) or cirrus (wispy) clouds. In other words, you won't get an intimidating supercell rolling in with these implementations.

There have also been a few articles in more recent GPU Pro books (I want to say 5, but it could be one of the older ones), that improved a bit on the method above for screen-space clouds, but the results still seemed a bit limited.

In most of the above solutions, the results are best if viewed from the ground. If you want to leave the ground and fly alongside or above the clouds, you'll likely be switching to billboards. http://www.gamasutra.com/view/feature/2021/let_there_be_clouds_fast_.php?print=1

Fortunately, there's another alternative that I'm aware of (and currently testing out) that will be in this year's GPU Pro 6. These clouds take into account many of the same things the atmosphere implementation does, including multi-scattering, and look to give pretty decent results. You can fly over and around them and they still render properly. There's a video at the bottom of the Intel page (below) where you can see them in action. They're not perfect, but I certainly think they're visually a step above previous implementations.

https://software.intel.com/en-us/blogs/2014/08/31/cloud-rendering-sample-updated

https://github.com/gametechdev/cloudsgpupro6

Edit: Formatting and links

I have this webpage saved, maybe you'll find something useful there: http://vterrain.org/Atmosphere/Clouds/

I'm the author of the tech rendering the clouds presented in this video:

And I did it the way you speak about up in the first post, but I tell you right away, I'm pretty sure you do not want to invest the time necessary to obtain great results if you don't have piles of money, or free time, or maybe a sleep deprivation syndrome or something like that that could allow you to over-engineer your product.

Otherwise, go for a library, if you find one, or do something much simpler. For example, do you need dynamic ? You can cut on the features prior to falling into feature creep. This is a sound software engineering advice.

You could use artist authored ellispoidal mesh shapes that you render one-sided to get you some support for fragment shaders, and render them from back to front, then invent some just-about-right shader to get the scattering believable from where your sun is at this moment.

But going the full road of ray marching in shaders is calling for weeks of struggle and tight hardware limitations, even today...

vtio0JG.jpg

Haha thanks guys,

After testing the waters I think I have come up with a few ideas. I really appreciate all of your input.

What I have decided to do after a couple of days of research is use 2D fractional browning motion noise. The clouds only really need to be 2D, and I really should have mentioned that in the OP.

As of now I have a 2D noise function that can generate x amounts of octaves on the GPU. With this information I need to project it in the sky in such a manner that it looks believable. My sky shader uses a bit of a hack to fake the earths curvature. I tried using the same method and got weird seems in the center of the sky and clouds would peel apart and come out from there. I can always just resort to a 2D plane of course.

One last thing I struggled to find is how to create realistic cirrus clouds. My end result I'm looking for maybe 2 layers of these clouds, some very high altitude clouds and lower altitude cumulus ones. I have yet to find sufficient enough research on cirrus clouds.

PS: Your video looks amazing Lightness, I actually have been following that software for quite some time!

Do you have any advice for the shading aspect of clouds? Also any tips for night time sky rendering? My sky lacks that as of now.

This topic is closed to new replies.

Advertisement