A master thesis implementation of physically-based volumetric cloud rendering in Unity, featuring advanced light scattering models and performance optimizations.
This project implements a sophisticated real-time cloud rendering system in Unity 3D, developed as part of a master thesis at the Faculty of Electrical Engineering, University of Belgrade. The implementation evolves through four iterations, from a simple screen-space shader to a comprehensive solution featuring physically-based light scattering and advanced optimization techniques.
- Two-lobe Henyey-Greenstein phase function for realistic light scattering
- Energy-conservative scattering based on Frostbite's approach
- Multiple scattering approximation for enhanced realism
- Adaptive shadow calculation with early termination
- GPU-based 3D noise generation using compute shaders
- Adaptive step size with lookup tables for efficient ray marching
- Predefined noise configuration system for artistic control
- LOD-based rendering with customizable quality settings
- Vertical density profiles using AnimationCurve
- Customizable cloud boundaries with soft falloff
- Separate control for forward/backward scattering parameters
- Real-time preview in Unity Editor
The system consists of several key components:
- CloudNoiseComputeShader.compute - GPU-based 3D Perlin noise generation
- CloudShaderV4.shader - Main volumetric rendering shader
- Perlin3DGenerator.cs - High-level interface for noise generation
- CloudNoiseComputeManager.cs - Compute shader management
- NoiseConfiguration.cs - ScriptableObject for noise parameters
- V1: Screen-space shader with procedural noise
- V2: Surface shader with Henyey-Greenstein scattering
- V3: CPU-based pre-computed 3D textures
- V4: GPU compute shader generation with energy conservation
Testing performed on NVIDIA GeForce RTX 3060 Ti at 1920x1080:
| Scenario | FPS | CPU Time (ms) | GPU Time (ms) |
|---|---|---|---|
| Full Frame | 73.5 | 16.49 | 12.90 |
| Partial Frame | 120.3 | 6.31 | 5.02 |
| No Clouds | 464.7 | 2.2 | 1.0 |
Clouds covering most of the viewport - maintaining 73.5 FPS
Partially visible clouds - achieving 120.3 FPS
The final implementation showing realistic volumetric clouds with physically-based lighting
- Unity 2022.3.41f1 or newer (tested with Unity 6000)
- Universal Render Pipeline (URP)
- GPU with compute shader support
- Clone this repository
- Open the project in Unity
- Ensure URP is properly configured
- Open the sample scene in
Assets/Scenes/ - Adjust cloud parameters in the Inspector
- _NoiseTexture3D - Pre-computed 3D noise texture
- _NoiseAmplitude - Overall cloud density multiplier
- _HGG0 - Forward scattering coefficient (0 to 1)
- _HGG1 - Backward scattering coefficient (-1 to 0)
- _ScatteringAlbedo - Cloud color and brightness
- _ExtinctionFactor - Light absorption strength
- _MinStepSize / _MaxStepSize - Ray marching step bounds
- _TargetDensity - Density threshold for adaptive sampling
- _BoxMin / _BoxMax - Cloud volume boundaries
- _BoxFalloff - Edge softness
- Neural Network Integration: Using generative models trained on SDF for automatic cloud shape generation
- Weather System Integration: Dynamic cloud evolution based on atmospheric models
- Mobile Optimization: Adaptation for limited hardware resources
- VR/AR Support: Optimizations for stereoscopic rendering
- Temporal Upsampling: Reduce per-frame computation cost using temporal coherence
Key papers and resources that influenced this implementation:
- Hillaire, S. (2016). "Physically Based Sky, Atmosphere and Cloud Rendering in Frostbite"
- Harris, M. J. (2003). "Real-time cloud simulation and rendering"
- Schneider, A. (2015). "The Real-Time Volumetric Cloudscapes of Horizon: Zero Dawn"
- Wang, N. (2004). "Realistic and fast cloud rendering"
This project is licensed under the MIT License - see the LICENSE file for details.