A physically-based software path tracer written from scratch in Rust.
A software path tracer written in Rust from scratch. rachit-pt generates images of 3D scenes by simulating the physical behavior of light, implementing a recursive ray tracing algorithm with global illumination.
Example render with HDR skybox and depth of field. Render time: 01:31:56
glam crate for high-performance vectorized operations.The engine is structured into focused modules:
scene.rs: Manages the world state, camera setup, and HDR texture loading.geometries.rs: Defines the Ray structure and handles mathematical intersections. Currently supports mathematically perfect sphere intersections by solving quadratic equations.materials.rs: Implements light scattering logic and material properties.main.rs: The core rendering loop, configuring the camera, evaluating anti-aliased samples per pixel, casting rays, and writing output via an indicatif progress bar.The path tracer recursively computes the color of a pixel by shooting rays from the camera into the scene. When a ray hits an object, a new ray is scattered based on the material’s BRDF (Bidirectional Reflectance Distribution Function), accumulating attenuation until the maximum bounce depth is reached or the ray escapes to the skybox.
Clone the repository:
git clone https://github.com/rachitkakkar/rachit-pt.git
cd rachit-pt
Run the renderer in release mode (highly recommended for performance):
cargo run --release
The engine will render the scene and output an image file named output.png in the project root. You can monitor the progress via the integrated terminal progress bar.
rayon)