A multithreaded raytracer implemented in rust
As every projects in rust, run with:
cargo run --release
Everything happens in the src/main.rs
file.
Edit the HEIGHT
and WIDTH
constants at the beginning of the file:
const WIDTH: usize = 1920;
const HEIGHT: usize = 1080;
Objects and lights are created in the init_scene
function.
Add or remove them according to your needs.
For example:
let cylinder = Cylinder::new(
Vector3::new(0.0, 5.0, 0.0), // Position
Vector3::new(1.0, 0.0, 1.0).normalize(), // Direction vector *NEEDS TO BE NORMALIZED*
0.5, // Width of the cylinder
Vector3::new(0.5, 0.5, 0.8), // Color scaled from 0 to 1 in RGB
0.5, // Reflection index
0.0 // Refraction index
);
scene.objects.push(Box::new(cylinder)); // Add the cylinder to the scene
- Sphere, Cylinder, Planes primitives
- Directionnal lights
- Spot lights
- Diffuse and total reflection
- Cone primitive
- Amblient lightning
- Materials