Website powered by

Dynamic skybox rendering system in Unity Engine

This is a short breakdown of how I created realtime skybox/clouds system for Gloria Victis game.

It's a mix between volumetric clouds system and regular skybox texture rendering. I wanted to avoid blurry look of purely volumetric system but also have dynamic sky that is not only randomly generated but also in constant motion. I also wanted to reduce realtime rendering overhead to minimum so the sky is actually entirely 2D.

The clouds are dynamically lit by sun depending on it's apparent location in the sky and shadowed using shadowmap computed similarly how engine is doing it for directional lights. Full day-night cycle is supported and clouds move with wind. Once clouds move beyond horizon they disappear and new clouds are generated on the other side of the sky.

The cloud shapes are generated by stamping small circular chunks over larger texture buffer asynchronously (as much as it is possible using Unity's AsyncGPUReadback API for GPU operations and Jobs system for CPU and spreading overhead from main thread over many frames). After first buffer finishes rendering, second buffer is being computed with clouds offseted in direction of current wind vector. From this point the process of blending two sky buffers happens using motion vectors calculated earlier. This creates appearance of clouds motion despite the fact that it's only 2 frame animation. During blending third buffer is being rendered offseted once again by current wind and when blending finishes last buffer in the blending process will blend with this new third buffer.
This loop continues indefinitely.

Animation showing how shadowmap (visibile in the lower right corner) affects lighting.

Day-night cycle. Artifacts visible in a form of blinking cloud fragments are coming from a fact that in order to record this video I had to artifically force rendering every frame which is something this system was not designed to handle.

Shading is dynamically computed on individual cloud particles using custom shadowmap of the entire sky rendered before this step.

360 View, without post-process effects.

In game screenshot

In game screenshot

Couple of examples of cloud chunk textures and a normal map. They are highely compressed in this image and I adjusted them a little to better demonstrate variety of shapes.

Couple of examples of cloud chunk textures and a normal map. They are highely compressed in this image and I adjusted them a little to better demonstrate variety of shapes.