← Projects

Renderers from Scratch

A REYES micropolygon pipeline and a BVH path tracer, both built by hand

May 2019 graphicsrenderingC++
Renderers from Scratch

Two renderers written for a graduate computer graphics course, neither of them using a graphics library to do the actual rendering.

REYES

The first is a REYES pipeline — the micropolygon approach Pixar shipped Renderman on. Surfaces are diced into sub-pixel quads, shaded, then sampled. The test scene is the usual suspects: a textured sphere, a checkered torus, a reflective sphere, a cylinder, a cone.

Render of an Earth-textured sphere, a black and white checkered torus, a mirrored sphere, a green cylinder and a brown cone on black
REYES output. The stair-stepping on the cone edge is the dicing rate showing through.
A pale sphere shaded with a fine displacement pattern, lit from the upper rightA low-polygon head model rendered in terracotta above a reflective grey floor

Path tracer with a BVH

The second is a path tracer. The interesting part was not the light transport but the acceleration structure: a bounding volume hierarchy, using the seven-dimension slab test from Kajiya’s paper.

A noisy path-traced scene: a checkered sphere lit by red, green and blue area lights above a dark slab, with a magenta bar crossing the frame
Red, green, and blue area lights on a checkered sphere. The grain is unconverged sampling.

It worked, and it was slow — one scene took twenty minutes at 1500 × 1500 with a single sample per pixel. The tree built correctly; the problem was how it built. Triangles were inserted into a sub-cell based on whether that cell contained the triangle’s centre, then the cell was grown to fit whatever it had swallowed. For a large triangle that produces a badly shaped cell, and the hierarchy stops being much of a hierarchy.

Two days of trying to fix it did not fix it. Writing that down is the useful part of the exercise: the structure was right and the build heuristic was wrong, which is a distinction worth having learned early.