You can get Voxel Farm now. For more information click here.

Monday, April 15, 2013

Some Clouds

Clouds come in many forms. When it comes to generating them it seems there is no silver bullet method. Part of the problem is we call clouds to just one aspect of a more general process: water particles suspended in air. This could also be fog, or the misty breath coming out of trees and plants in a jungle. This is what the initiated in this occult science call "The Participating Media".

I decided to tackle this problem by having different layers working together. Which layer to do first? Even in the highest places in Earth, it is likely to find a layer of clouds over your head. I did some experiments over the weekend on how this particular layer could be rendered.

Here are a couple of early screenshots for your consideration:




It is a very simple and fast method that allows clouds to animate and evolve over time. You can go from a clear sky to a very cloudy one as well. It takes into account the sun's position and does some basic scattering and self shadowing.

These clouds are rendered in the same skydome that performs the day-night cycle, so they do not add any new geometry. This is also the problem with this method: This is a flat layer. There is the impression of volume thanks to how the light is computed, and this trick holds as long as the clouds do not move too fast. If you make them sprint over your head it becomes obvious it is a flat layer. You cannot also come too close to these clouds, that also kills the illusion.

For what it does, I think the method is quite neat, especially if you don't have much GPU cycles to spend in clouds. It does not use any textures or any other resources. This is 100% GPU so it would run nicely in demos or WebGL frames. I think it deserves a future technical post on its own, that of course assuming you guys like how they look.

Let me know what you think by dropping a comment.



