/pathtracer

A simple, naive path tracer in JavaScript

Primary LanguageJavaScript

JavaScript Path Tracer

A very simple path tracer in the browser with zero dependencies.

Path tracing is a technique that simulates the behavior of light to render photorealistic images:

output

Scenes

Features

  • Unbiased monte carlo integration
  • Adaptive sampling
  • Russian roulette
  • Physically based materials
    • Fresnel reflection, transmission, absorption, diffusion
    • Color, index of refraction, gloss, transparency, separate fresnel channels, metals
  • Arbitrary light sources
  • Physically based camera
    • sensor, aperture, focus, depth of field
  • Antialiasing
  • Spherical environment maps

Code

The renderer is about 430 lines written for readability, not terseness. The core components of any monte carlo path tracer are its trace function and Bidirectional Scattering Distribution Function (bsdf).

Running locally

$ git clone https://github.com/hunterloftis/pathtracer.git
$ cd pathtracer
$ yarn install
$ yarn start
$ open localhost:8000