Skip to content

A compute shader based path tracer implemented in the Godot game engine

License

Notifications You must be signed in to change notification settings

FrancoYudica/ComputePathTracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ComputePathTracer

A compute shader based path tracer implemented in the Godot game engine

Features

Path Tracer: A compute shader based path tracer, implemented from scratch with progressive accumulation for noise reduction across frames.

Materials: Multiple material and texture types supported:

  • Lambertian (diffuse) with metallic-roughness workflow
  • Metallic materials with roughness-based reflections
  • Dielectric materials with Schlick's approximation for realistic glass/transparent surfaces
  • Emissive materials for light sources

HDRI Skybox: The renderer samples the camera's environment PanoramaSkyMaterial with configurable energy/intensity.

SAH based Bounding Volume Hierarchy (BVH): A spatial acceleration structure built on the CPU and traversed on the GPU using an iterative stack-based algorithm, dramatically reducing triangle intersection tests for complex meshes.

Texture maps: Texture mapping support for albedo, metallic, roughness, emission and normal textures.

Alpha masking: Cutout transparency support using the alpha channel of albedo textures. During ray-triangle intersection, transparent texels are discarded, allowing rays to pass through and find geometry behind them.

Depth of Field: Physically-based camera model with configurable aperture and focal distance.

Vertex Interpolation: Barycentric coordinate interpolation for smooth shading normals, vertex colors, and support for per-vertex attributes.

Anti-Aliasing: Multi-sample anti-aliasing (MSAA) with per-pixel jittering for cleaner edges.

Random Sampling: PCG-based pseudo-random number generation with proper seed management for stratified sampling and low-noise rendering.

Configurable Ray Bounces: Adjustable maximum bounce depth for controlling light transport complexity and performance.

Debug Visualization Modes:

  • Normal visualization
  • Depth visualization
  • BVH traversal heatmap for performance analysis

Gamma Correction: Proper sRGB gamma correction (2.2) applied to final output for accurate color display.

Setting up the project

The project uses C++ with the GDExtension API and SCons as the build system. For setup instructions, refer to the GDExtension C++ example on the Godot documentation.

Future work

  • Physically-Based BRDFs: Implement industry-standard BRDFs (e.g., GGX/Trowbridge-Reitz microfacet model).

  • Post processing pipeline: Bloom and glare effects, tonemapping operators (ACES, Reinhard), exposure control.

  • Importance sampling: NEE (Next Event Estimation) and MIS (Multiple Importance Sampling) for faster convergence with emissive objects and HDR environments.

  • Advanced materials: Support for subsurface scattering, anisotropic materials and clearcoat layers.

  • Instancing support

Samples

About

A compute shader based path tracer implemented in the Godot game engine

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published