pub struct ImageTracer<'a> {
    image: &'a mut HdrImage,
    camera: Camera,
}
Expand description

Trace an image by shooting light rays through each of its pixels.

Fields§

§image: &'a mut HdrImage

An initialized HdrImage.

§camera: Camera

A Camera enum that implement FireRay trait.

Implementations§

source§

impl<'a> ImageTracer<'a>

source

pub fn new(image: &'a mut HdrImage, camera: Camera) -> Self

Initialize an ImageTracer object.

The parameter image must be a HdrImage object that has already been initialized.
The parameter camera must be a Camera enum that implement FireRay trait.

source

fn fire_ray(&self, col: u32, row: u32, u_pixel: f32, v_pixel: f32) -> Ray

Shot one light Ray through image pixel (col, row).

The parameters (col, row) are measured in the same way as
they are in HdrImagethe bottom left corner is placed at (0, 0).

The values of u_pixel and v_pixel are floating-point numbers in the range [0, 1].
They specify where the ray should cross the pixel; passing 0.5 to both means that
the ray will pass through the pixel’s center.

source

fn all_rays( &self, init_state: u64, init_seq: u64, antialiasing_level: u32 ) -> Vec<Rays>

Generate a Vec of Rays.

Appo method for parallelized fire_all_rays.

source

pub fn fire_all_rays( &mut self, renderer: &Renderer<'_>, init_state: u64, init_seq: u64, antialiasing_level: u32 )

Shoot several light rays crossing each of the pixels in the image.

If antialiasing_level is one, for each pixel in the HdrImage object fire one Ray,
and pass it to a Renderer that implement a Solve trait to determine the Color of the pixel.

If antialiasing_level is greater than one, then each pixel is divided in a N by N grid,
where N is the anti-aliasing level, and a Ray is thrown for each sub-pixel;
the color of the pixel in this case is obtained as the mean color of the N*N samples.

This function is parallelized for each pixel that compose image pixels matrix,
thanks to high-level API [rayon::iter::IntoParallelRefIterator::par_iter].
So for each available thread an independent pixel rendering equation resolution is computed,
using particular Renderer that implement Solve trait.

Note: to avoid artefacts each Pcg used by each thread is created from a different sequence, thanks to all_rays method.

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for ImageTracer<'a>

§

impl<'a> Send for ImageTracer<'a>

§

impl<'a> Sync for ImageTracer<'a>

§

impl<'a> Unpin for ImageTracer<'a>

§

impl<'a> !UnwindSafe for ImageTracer<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.