A real time dynamic global illumination renderer based on surfel. Final project of University of Pennsylvania's CIS 565 GPU Programming and Architecture class. Written by Zhen Ren, Ruipeng Wang and Jinxiang Wang.
SurfelPlus is a real-time dynamic global illumination renderer built on top of NVIDIA’s vk_raytrace framework. Using Vulkan ray tracing and surfel-based techniques, SurfelPlus aims to deliver high-quality lighting effects with dynamic scene updates, providing an efficient solution for realistic and immersive visual rendering in real time. Click here for the project pitch PDF.
SurfelPlus utilizes surfel-based techniques to achieve high-quality and accurate lighting effects. This approach builds on the surfel GI method presented by EA SEED in their SIGGRAPH 2021 talk and SIGGRAPH 2024 talk. Originally designed for the Frostbite engine, these techniques have been carefully adapted and optimized for our Vulkan-based renderer, taking advantage of Vulkan’s flexibility and ray tracing capabilities to deliver real-time global illumination in dynamic scenes.
Surfels, short for “surface elements,” are point-like primitives that represent the surface of a 3D object. Each surfel stores key information, including position, normal, color, and other material properties, enabling efficient computation of light interactions in a scene.
In global illumination, surfels serve as intermediaries for light propagation and reflection, balancing accuracy and computational cost.
Surfel-Based Indirect Lighting
Indirect lighting is computed by storing and sharing light energy across surfels. This approach captures diffuse inter-reflections and supports dynamic scenes without requiring precomputed data, making it well-suited for interactive applications.
Lighting Integration
SurfelPlus leverages Vulkan’s capabilities for direct lighting, while surfels handle the more performance-intensive indirect light calculations. This hybrid approach optimizes rendering performance without sacrificing visual quality.
The G-Buffer Pass is responsible for capturing per-pixel information about the scene’s geometry and surface properties, which are later used in lighting and shading computations. This pass encodes data such as primitive object ID, compressed world-space normals, and other attributes necessary for the rendering pipeline.
Visibility Buffer | Depth Buffer |
---|---|
A pass that reset some counters and prepares all the buffer for later accumulation.
The Surfel Update Pass is responsible for maintaining and updating the dynamic surfel data in real time. It processes active surfels to:
Recycle expired or invalid surfels based on specific criteria, such as lifespan, distance from the camera, total surfel count, or visibility status.
Adjust surfel radius dynamically based on camera distance and scene conditions to balance performance and visual quality. The cell radius is bounded by cell size to keep surfels right in their cells.
Distribute surfels into appropriate grid cells for efficient spatial queries and interactions. Surfels would check the surrounding 3x3 cells so that surfels crossing multiple cells can be correctly recorded in each cell.
Allocate ray resources for surfel-based global illumination calculations, ensuring adequate sampling for indirect lighting. The ray allocation is influenced by surfel variance, surfel life and surfel visibility.
This pass ensures the surfel system remains efficient and responsive to scene changes, supporting real-time dynamic global illumination with consistent performance. However, surfel recycle may dispose some surfels in unseen area, causing the GI to re-converge when camera looks at them.
Pre-allocate the offset and range of cell to surfel buffer.
Populate data in cell to surfel buffer.
The Surfel Ray Tracing Pass is responsible for casting rays from surfels to compute their radiance, which is essential for indirect lighting in the scene. This pass integrates ray-guiding sampling and cosine-weighted hemisphere sampling to ensure accurate and efficient light transport calculations.
When a ray reach its maximum depth but receiving not lights, we can use the surrounding surfels to provide diffuse indirect lighting for that ray. The helps the scene to converge faster. However, if there are many surfels nearby, sampling all of them would cause a huge performance deration. Therefore, a stochastic sampling strategy would be used to limit the number of surfel samples.
Surfel Ray Updates: Updates each surfel ray with its computed radiance, direction, and probability density function for use in subsequent lighting computations. Here, we also clamps high luminance values to improve stability and avoid firefly effects in the scene.
Dynamic Adjustments: Adapts ray tracing depth based on the surfel’s activeness to optimize performance without sacrificing realism.
This pass is critical for accurately simulating light propagation in the scene, contributing to the high-quality global illumination achieved by SurfelPlus.
The Surfel Integration Pass is responsible for aggregating the radiance contributions collected by surfel rays, updating surfel properties, and sharing irradiance data among nearby surfels. This pass plays a crucial role in achieving consistent and smooth global illumination.
Radiance Aggregation: Gathers and accumulates radiance data from surfel rays stored in the memory. Each surfel would have maximum 64 rays in each frame. These rays are divided to 4 packs and each pack would contribute to the surfel irradiance using MSME. MSME algorithm would also calculate the surfel variance and accumulation weight so that surfels can be more responsive to environment change and converge in a smoother way.
Irradiance Map Update: Updates the irradiance map for each surfel, storing directional irradiance information in a 6x6 grid for efficient reuse in guided sampling. We also writes depth information into a corresponding depth map to assist with visibility checks. Radiance in each surfel
Shared Radiance Contribution: Enables nearby surfels to share irradiance data within a local spatial cell. This step accelerate surfel convergence a lot. Uses factors like normal alignment, distance, and surfel lifespan to weight contributions, ensuring consistent and plausible lighting. Stochastic sampling strategy is also applied here.
Adaptive Integration: Differentiates behavior for newly created surfels and established ones to avoid sudden changes in irradiance values. Then, we normalizes contributions across samples, ensuring accurate energy conservation.
This pass ensures that surfels maintain smooth and stable lighting across frames while leveraging shared data to enhance global illumination accuracy and performance.
The Surfel Generation Pass computes indirect lighting contributions for each pixel based on nearby surfels, updates shading information, and dynamically generates new surfels to ensure adequate coverage in the scene. This pass evaluates the lighting of the rendered image by incorporating smooth and detailed global illumination.
Coverage and Contribution Analysis: Evaluates coverage and contribution metrics of each pixel determine lighting consistency and detect potential gaps in surfel representation.
Dynamic Surfel Generation: Generates new surfels dynamically in underrepresented regions to maintain proper lighting coverage. The position, radius, and radiance of new surfels are initialized based on the scene’s current lighting conditions.
Debugging and Visualization: Here, we provide supports multiple debugging modes, including visualizing radiance, surfel IDs, variance, and surfel radius. This provides insights into surfel contributions and the overall quality of indirect lighting.
Adaptive Surfel Removal: Removes surfels in regions with excessive coverage to optimize surfel layout memory usage and computational performance.
This pass evaluates the indirect diffuse lighting using nearby surfels, while dynamically adapting the surfel distribution to maintain high-quality and uniform global illumination in real-time scenarios.
Each color cell represents one surfel
The Reflection Compute Pass computes specular reflections using RIS. It calculates accurate reflection contributions while efficiently handling complex material properties and varying surface roughness.
RIS: Implements a weighted reservoir sampling approach to select the best reflection candidate based on target contribution weights.
Reflection Computation: Traces reflection rays to gather radiance from the scene using both raw trace and surfel-based indirect lighting. The idea is similar to surfel ray trace. This approach accelerate reflection convergence surprisingly.
Without surfel indirect, max bounce = 6 | With surfel indirect, max bounce = 1 |
---|---|
From the above image, you can see the huge difference achieved by surfel indirect lighting even with only 1 bounce.
Firefly Suppression: Includes a threshold-based luminance clamp to prevent outliers (fireflies) in the reflection output, ensuring stable and realistic visuals.
This pass provides high-quality specular reflections, essential for realistic rendering of glossy and metallic surfaces, while maintaining efficiency through RIS and surfel indirect lighting techniques.
The Spatial Temporal Filtering Pass refines the specular reflection data by applying spatial reconstruction and temporal accumulation techniques. This pass ensures smooth and visually accurate reflections while mitigating noise and artifacts.
Reflection lighting in the scene
Spatial Reconstruction Filtering: Uses a neighborhood sampling pattern to collect and average reflection data from nearby pixels. Incorporates sample weighting based on BRDF contributions, material consistency, and PDF values to prioritize relevant samples.
Material Consistency Check: Ensures that only samples with matching material IDs contribute to the reflection data, preserving material-specific characteristics.
Variance Calculation: Computes the variance of sampled contributions to measure the reliability and stability of the filtered reflections.
Temporal Accumulation: Combines current filtered results with the previous frame’s reflections to enhance temporal stability and reduce flickering.
The Bilateral Cleanup Pass refines the filtered reflection data by applying a bilateral filter that considers spatial, color, and normal similarity. This pass enhances the smoothness of reflections while preserving sharp edges and important details.
Filtered reflection image for denoising
This pass ensures high-quality reflection visuals by reducing noise and artifacts while maintaining important surface details and transitions, providing a polished final image.
A ssao pass to add more realism to the scene. Use temporal accumulation to do denoising.
This pass calculates direct lighting and integrats it with indirect and reflection information that gathered from previous passes.
Information needed (material, world position, etc.) for Direct lighting was obtained and uncompressed/reconstructed from G-Buffer, then ray-query features was used to compute shading accordingly.
Direct Lighting | Indirect Lighting | Reflection |
---|---|---|
The TAA pass jitters the view frustum and strategically averges the color between multiple frames.
Position Reconstruction: Reconstruct world position using depth buffer and screen uv.
Previous Frame Reprojection: Using the view-projection matrix of last frame to calculate uv of world position of current pixel in last frame.
Reprojection |
---|
Neighbor Color Vector AABB: Sample the 3x3 neighbor color and adjacent neighbor color (surrounding pixels in “+” pattern), calculate aabb of color vector
AABB |
---|
Neighbor Color Clipping: clip the current color towards history color instead of just clamping it. In this way color from previous frame is trivially accepted to reduce ghost and smearing effect.
Clamping and Clipping |
---|
Blend and weigh history frames: Lerp between colors of past frame and this frame. Higher feedback factor will have a faster converge but will introduce artifacts.
Blend |
---|
Click here for the original PDF.
For our first milestone, we made significant progress in setting up the foundation of our renderer:
This milestone established a solid groundwork for our surfel-based GI system.
Surfel Generation | Visibility Buffer | Normal Buffer |
---|---|---|
For the second milestone, our focus is on improving the surfel system and integrating advanced features:
These improvements aim to advance the overall efficiency and realism of our renderer.
Click here for the original PDF.
For Milestone 2, we achieved significant advancements in our surfel-based GI system:
Diffuse | Surfel indirect |
---|---|
Looking ahead to Milestone 3 and the final stage of the project, our goals include:
Click here for the original PDF.
For Milestone 3, we addressed key issues identified in Milestone 2 and implemented significant improvements:
Before Milestone 3 | After Milestone 3 |
---|---|
These improvements position SurfelPlus as a highly efficient and visually robust renderer capable of dynamic global illumination with high performance and quality.
Click here for final presentation PDF.
These enhancements collectively elevate the visual quality and performance of SurfelPlus, making it a robust and versatile renderer for real-time global illumination in dynamic environments.
The TAA pass jitters the view frustum and strategically averges the color between multiple frames.
Position Reconstruction: Reconstruct world position using depth buffer and screen uv.
Previous Frame Reprojection: Using the view-projection matrix of last frame to calculate uv of world position of current pixel in last frame.
Reprojection |
---|
Neighbor Color Vector AABB: Sample the 3x3 neighbor color and adjacent neighbor color (surrounding pixels in “+” pattern), calculate aabb of color vector
AABB |
---|
Neighbor Color Clipping: clip the current color towards history color instead of just clamping it. In this way color from previous frame is trivially accepted to reduce ghost and smearing effect.
Clamping and Clipping |
---|
Blend and weigh history frames: Lerp between colors of past frame and this frame. Higher feedback factor will have a faster converge but will introduce artifacts.
Blend |
---|
Sharpen: Filter the final image with Laplace operator
No TAA | TAA (Unsharpened) | TAA (Sharpened) |
---|---|---|
Large open scene | Closed scene |
---|---|
With Glossy Indirect Lighting | Without Glossy Indirect Lighting |
---|---|
GIBS: SIGGRAPH 2021 talk
GIBS: SIGGRAPH 2024 talk
Stochastic All the Thing
Unreal Engine 5.5
SurfelGI-W298
Stochasitc Screen-Space Reflections
Ground Truth Ambient Occlusion