33 comments:

  1. the clouds look amazing and a low cpu usage is always good but moutans can easaly go up to and beond! mt kinabalu is one egsample i know from exspereance. also low fog can be seen as a see of clowds if seen from a tall enuth hill. would be verry nice if there is room in the cpu cycls to make them happen.

    ReplyDelete
    Replies
    1. Yes, certainly there will be clouds under the mountains. This will be a different layer. What you see here is what always goes over mountains.

      Delete
  2. The clouds look realistic from the perception when looking from below.
    But when you are in a tall mountain, how will the clouds act, Are they flat or are they acually procedurally volumetric?

    Also i saw this stunning sky: https://www.youtube.com/watch?v=0ygZCDoCVec
    I don't know if he got any papers of it or something. But i'll reply here again if i find someting

    ReplyDelete
    Replies
    1. Thanks for the link. I knew about them. I will be using a similar approach for other layers. The results you see here are for clouds that remain far above the highest point in the terrain. More layers are coming.

      Delete
    2. Here is some info on how it is done:

      http://reset-game.net/?p=284

      Their game, Reset, is beautifully lighted.

      Delete
    3. You mention "Highest point in the terrain". Will there be a hard cap?

      Delete
    4. Not because of the clouds, but from the octree index design. The high point could be set to around 40 km, which is practical I think. It could also be a lot more, it really depends on the application.

      Delete
    5. Well, seeing as that's higher than Mt. Everest...

      I think that's fine.

      Delete
  3. I'd love a technical post on this! This will look more interesting/varied with multiple layer probably, right now it does the job, but reminds me a bit of a Bryce sky.

    I also think eventually you'll have to dedicate some geometry to a few billboard clouds here and there. I'll give you a silly example but it's worth a look anyway: an old Nintendo game called Wind Waker was set at sea and had lovely skies. I ripped the textures and they had like 2 microscopic .PNGs, one for the particles and one for the horizon clouds. BUT, they did they job because they kept overlapping and adding to each other. If they did that on Gamecube you can do a better looking version here for sure.

    The horizon cloud image also contained the haze gradient I think. Anyway, those clouds were set around the scene and they probably had two layers of them offset at different speeds, so when added to each other it looks like clouds changing shape and moving continuously. Worth a look.

    Lastly, your low horizon color in the second shot looks very white, too much in my opinion. I say find some nice gradients here and there and cycle through those, you could randomise the sunset colors for each day too, to add variety. Have fun with the colors, forget the technical papers on that one!

    ReplyDelete
  4. Perhaps you could use a variation of your tree foliage generator to make some low fluffy clouds?

    ReplyDelete
    Replies
    1. Yes, billboards are good for that.

      I am more inclined into using the natural octree-like structure of the scenes to have as few planes as possible. I will talk more about when I know.

      Delete
  5. Ps. are you using a Gamma gradiaent for the horizon color? perhaps a saturation gradient would work better ???

    ReplyDelete
    Replies
    1. I am not using color gradients at all. The colors you see are produced by some approximated physical model to how different light frequencies diverge when traveling over the atmosphere.

      So at no point I have something that says "white" or "pink" or "orange". It is really physical properties like size of the atmosphere layer, radius of the planet, etc.

      Delete
    2. This comment has been removed by the author.

      Delete
    3. So that means you had to determine the size of the planet, how big did you decide to make it? Earth-like? (I know this isn't actually land-mass based, but still a fun little thing to know =P)

      Delete
  6. Ok perhaps I should have used the word "function" instead of "Color".

    ReplyDelete
  7. Miguel, I have been following your blog for several months and I appreciate the natural and balanced realism that you always seem to aim for. Some people say the popular game engines like Cry and Unity are getting very "realistic," but I find them to be very plastic-y, like junk food for the eye.

    As you add, modify and remove elements of your models, how do you make sure the changes increase the realism? In other words, do you ever try to match your results to photos, or is it all just based on feel? For instance on these clouds, are you testing them against anything?

    ReplyDelete
    Replies
    1. I honestly do not have an answer. What you see here is programmer art. I trust experimented designers can make this look 10 times better.

      I try to keep the algorithms broad enough so they can produce a realistic output, but also a more stylized look like DOTA or WoW.

      All the images I post fall into the realistic look and I think there is a good reason for that. I believe if you can produce realistic content, you can do stylized, but not the other way around.

      We can all agree for the most part on how reality is supposed to look. So it is a way to know you have an "obedient" algorithm that is doing what it is meant to do.

      I do use a lot of pictures for reference. Also my wife and friends will come and check on the stuff. Since they do not play games they have no problem pointing out what is wrong.

      Delete
    2. That's not programmer art, that's Graphical programmer art! XD If it was programmer art it would be ASCII or made in msPaint =P. (Hmm... how would your world look if you replaced all the textures with ASCII characters? XD)

      Delete
  8. Reading from gfx programmer perspective, the more technical details the better. Maybe even small demo on ShaderToy?

    ReplyDelete
  9. For a top layer they certainly look good to me. And don't put yourself down, this is not just programmer art - you clearly have a very solid graphical background in addition to being a c++ genius. I think flat skydome clouds isn't an issue if you're putting further layers in below. I know your modus operandi doesn't include licencing libraries from other companies (where's the fun in that eh?!) but I'm guessing you're familiar with the truesky libraries from simul http://simul.co.uk/truesky Are you aiming for fully volumetric clouds? Not just moving, but morphing over time; lit and rendered so they can realistically envelop mountains, create world shadowing/light shafts and all that cool looking stuff? I got the arma III alpha, and flying in and out of fully volumetrically rendered clouds for the first time really was quite exhilerating! I suppose it depends on whether you're planning to have any action take place up in the atmosphere - if you're just looking up at distant layers from the ground all the time, you can get away with billboard clouds, because you're never close enough to them for the illusion to break.

    ReplyDelete
    Replies
    1. I don't put myself down. I am happy with my skills. At the same time I need to pay respect to the real graphic designers out there.

      I plan on adding new volumetric layers so you can get inside clouds or over them.

      Delete
  10. I think what you have here will work great for the extremely high, upper atmosphere cloud deck. After you work out some of the other lower clouds, I would suggest using this upper set of clouds sparingly.

    The highest clouds have a few "types" and formations of clouds, like cirrus and are very tenuous, due to the thinness clouds that form at those elevations. You could mimic real life with a couple of noise typs that mimic those types of clouds.

    Here's a crude, but clear outline of the three main areas of cloud formation:
    http://pvs.kcc.hawaii.edu/images/navigation_and_weather/cloud_forms.gif

    Below is a good example of how some, or all of these exist at multiple levels in some skies:
    http://aultparksunrise.files.wordpress.com/2012/03/079_03_sunrise_over_valley_4nn.jpg

    1) The top right of the image = light Cirrus wispy clouds, so high in the atmosphere that they are still illuminated by the setting sun.

    2) Middle section of image = Altocumulus, taking on the setting sun, but lower than the cirrus, creating that unique alto cumulous pattern.

    3) Bottom section of image = Stratocumulus heavy clouds, often where the actual rainstorms are happening.

    The beauty of our skies are that you can create a huge variety of skies by just varying the composition, and frequency of a few layers of clouds:
    - Sunny Desert = High wispy sporadic clouds only.
    - Tropical Good weather = High and medium puffy Cumulus clouds.
    - Rainy day = Heavy numbostatus and puffy Cumulous above them when the weather breaks.

    ------

    From a technical front: I hope you are able to do something more 'volumetric' than just a couple of cloud planes. I think your engine, and worlds they can create, will benefit greatly from tackling this the way you do everything, with realism in mind.

    I'm actually surprised that voxels don't lend themselves to doing clouds, just at a coarser scale than the ground -- being a 3D data representation and all. But perhaps it's more the computational rendering issues that are a constraint.

    I love what you've done, and even if you can't crack this before a demo, I know we'd all be fine with what you have now! :)

    ReplyDelete
    Replies
    1. Voxels are a perfect match for clouds. I will use them for cloud layers at the camera level or below it.

      Now, for an always distant layer like this one in particular, they are an overkill. So instead of having voxels covering the entire cloud space, it is better to split it into zones. One zone can use voxels at higher resolutions if the other zone does not use voxels at all.

      Delete
    2. Just when you figure '3 standard cloud types are good enough' nature throws out a crazy lenticular cloud or other type of cloud formation that is so "other worldy" that if it was actually in a video game people would say that it was too far fetched!

      Like this one:
      http://apod.nasa.gov/apod/image/1304/hoodcloud_canales_1700.jpg

      Delete
    3. That's the curse of being any person who works with any virtual medium (Be it Games, Movies or radio) If the people don't believe it to be real, even if it is very real, it's not real.

      Delete
    4. that's an amazing image - like you say, if it was rendered in a virtual world, it would be criticized as being fake! There's a real sense of wonder, almost magic at seeing something in nature that you know very few people have ever witnessed, something that's so at odds with everything you expect... I sometimes get a mild version of that feeling playing minecraft when I come across a spectacularly weird area of mountain/cave terrain. Hunting them out becomes part of the thrill of the game.

      Delete
    5. Completely agree with you John. I believe that the the best part of playing in a procedurally generated world, is finding those WOW moments.

      Delete
  11. Beautiful, totally agree, and can't wait. The lightweight layer for the highest clouds, that you have done here, will add so much depth when the other layers are in.

    Goodness this will be fun to see! Awesome stuff as always.

    ReplyDelete
  12. Looks cool. I'd love to see some technical details.

    ReplyDelete
  13. I need the next part "volumetric clouds" for my own project ... I would love to see a brief overview of how this problem is solved as my engine is also voxel based :)

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. I think if you add water (liquid) and the rainfall, will be copy of the wonderful world without people))

    ReplyDelete

There was an error in this gadget