Skip to content

uros117/cloud-rendering

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Real-Time Cloud Rendering Techniques in Unity

A master thesis implementation of physically-based volumetric cloud rendering in Unity, featuring advanced light scattering models and performance optimizations.

Overview

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.

Key Features

🌥️ Physically-Based Rendering

  • 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

🚀 Performance Optimizations

  • 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

🎨 Artistic Control

  • Vertical density profiles using AnimationCurve
  • Customizable cloud boundaries with soft falloff
  • Separate control for forward/backward scattering parameters
  • Real-time preview in Unity Editor

Technical Implementation

Architecture

The system consists of several key components:

  1. CloudNoiseComputeShader.compute - GPU-based 3D Perlin noise generation
  2. CloudShaderV4.shader - Main volumetric rendering shader
  3. Perlin3DGenerator.cs - High-level interface for noise generation
  4. CloudNoiseComputeManager.cs - Compute shader management
  5. NoiseConfiguration.cs - ScriptableObject for noise parameters

Shader Evolution

  • 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

Performance Results

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

Full Frame Rendering

Full Frame Clouds Clouds covering most of the viewport - maintaining 73.5 FPS

Partial Frame Rendering

Partial Frame Clouds Partially visible clouds - achieving 120.3 FPS

Final Implementation Result

Final Result The final implementation showing realistic volumetric clouds with physically-based lighting

Setup and Installation

Requirements

  • Unity 2022.3.41f1 or newer (tested with Unity 6000)
  • Universal Render Pipeline (URP)
  • GPU with compute shader support

Installation Steps

  1. Clone this repository
  2. Open the project in Unity
  3. Ensure URP is properly configured
  4. Open the sample scene in Assets/Scenes/
  5. Adjust cloud parameters in the Inspector

Shader Parameters

Main Properties

  • _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

Optimization Parameters

  • _MinStepSize / _MaxStepSize - Ray marching step bounds
  • _TargetDensity - Density threshold for adaptive sampling
  • _BoxMin / _BoxMax - Cloud volume boundaries
  • _BoxFalloff - Edge softness

Future Work

  • 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

References

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"

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published