Crate crystal_ball[−][src]
Expand description
Overview
Crystal Ball is a path tracing library written in Rust.
It uses rayon for parallelization and can save the rendered image in various formats thanks to the image crate.
Example Usage
use std::path::Path; use crystal_ball::prelude::*; fn main() { let objects = vec![ Sphere::new() .with_center(Vec3::new(0.0, 0.0, -1.0)) .with_radius(0.5) .with_material(Material::Diffuse { color: Color::new(1.0, 0.45, 0.31), }), Sphere::new() .with_center(Vec3::new(0.0, -100.5, -1.0)) .with_radius(100.0) .with_material(Material::Diffuse { color: Color::new(0.7, 0.7, 0.7), }), ]; let scene = Scene::new() .with_camera(Camera::new()) .with_objects(objects); let engine = RenderEngine::new(32, 8); // Samples and max bounces let mut image = engine.render(&scene); image .write(Path::new("output/example_render.png")) .expect("Error writing rendered image"); }
Modules
color | Data Types and functions related to colors and images. |
math | Data Types and functions related to math with focus on vectors. |
prelude | |
rendering | Data Types and functions related to rendering. |
shapes | Geometric shapes that can be placed into the scene. |