Home

Awesome

Volume Cloud for Unity3D

This project won't be maintained in the future, since to work with modern Unity(HDRP, URP) there's too much work has to be done. And I have no intention to make it look better or more features either(I mainly use UE4 for now).

But still, if you have any idea or problem about volume cloud, I'm glad to hear them and share my thought!

Cloud at dawn.
Cloud forms a hole in the sky.
A huge cloud at distant.
Cloud view from above. With the hi-height(name from hi-z since they're similar) technique, a much larger view range could be used when rendering cloud. The screenshot is rendered with my atmosphere scattering system(Here)
(The ap system is just my hobby project, not optimized at all. It's included in this repo, use it at your own risk).

Volume Cloud for Unity3D is a plugin for rendering cloud using raymarch. For now only compatible with standard rendering pipeline.

Quick startup

Clone the repo, find three screenshot scenes under folder in Assets/VolumeCloud/Example, and you should see the cloud right away.

Performance

The benchmark here is done in Unity Editor (Sorry for my lazyness), on my laptop with GTX 1060 6G.

The time is measured from stats panel in Game window.

Two tables are listed, with the first set to same options used to render screenshots at top, to show the performance under generic usage.

SceneQualityDownSampleHi-Height enabledTimeComment
Screenshot1LowHalfTrue1.0ms
Screenshot2LowHalfTrue1.0ms
Screenshot3LowHalfTrue1.1ms
Screenshot4LowHalfTrue5.0msAbove cloud layer, many hi-height lookups

Here the second list is set to render at full resolution, to better show how each option affects performance.

SceneQualityDownSampleHi-Height enabledTimeComment
Screenshot1LowFullTrue9.0ms
Screenshot1LowFullFalse7.2ms
Screenshot1HighFullTrue10.0ms
Screenshot4LowFullTrue11.5msAbove cloud layer, many hi-height lookups

Customize

This section shows you how to setup and adjust the shape and looking of the cloud to fit your own need.

Camera Script

  1. Attach VolumeCloudRenderer to your camera. It's advised to put it before any post processing scripts. Once you add the script, the values in Inspector be filled with default values, and you should see effect right away.
  2. Adjust rendering settings.
  1. Adjust cloud properties in the config file. See below.

Cloud Configuration

Most cloud properties are seprated from the script into the config asset for reuse.

The default config in example should be nice enough to use. If you want do more control, continue reading. The most important options are listed below. Other options are not important or intuitive enough.

Weather map

The weather Tex tells the renderer how does cloud formed over sky. It's most important if you want to adjust your sky.

RGB channles are used, R channel for cloud coverage. G channel for wetness, and B for cloud type(see below).

For now there isn't an automatic way to generate a weather map, just paint it yourself, or use those in example.

Height-Density Map(Idea from [4])

Height-density map describes the density of your cloud at specified height and type. X-axis for cloud type used in weather tex, Y-axis for height.

On the R channel, density is set for corresponding cloud type and height.

On the G channel, a detail value is set for corresponding cloud type and height. Higher the value, more "round" will the cloud be.

Shape / Shape-Detail / Shape-Curl

The basic idea of volume cloud rendering is raymarch though 3D cloud-like noise texture. Here two textures are used, naming base texture and detail texture. The cloud shape is formed from base texture, then subtracted by detail texture. Also, a curl noise is used to offset detail texture sampling, to provide a turbulence-like effect.

Adjust corresponding settings will affect how sampling is done.

Shape Modifiers

These are global modifiers for some values. Just leave them for 1.

Lighting

The cloud lighting contains ambient light and directional light color contribution.

Ambient color is directly added to final result no matter what.

Scattering/Extinction coefficient are used to adjust how directional light affects cloud. Extinction describes how much cloud receives light, and scattering describes how much cloud scatters the light. Extinction value should never be greater than scattering value unless you want a non-physical effect(Or, the cloud in your game can glow).

The multi-scattering section contains parameters for simulate multi-scattering effects. The idea is from [4]. Hover your mouse over the label for more info.

Lighting - Silver

This value controls how does the silver effect spread over cloud. Lower value causes silver effect more concentrated around sun and brighter.

Lighting - Atmosphere

These settings simulate aerial perspective effect for distant cloud. Cloud color is modified with following code:

float atmosphericBlendFactor = exp(-depth / _AtmosphereColorSaturateDistance);
result.rgb = lerp(_AtmosphereColor, result.rgb, saturate(atmosphericBlendFactor));

Wind

Wind effect simulates the cloud moving by rotating the noise texture. So the overall cloud position won't be changed.

Known issues

Nothing yet.

TODO

References

[1]The Real-time Volumetric Cloudscapes of Horizon: Zero Dawn
[2]Nubis: Authoring Real-Time Volumetric Cloudscapes with the Decima Engine
[3]TAA from playdead
[4]Physically Based Sky, Atmosphere and Cloud Rendering in Frostbite
[5]Cool TAA history clip from zhihu [6]Bilateral upsample code from SlightlyMad/VolumetricLights

Implementation Details

If you're intersted in how volume cloud is implemented, see the references. Or if you're intersted at what improvements I made and how, refer to the IMPLEMENTATIONDETAIL.md at root folder.

History.

18/4/15 - Fixed "band" glitch.
18/7/7 - Added low-resolution rendering.
18/10/28 - Added Height-Density map from [4]
19/3/2 - Added depth estimation stuff, reduced blur problem when rotating camera.
19/3/4 - Rewrite lighting code, using methods from [4], it should be very "physically based" now.
19/5/18 - Rewrite raymarch and TAA. The 4x4 pattern is obsoleted. A full-screen raymarch with much lower sample count and temporal reprojection is used now.
19/5/31 - Hi-Height technique implemented.
19/6/25 - Rewrite shape function, the "cauliflower" shape is more visible now. Fixed object edge glitch when downsample is used.