Skip to content

tantaouibahaa/ray-tracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ray-tracer-hs

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.

what it can do

  • 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

scenes

There are 10 built-in scenes you can render. Here are some of them:

Perlin Spheres Simple Light
Perlin noise spheres Emissive lighting
Cornell Box Glass Final Scene
Cornell box with glass Final scene -- a bit of everything

building & running

You'll need GHC and Cabal. Then:

cabal build

Pick a scene (1-10) and an output file:

cabal run ray-tracer-hs -- 1 bouncing_spheres.ppm

The 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.

About

Ray Tracing in One Weekend in Haskell

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors