Ray Tracer
A toy ray tracer for educational purposes (i.e. my own education).
- Written from scratch in Rust
- Most of the theory from Peter Shirley's Ray Tracing in One Weekend and Ray Tracing the Next Week
Live Demo (WebAssembly)
Features
- Geometries:
- Sphere
- Rectangle
- Cube
- Transformations:
- Translation
- Rotations (TODO)
- Scale (TODO)
- Shear (TODO)
- Materials:
- Lambertian
- Metal
- Dielectric
- Emitting
- Textures:
- Uniform
- Checker
- Gradient (TODO)
- Image (TODO)
- Perlin (TODO)
- Cameras:
- Perspective
- Orthographic (TODO)
- Ray / Actor hit search
- Linear
- Binary Tree
- Octree
Usage
use Vec3;
use Scene;
use Sphere;
use Rectangle;
use Translation;
use PerspectiveCamera;
use Renderer;
use Material;
use PlainMaterial;
use LambertianMaterial;
use MetalMaterial;
use Actor;
use UniformTexture;
use Axis;
let mut scene = new;
scene.set_background;
// The floor
let hitable = Box new;
let texture = Box new;
let material = Box new;
let actor = Actor ;
scene.add_actor;
// A sphere
let hitable = Box new;
let hitable = Box new;
let texture = Box new;
let material = Box new;
let actor = Actor ;
scene.add_actor;
// A light
let hitable = Box new;
let hitable = Box new;
let texture = Box new;
let material = Box new;
let actor = Actor ;
scene.add_actor;
// Set up the camera
let width = 320;
let height = 180;
let aspect = width as f64 / height as f64;
let mut camera = new;
camera.set_fov;
camera.set_position;
// camera.set_direction(&[0.0, 1.0, 0.0]);
camera.set_lookat;
camera.set_up;
camera.set_fov;
// Set up the renderer
let samples = 256;
let max_reflections = 8;
let antialiasing = false
let renderer = new;
// Process the image
let image = renderer.render;