Caustics

Deterministic path tracing · Ruby

Follow the light.

A pure Ruby path tracer and teaching example for cameras, materials, textures, and acceleration.

gem install caustics

A scene, in raysRuby reference engine

A renderer you can inspect.

Build scenes from small parts, render repeatable samples, and compare backends.

01

Compose geometry

Trace spheres, planes, triangles, and quads through a BVH.

02

Work with materials

Use Lambertian, metal, dielectric, emission, and image textures.

03

Render repeatably

Deterministic sampling, depth of field, and process workers where fork exists.

A small first step

Start with one example.

Install the gem, then follow the project guide for platform requirements and the full API.

Read the installation guide ↗

require "caustics"

scene = Caustics::Scene.build do
  sphere center: [0, 0, 0], radius: 0.5,
         material: lambertian([0.8, 0.2, 0.2])
end

Caustics.render(scene, width: 320, height: 180,
                spp: 16, workers: 4).write("out.png")