Skip to content

Mourtz/raytracer-0

Repository files navigation

Advanced WebGL2 Pathtracer with ReSTIR and MIS

This is a fully functional real-time pathtracer featuring advanced lighting algorithms. It is entirely written in JavaScript, using the WebGL2 API to carry out all computations on the GPU. The renderer is highly modular, allowing users to toggle sophisticated features like Multiple Importance Sampling (MIS), ReSTIR (Reservoir Spatiotemporal Importance Resampling), procedural sky, and various sampling strategies.

On low end devices, the GLSL compiler is usually crashing due to the large amount of code that is being passed by the main fragment shader. Of course the amount of computational power needed to run the renderer depends on the complexity of the scene. On my current system I have a RTX 3070m (8GB VRAM) and the driver doesn't crash regularly, any graphics card with 10 TFLOPS in FP32 and with sufficient VRAM should be running fine.

It seems to be working fine on Windows using Angle, Google Chrome is highly suggested as it gives me the lowest render times among of all the browsers I 've tested.

List of features

  • generative texture mapping
  • procedurally generated textures
  • supports color, emission and specular textures
  • supports raytracing of Quadric & Euclidean surfaces
  • supports raymarching of signed distance fields
  • multiple light sampling
  • Reinhard tone mapping
  • cosine weighted importance sampling
  • MIS (Multiple Importance Sampling)
  • ReSTIR (Reservoir Spatiotemporal Importance Resampling)
  • Homogeneous participating media
  • Spectral

Demo (Let it fetch all the required data before hitting the render button!)


@ToDo List

  • bump mapping
  • split the main shader into three (1st for eye path tracing, 2nd for light path tracing, 3rd for merging the paths) to reduce the probability of the driver crashing during compilation.
  • HLBVH support(some work has been done already)
  • Heterogeneous participating media
  • volumetric SDF
  • BSSRDF

Gallery

alt text

alt text

alt text

alt text

Show more

References & Credits

Research Papers

  • ReSTIR: "Spatiotemporal reservoir resampling for real-time ray tracing with dynamic direct lighting" (Bitterli et al., 2020)
  • Multiple Importance Sampling: "Optimally combining sampling techniques for Monte Carlo rendering" (Veach & Guibas, 1995)
  • Power Heuristic: "Robust Monte Carlo methods for light transport simulation" (Veach, 1997)

Inspiration & Techniques

  • iq - Inigo Quilez (SDF techniques and noise functions)
  • Toshiya Hachisuka - Advanced light transport algorithms
  • reinder - Reinder Nijhoff (WebGL raytracing techniques)
  • erichlof - Erich Loftis (Real-time pathtracing implementations)