Skip to main content

Renderer

Struct Renderer 

Source
pub struct Renderer<'a, Scene, Prod, Img, A, ShaderArgs, P>
where Scene: Sync, Prod: Produce<Triangle> + Sync + ?Sized, A: Acc,
{
Show 25 fields pub scene: Scene, pub scene_ray_color: fn(&Scene, f32, usize) -> (A::In, ShaderArgs), pub shader: Shader<A::In, ShaderArgs>, pub is_transparent: fn(&A::In) -> bool, pub acc_to_linear_rgba: fn(A::Out) -> Rgba, pub producer: &'a Prod, pub img: &'a mut Img, pub size: fn(&Img) -> PixelPos, pub pxl: fn(_: &mut Img, _: PixelPos, c: Rgba<u8>), pub acc_data: A::Data, pub persp: &'a CameraPerspective, pub cam: &'a Camera, pub flip_xyz: Vector, pub compr_masks: &'a mut [CompressedMasks], pub pre_compr_masks: &'a mut [CompressedMasks], pub sub_compr_masks: &'a mut Vec<Vec<CompressedMasks>>, pub sub_tile_triangle_limit: u32, pub profile: &'a mut P, pub profile_render: fn(&mut P, Option<f64>), pub profile_compress: fn(&mut P, ProfileCompressData<'_>, Option<f64>), pub sub_masks: bool, pub pre_masks: bool, pub profile_enabled: bool, pub acc_limit: u32, pub scale_to_pre_tile_size: u32,
}
Expand description

Stores data needed during rendering.

Fields§

§scene: Scene

Scene data.

§scene_ray_color: fn(&Scene, f32, usize) -> (A::In, ShaderArgs)

Gets a default ray color prior to shading.

Make sure to convert to the same color space as the accumulator.

For example, if the accumulator uses linear color space, and you use sRGB color space in scene data, then you should convert to linear color space.

§shader: Shader<A::In, ShaderArgs>

A customized shader transform prior to color accumulation.

This can be used to change the color of the ray.

§is_transparent: fn(&A::In) -> bool

Returns true if color is transparent, false otherwise.

This is used to filter out colors that do not contribute in accumulator.

§acc_to_linear_rgba: fn(A::Out) -> Rgba

Produces the final color from accumulator.

§producer: &'a Prod

A producer.

§img: &'a mut Img

The target image.

§size: fn(&Img) -> PixelPos

Get the size of the image in pixels.

§pxl: fn(_: &mut Img, _: PixelPos, c: Rgba<u8>)

Writes pixel to image.

§acc_data: A::Data

Accumulator data.

This is used to pre-configure the accumulator with some data.

§persp: &'a CameraPerspective

The camera perspective.

§cam: &'a Camera

The camera.

§flip_xyz: Vector

Can be used to scale or flip axis.

§compr_masks: &'a mut [CompressedMasks]

Stores compressed masks per render tile.

§pre_compr_masks: &'a mut [CompressedMasks]

Stores compressed masks for pre-pre-processing.

§sub_compr_masks: &'a mut Vec<Vec<CompressedMasks>>

Stores compressed masks for adaptive sub-tiling.

§sub_tile_triangle_limit: u32

A limit on the number of triangles per tile before doing adaptive sub-tiling.

Adaptive sub-tiling produces sub-tiles such that the average number of triangles is less than this limit, down to 2x2 sub-tiles.

§profile: &'a mut P

Data used to store performance profiling information.

§profile_render: fn(&mut P, Option<f64>)

Reports the amount of seconds taken to render (None if profiling is disabled).

§profile_compress: fn(&mut P, ProfileCompressData<'_>, Option<f64>)

Reports profile compress data and amount of seconds (None if profiling is disabled).

§sub_masks: bool

Whether to use adaptive sub-tiling.

Adaptive sub-tiling splits tiles that have a large amount of triangles into sub-tiles, where the average amount of triangles is less thatn sub_tile_triangle_limit.

§pre_masks: bool

Whether to use pre-masks.

This is a pre-pre-processing step where run-length compression on masks uses a lower resolution, to speed up pre-processing.

§profile_enabled: bool

Whether profiling is enabled.

Profiling gathers some data about the rendering process.

§acc_limit: u32

A limit of how many accumulations per tile.

Is used to prevent inner infinite rendering loops.

This is usually some multiple of the accumulator buffer size.

§scale_to_pre_tile_size: u32

The scale ratio between pre-tile size and tile size.

Implementations§

Source§

impl<Scene, Prod, Img, Accumulator, ShaderArgs, P> Renderer<'_, Scene, Prod, Img, Accumulator, ShaderArgs, P>
where Scene: Sync, Prod: Produce<Triangle> + Sync + ?Sized, Accumulator: Acc,

Source

pub fn render<const TILE_SIZE: usize>(self)

Render with some render tile size.

The tile size should be optimized for adaptive sub-tile rendering. Use optimal_sub_tile_size.

Auto Trait Implementations§

§

impl<'a, Scene, Prod, Img, A, ShaderArgs, P> !UnwindSafe for Renderer<'a, Scene, Prod, Img, A, ShaderArgs, P>

§

impl<'a, Scene, Prod, Img, A, ShaderArgs, P> Freeze for Renderer<'a, Scene, Prod, Img, A, ShaderArgs, P>
where Scene: Freeze, <A as Acc>::Data: Freeze, Prod: ?Sized,

§

impl<'a, Scene, Prod, Img, A, ShaderArgs, P> RefUnwindSafe for Renderer<'a, Scene, Prod, Img, A, ShaderArgs, P>

§

impl<'a, Scene, Prod, Img, A, ShaderArgs, P> Send for Renderer<'a, Scene, Prod, Img, A, ShaderArgs, P>
where Scene: Send, <A as Acc>::Data: Send, Img: Send, P: Send, Prod: ?Sized,

§

impl<'a, Scene, Prod, Img, A, ShaderArgs, P> Sync for Renderer<'a, Scene, Prod, Img, A, ShaderArgs, P>
where Img: Sync, P: Sync, Prod: ?Sized,

§

impl<'a, Scene, Prod, Img, A, ShaderArgs, P> Unpin for Renderer<'a, Scene, Prod, Img, A, ShaderArgs, P>
where Scene: Unpin, <A as Acc>::Data: Unpin, Prod: ?Sized,

§

impl<'a, Scene, Prod, Img, A, ShaderArgs, P> UnsafeUnpin for Renderer<'a, Scene, Prod, Img, A, ShaderArgs, P>
where Scene: UnsafeUnpin, <A as Acc>::Data: UnsafeUnpin, Prod: ?Sized,

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

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>,

Source§

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>,

Source§

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.