rustytracer

Crates.iorustytracer
lib.rsrustytracer
version0.1.0
created_at2025-08-30 09:53:32.520718+00
updated_at2025-08-30 09:53:32.520718+00
descriptionA high-performance ray tracer with multiple preset scenes
homepage
repositoryhttps://github.com/Aditya-1304/raytracer
max_upload_size
id1817473
size67,858
Aditya Mandal (Aditya-1304)

documentation

README

RustyTracer

A high-performance ray tracer built in Rust featuring 8 stunning preset scenes, BVH acceleration, and parallel processing for fast renders.

Rust License Version

Features

  • Blazing Fast: BVH acceleration + Rayon parallelization

  • 8 Preset Scenes: From classic to ultra-high quality renders

  • Advanced Materials: Realistic glass, metal, and diffuse surfaces

  • Interactive Menu: User-friendly scene selection interface

  • High Resolution: Up to 1400px with 300+ samples per pixel

  • Parallel Processing: Multi-threaded rendering for maximum performance

  • Optimized: 10x+ faster rendering compared to single-threaded implementations

Quick Start

Prerequisites

Installation & Usage

# Clone the repository
git clone https://github.com/Aditya-1304/raytracer.git
cd raytracer

# Run with optimizations (strongly recommended!)
cargo run --release

# Follow the interactive menu to select and render scenes

Technical Implementation

Core Features

  • BVH Acceleration: Spatial partitioning reduces intersection tests from O(n) to O(log n)

  • Parallel Processing: Rayon-powered multi-threading across CPU cores

  • Advanced Materials:

    • Lambertian (diffuse) surfaces with perfect scattering
    • Metal surfaces with configurable roughness
    • Dielectric materials with realistic refraction (glass, water, crystals)
  • Camera Effects: Depth of field, anti-aliasing, adjustable field of view

  • Optimized Sampling: Importance sampling for realistic lighting

Architecture

src/
├── main.rs           # Interactive CLI interface
├── scenes.rs         # Scene definitions and generators  
├── camera.rs         # Camera with depth of field
├── material.rs       # Material implementations
├── bvh.rs           # BVH acceleration structure
├── vec3.rs          # 3D vector math
├── ray.rs           # Ray definition and operations
├── sphere.rs        # Sphere primitive
├── color.rs         # Color handling and gamma correction
└── rtweekend.rs     # Utilities and random number generation

Usage Tips

Output

  • Images are saved as .ppm files in the project directory
  • Convert to common formats: convert image.ppm image.jpg (ImageMagick)
  • Or use online converters for quick sharing

Customization

  • Modify src/scenes.rs to create your own scenes
  • Adjust camera parameters for different perspectives
  • Experiment with material properties for unique effects

Contributing

Contributions are welcome! Here are some ideas:

  • New Scenes: Create unique ray-traced scenes
  • Performance: GPU acceleration, SIMD optimizations
  • Features: New materials, lighting models, primitives
  • Bug Fixes: Resolve issues and improve stability
  • Documentation: Improve guides and code comments

Development Setup

git clone https://github.com/Aditya-1304/raytracer.git
cd raytracer

# Run tests
cargo test

# Check code formatting
cargo fmt --check

# Run clippy for linting
cargo clippy

Acknowledgments

  • Peter Shirley: "Ray Tracing in One Weekend" series
  • Rust Community: For excellent documentation and crates
  • Graphics Researchers: Decades of ray tracing innovation

Inspiration

This project demonstrates the power of Rust for high-performance graphics programming, combining memory safety with zero-cost abstractions to achieve both correctness and speed.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

Aditya Mandal


Commit count: 23

cargo fmt