Struct rustracer::imagetracer::ImageTracer
source · 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
Implementations§
source§impl<'a> ImageTracer<'a>
impl<'a> ImageTracer<'a>
sourcefn fire_ray(&self, col: u32, row: u32, u_pixel: f32, v_pixel: f32) -> Ray
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 HdrImage
the 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.
sourcefn all_rays(
&self,
init_state: u64,
init_seq: u64,
antialiasing_level: u32
) -> Vec<Rays>
fn all_rays( &self, init_state: u64, init_seq: u64, antialiasing_level: u32 ) -> Vec<Rays>
Appo method for parallelized fire_all_rays
.
sourcepub fn fire_all_rays(
&mut self,
renderer: &Renderer<'_>,
init_state: u64,
init_seq: u64,
antialiasing_level: u32
)
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.