This is an implementation of the ray tracer introduced in Peter Shirley's ray tracing book series.
It's implemented in a brute-force way, so rendering even a 480P image can possibly take hours. However, it does contain a few interesting techniques in computer graphics.
The images generated are in .ppm
format, so you might want a ppm viewer to view them.
To build the project, run make
in root directory, where the executable will be located.
To render the image, run ./raytracer > <file-name-of-your-choosing>
. Note that the image must be in .ppm
format.
Objects are geometries that can be added to a scene and get rendered. They include
- Spheres
- Moving shperes
- Planar rectangles
- Cuboids
The material of an object decides the way rays scatter on their surface (or inside the object). They include
- Diffuse material. Rays have equal possibility to scatter in every direcition.
- Matal. Rays will be reflected, but not strictly adhereing to Snell's Law due to fuzziness.
- Dielectric. Rays can either be reflected or refracted.
- Light. Light sources don't scatter rays. They change the color of rays hitting the light source object.
- Constant medium. Rays don't necessarily get scattered on the surface. They can enter the inside of the object, but may be scattered at any moment until they're out again.
The texture of an object decides the change of color for rays hitting the surface. They include
- Solid color. Just one color, plain and simple.
- Checker. Self-explanatory.
- Perlin noise. It utilizes a few randomization techniques to implement a repeatable black-and-white pattern that resembles noises on a television.
- Image. It maps an image to the surface of the object.
Visual effects make the image more realistic. They include
- Antialiasing
- Defocus blur (Depth of field)
- Motion blur
The ray tracer adopts bounding box hierarchy to accelerate rendering, especially for scenes containing dense, small objects.
- Checker texture
- Perlin texture
- Cornell box
- Cornell box with smoke
- Earth
- Light source
- Final scene of the first book
- Final scene of the second book