A ray tracer written from scratch in Haskell, following the Ray Tracing in One Weekend book series. My first time doing anything graphics-related, honestly.
- Materials -- lambertian (diffuse), metals, dielectrics (glass), and emissive lights
- Textures -- solid colors, checkerboard patterns, image textures, Perlin noise
- Geometry -- spheres, quads, boxes, and rotations/translations of all of them
- Volumetrics -- constant density mediums (fog, smoke)
- BVH -- bounding volume hierarchy so it doesn't take literally forever
- PDF sampling -- importance sampling for cleaner images with less noise
- Motion blur -- moving spheres between frames
- Defocus blur -- depth of field / bokeh
There are 10 built-in scenes you can render. Here are some of them:
![]() |
![]() |
| Perlin noise spheres | Emissive lighting |
![]() |
![]() |
| Cornell box with glass | Final scene -- a bit of everything |
You'll need GHC and Cabal. Then:
cabal buildPick a scene (1-10) and an output file:
cabal run ray-tracer-hs -- 1 bouncing_spheres.ppmThe full list:
| # | Scene |
|---|---|
| 1 | Bouncing spheres |
| 2 | Checkered spheres |
| 3 | Earth |
| 4 | Perlin spheres |
| 5 | Quads |
| 6 | Simple light |
| 7 | Cornell box |
| 8 | Cornell smoke |
| 9 | Final scene |
| 10 | Cornell box with glass |
Output is PPM format. You can convert to other formats with ImageMagick or just open it with Preview on macOS.



