Photon Garden Raytracer Impementation. Rust Impementation of Zenphoton
This project is hosted on Gitlab with a mirror to Github. Main Repo: https://gitlab.com/IGBC/rustic-zen/
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.
This library holds only the rendering framework and models for defining a scene. Functionality for defining a scene, i.e. generative and animation algorithms are not provided here. The focus of Rustic-Zen is providing the raytrace algorithms for rendering a static scene.
Rustic-Zen provides a single basic shader, for backwards compatiblity with prior art. It is expected that dedicated library users will use the exposed Material trait to create your own shaders.
extern crate rustic_zen;
use rustic_zen::prelude::*;
fn main() {
// Set up constants.
let width: f64 = 3440.0;
let height: f64 = 1440.0;
let rays = 100_000;
// This would be better but these doctests have to run in reasonable time
// let rays = ((width * height).round() / 2.0) as usize;
// Build a basic Material
let m = Box::new(HQZLegacy::new(0.3, 0.3, 0.3));
// Build a basic Object
let o = Object::Line {
x0: Sample::Constant(0.0),
y0: Sample::Constant(height*0.75),
dx: Sample::Constant(width),
dy: Sample::Constant(0.0),
material: m,
};
// Build a basic Light
let l = Light{
power: Sample::Constant(1.0),
x: Sample::Constant(width/2.0),
y: Sample::Constant(height/2.0),
polar_angle: Sample::Constant(0.0),
polar_distance: Sample::Constant(0.0),
ray_angle: Sample::Range(360.0, 0.0),
wavelength: Sample::Blackbody(4500.0),
};
// We also need a viewport
let viewport = Rect::from_points(&Point{x: 0.0,y: 0.0},&Point{x: width,y: height});
// Construct a renderer object and add the light and object to it.
let r = Scene::new(width as usize, height as usize, viewport).with_object(o)with_light(l);
// Render Image
println!("Tracing Rays");
let image = r.render(rays);
// Output the Image as a Vec<u8>
println!("Serializing!");
let data = image.to_rgb8(0.7, 1.2);
// Do Export to a PNG or whatever you want here.
}
In alpha version numbers are 0.0.*
every change will be breaking
In beta version numbers will be 0.*.*
every minor release will be breaking
Post 1.0.0
semantic versioning will be used
This project and all artworks created by the examples are copyright Lauren Brown (SEGFAULT), and are licenced under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License
see the LICENCE.md file for full terms.