Crate rustic_zen

Source
Expand description

Photon Garden Raytracer Impementation.

Rustic Zen renders artworks from a scene definition by simulating individual photons and tracing their path as they bounce through a 2D. space.

Photons are generated by Lights and interact with Objects. Each interaction results in either the photon being absorbed, or being allowed to continue with a new direction, based on the rules defined by the Object’s Material.

§Example usage:

extern crate rustic_zen;
use rustic_zen::prelude::*;
use rustic_zen::material::hqz_legacy;
use std::sync::Arc;

fn main() {
    // Set up constants.
    let width: f64 = 1920.0;
    let height: f64 = 1080.0;

    // Build a basic Material
    let m = hqz_legacy(0.3, 0.3, 0.3);

    // Build a basic Object
    let o = Segment::line_from_points((0.0,(height * 0.75)), (width, (height * 0.75)), m);

    // Build a basic Light
    let l = Light::new((width / 2.0, height / 2.0), 1.0, 0.0, 0.0, (360.0, 0.0), Sampler::new_blackbody(5800.0));

    // Construct a renderer object and add the light and object to it.
    let s = Scene::new(width as usize, height as usize).with_object(o).with_light(l);

    // Create an image to render into.
    let mut i = Arc::new(Image::new(width as usize, height as usize));

    // Render Image
    println!("Tracing Rays");
    let rays = s.render(RenderConstraint::TimeMS(1000), 1, &mut i);
    // this call should probably be more like 5000 - 15000 ms and use your number of threads,
    // but this example is run by various CI tools, and tests can't take too long.

    // Output the Image as a Vec<u8>
    println!("Serializing!");
    let data = i.to_rgba8(rays, 0.7, 1.2);
     
    // Do Export to a PNG or whatever you want here.
}

Modules§

geom
Rustic Zen’s native geometry primitives.
image
Module providing render targets for both Software and Hardware accelerated image rendering.
material
Materials in Rustic Zen are defined as closures that act on a single ray when intersecting wtth an object.
prelude
This prelude contains everything to quickstart using Rustic Zen.
sampler
Wrappers for stochastically sampled variables.
scene
Scene Definition and Rendering Control.