Ray Marcher§


Implementation Details§

The ray marcher above is being rendered in real-time in a WebGL2 context with a fragment shader written in GLSL; you can also rotate the center object with your mouse.

For performance reasons, the marcher is rendering to a 360 x 360 viewport that is upsampled to 720 x 720. To mask the blurriness and aliasing from upsampling and Monte Carlo, I used a dither filter by Shorakie on Shadertoy.

The shader does 12 passes (ray bounces) per fragment; for dielectric materials I implement a Monte-Carlo approach to choose whether to reflect or refract. As for the BRDF, I used the Cook-Torrence specular model combined with the normal Blinn-Phong diffuse.

The geometry is generated implicitly via signed distance functions (SDFs). With SDFs, we can use the finite difference method to quickly approximate the gradient of the apparent surface. Another benefit is that we can apply interpolation on the basic binary operations from constructive solid geometry (CSG); the consequence is that we can create complex smooth (sometimes organic like) geometries.

Some other features I intend on implementing:

  • Burley (Disney) diffuse BRDF
  • Volume Transluency (BTDF)
  • Subsurface Scattering (BSSRDF)
  • Bidirectional Path Tracing/Photon Mapping
    • Caustics