Saturday, June 17, 2017

Procedural Clouds in Tiled Terrain

I've shown tiled terrain clouds in many screenshots over various blog posts, but I've never had a post that shows off the different types/layers of clouds. The 3DWorld sky is rendered back to front as several layers:
  • Blue sky with gradient for atmospheric scattering effect (day) / starfield (night)
  • Sun flare when the sun is in view (day) / moon (night)
  • Fog/haze layer that increases in intensity with distance to blend the terrain with the sky
  • Procedural 2D wispy cloud plane layer that casts shadows on the ground
  • Procedural volumetric 3D clouds that move with the wind
Both cloud layers are drawn using screen aligned quads and noise evaluation in shaders on the GPU. The 2D cloud layer casts shadows on the terrain and grass by tracing a ray from the sun to the point on the ground and intersecting it with the cloud plane to compute light intensity. I haven't figured out how to efficiently produce shadows for the 3D cloud layer. The two types of clouds use different lighting calculations because the shaders have access to different types of data. For example, the cloud plane doesn't have local cloud density information, so it can't compute volumetric lighting like the 3D cloud system can. They don't always blend together perfectly, but in most cases it looks good enough.

3DWorld has a set of config file parameters, key bindings, and UI sliders to control the amount of clouds on the 2D and 3D layers. Clouds are also affected by weather conditions such as wind, rain, and snow. I've added an "auto" mode with day/night cycle that dynamically varies the weather and cloud cover over time to simulate a real environment.

Here is a set of screenshots showing the various weather and cloud conditions that can be selected. I've turned off the birds in the sky for most of these images so that the clouds can be seen clearly.

Sunny day with sun lens flare and minimal cloud cover.

Light, wispy, high clouds, with distant fog.

Medium wispy clouds and haze. These clouds cast dynamic shadows on the ground.

High, dense clouds, with small areas where the sun peeks out.

Scattered small 3D cloud puffs.

Mixed 3D low lying volumetric clouds and high 2D cloud layers.

Heavy cloud cover with mixed cloud types. The lighting doesn't really match between cloud types.

Storm clouds with rain. Are those city buildings in the background?

Clouds colored red at sunset.

Night time clouds in a starry sky.

No comments:

Post a Comment