Skip to main content

Trace

Trait Trace 

Source
pub trait Trace {
    // Required method
    fn shade(&self, ray: Ray) -> (Vec3, f32);

    // Provided method
    fn advance(&mut self, now: Duration) -> Camera { ... }
}
Expand description

A raytraced scene: per-frame state plus a shader for every ray.

shade returns a unit-range color and a coverage alpha. Coverage decides which braille dots light; color, weighted by coverage, decides each cell’s tint. Any Fn(Ray) -> (Vec3, f32) closure is a still scene viewed through Camera::default.

Required Methods§

Source

fn shade(&self, ray: Ray) -> (Vec3, f32)

Shades one ray: (color, coverage), both in unit range.

Provided Methods§

Source

fn advance(&mut self, now: Duration) -> Camera

Advances animation state to now and returns this frame’s camera.

Examples found in repository?
examples/chat/welcome.rs (line 745)
743fn logo_cells(elapsed: f32, pointer: (f32, f32)) -> LogoGrid {
744	let mut platter = Platter::new(pointer);
745	let camera = platter.advance(Duration::from_secs_f32(elapsed));
746	let mut grid: LogoGrid = [[None; LOGO_COLS]; LOGO_ROWS];
747	scene::rasterize(&platter, &camera, LOGO_COLS as u16, LOGO_ROWS as u16, |x, y, glyph, color| {
748		grid[y as usize][x as usize] = Some((glyph, color));
749	});
750	grid
751}

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Trace for PathTracer

Source§

impl<F: Fn(Ray) -> (Vec3, f32)> Trace for F