An interactive experimental pathtracer, implemented using WebGPU via the Dawn renderer.
- WGSL offset computer
- Great tool for checking correct memory layout
- Physically Based Rendering, fourth edition
- Bounding volume hierarchy
- Inverse transform sampling method
- Ray Tracing: The Rest of Your Life
- Cosine-weighted hemisphere sampling method
- scratchapixel/moller-trumbore-ray-triangle-intersection
- The Reference Path Tracer, Ray Tracing Gems II and associated code sample boksajak/referencePT
- Rng initialization
- Next event estimation (direct light sampling) method
- Crash Course in BRDF implementation
- BRDF interface
- Lambertian BRDF,
sampleLambertian
,evalLambertian
- Building an Orthonormal Basis, Revisited
- Robust orthonormal axis, implemented in the
pixarOnb
function
- Robust orthonormal axis, implemented in the
- A Fast and Robust Method for Avoiding Self-Intersection, Ray Tracing Gems
- Method for the
offsetRay
function, for preventing ray self-intersections.
- Method for the
- Sampling Transformations Zoo, Ray Tracing Gems
- The
rngNextInCone
method and source
- The
- ACES Filmic Tone Mapping Curve
- filmic tonemapping function
- Simple Analytic Approximations to the CIE XYZ Color Matching Functions
- C code for the CIE XYZ color matching functions' multi-lobe Gaussian fit
- RGB / XYZ conversion matrices
- XYZ to sRGB conversion matrix
- Sky Dome Appearance Project
- The original source of the sky and solar disk model
- The following Rust implementation serves as the basis of the much simplified C code used in this project.
- Depth precision and reverse Z projection
- Free blue noise textures
- Using Blue Noise for Ray Traced Soft Shadows, Ray Tracing Gems II
A C++20 compiler is required.
$ cmake -B build -DCMAKE_BUILD_TYPE=Debug
$ cmake --build build --target pt -- -j 32
On Windows, the platform name (x64
, Win32
, ARM64
) should be provided during configuration. CMake defaults to Win32
-- see cmake-preset-x64-arch.md for instructions on setting up a CMake Preset to force -A x64
.
$ cmake -B build -A x64 -DCMAKE_BUILD_TYPE=Debug
The shaders are appended to a header file as raw strings during the pt
build step. Updating the header file can also be invoked manually:
$ cmake --build build --target bake-wgsl
It's recommendable to build using ccache in case Dawn ever needs to be rebuilt. See ccache.md for instructions.
The pt
executable contains the path tracer. You run it by providing it with input file in the pt
file format. .pt
files are generated from a glTF file using the pt-format-tool
executable.
# Running the path tracer requires input data generated from a gltf file.
$ ./build-release/pt-format-tool assets/Sponza.glb
# Run the path tracer with the resulting .pt file.
$ ./build-release/pt assets/Sponza.pt
For validating that the bounding volume hierarchy (BVH) and it's intersection tests are computed correctly. This executable loads the specified glTF file, builds a BVH, and produces an image where each pixel is colored by the number of nodes visited for the pixel's primary ray. Running the executable produces the test image bvh-visualizer.png
.
$ ./build-release/bvh-visualizer assets/Duck.glb
Running the hw-skymodel-demo
target generates a test image hw-skymodel-demo.png
.
To run the tests, the working directory has to be in the build folder. The tests depend on assets which are copied to the build folder.
$ (cd build-debug && ./tests)
For validating that textures are loaded correctly. Loads the specified glTF model and its base color textures, and dumps the textures into .png
files.
$ ./build-release/textractor assets/Sponza.glb