Skip to content

ModPhoenix/ray_tracer

Repository files navigation

Ray tracer

Ray tracer written on Rust, based on the book "The Ray Tracer Challenge" by Jamis Buck.

What can the ray tracer do currently?

For now it can render scene using virtual "world" and camera into .ppm image format. World can hold one light source and any number of graphic primitives.

You can apply various transformations and material settings to the object. All of these factors will affect the final pixel color in the final picture.

Available graphic primitives

  • Sphere
  • Plane
  • Cube
  • Cylinder
  • Cone

Examples of rendered scenes

Cylinder and Cone Two mirrors in front of each other Reflection and Refraction and Cubes Reflection and Refraction Three spheres on a plane with patterns Three spheres on a plane

Getting started

You can customize the scene in src/main.rs file and then render an image using cargo run, image file will be named scene.png.

cargo run --release

open scene.png

Ideas

  • Scene loader from yaml config file
  • Compile into WASM and run in the Web
  • CLI
  • Make rendering multithreaded
  • Performance improvements and refactoring

Progress in the book

  • Chapter 01: Tuples, Points, and Vectors
  • Chapter 02: Drawing on a Canvas
  • Chapter 03: Matrices
  • Chapter 04: Matrix Transformations
  • Chapter 05: Ray-Sphere Intersections
  • Chapter 06: Light and Shading
  • Chapter 07: Making a Scene
  • Chapter 08: Shadows
  • Chapter 09: Planes
  • Chapter 10: Patterns
  • Chapter 11: Reflection and Refraction
  • Chapter 12: Cubes
  • Chapter 13: Cylinders
  • Chapter 14: Groups
  • Chapter 15: Triangles
  • Chapter 16: Constructive Solid Geometry (CSG)