webgpu-pt

monte carlo path tracer
Contents

README.md

2.8 kB
 1### Overview
 2
 3An interactive path tracer impemented in WGSL. Supports multiple sampling methods, physically based materials including microfacets, and realistic light sources. Primarily written to explore WGSL and the WebGPU API. So it takes some shortcuts and is pretty straightforward.
 4
 5This is a GPU "software" path tracer, since there is no hw-accel using RT cores, it contains manual scene intersections and hit tests.
 6
 7- Single megakernel compute pass, that blits the output to a viewport quad texture
 8- A singele static SAH split BVH is constructed on the host
 9- Expects GLTF models, since the base specification for textures and PBR mapped pretty nicely to my goals here. So roughness, metallic, emission, and albedo. Textures and the normal map
10- A BRDF for these material properties, pretty bog standard. Cosine weighted hemisphere sample for the rougher materials and a GGX distribution based lobe for the specular. A naive 0.5 mix on the to for the material lobe selection and PDF.
11- There is no support for transmission, ior, or alpha textures
12- Balanced heuristic based multiple importance sampling along with two NEE rays. One for direct emissives and another for the sun
13- Uses stratified animaited blue noise for all the screen space level sampling and faster resolves.
14- Contains a free cam and mouselook, typical `[W][A][S][D]` and `[Q][E]` for +Z, -Z respectively. `[SHIFT]` for a speed up.
15
16### Local setup
17```
18npm install 
19npm run dev
20```
21`/public` should contain the assets. Just compose the scene manually in `main.ts` position, scale, rotate.
22
23###  To-do
24- Direct lighting NEE from an HDR equirectangular map
25
26### Resources
27- [WebGPU specification](https://www.w3.org/TR/webgpu/)
28- [WGSL Specification](https://www.w3.org/TR/WGSL/)
29- **Jacob Bikker:** [Invaluable BVH resource](https://jacco.ompf2.com/about-me/)
30- **Christoph Peters:** [Math for importance sampling](https://momentsingraphics.de/)
31- **Jakub Boksansky:** [Crash Course in BRDF Implementation](https://boksajak.github.io/files/CrashCourseBRDF.pdf)
32- **Brent Burley:** [Physically Based Shading at Disney](https://media.disneyanimation.com/uploads/production/publication_asset/48/asset/s2012_pbs_disney_brdf_notes_v3.pdf)
33- **Möller–Trumbore:** [Ray triangle intersection test](http://www.graphics.cornell.edu/pubs/1997/MT97.pdf)
34- **Pixar ONB:** [Building an Orthonormal Basis, Revisited
35](https://www.jcgt.org/published/0006/01/01/paper-lowres.pdf)
36- **Uncharted 2 tonemap:** [Uncharted 2: HDR Lighting](https://www.gdcvault.com/play/1012351/Uncharted-2-HDR)
37- **Frostbite BRDF:** [Moving Frostbite to Physically Based Rendering 2.0](https://media.contentapi.ea.com/content/dam/eacom/frostbite/files/course-notes-moving-frostbite-to-pbr-v2.pdf)
38- **Reference Books**: Ray tracing Gems 1 and 2, Physically based rendering 4.0.