Skip to main content

RayTraceSettings

Struct RayTraceSettings 

Source
pub struct RayTraceSettings {
    pub samples_per_axis: u32,
    pub max_bounces: u32,
}
Expand description

Ray-tracing quality settings shared by the CPU reference renderer and both GPU shader backends.

The values are packed into the GPU frame header so the CPU path and the shaders sample and bounce identically.

Fields§

§samples_per_axis: u32

Supersampling grid resolution per axis. 1 traces one ray per pixel; 4 traces sixteen and averages them. Valid range 1..=4.

§max_bounces: u32

Maximum number of secondary bounces after the primary hit. 0 still shades the primary hit. Valid range 0..=16.

Implementations§

Source§

impl RayTraceSettings

Implements the constructors and validation for RayTraceSettings.

Source

pub fn new_default() -> RayTraceSettings

Returns the default settings: one ray per pixel and the [RAYTRACE_DEFAULT_MAX_BOUNCES_LIMIT] bounce limit.

§Returns
  • RayTraceSettings - The default settings.
Source

pub fn with_quality(samples_per_axis: u32, max_bounces: u32) -> RayTraceSettings

Returns a settings block with an explicit sampling grid and bounce limit.

The arguments are not validated here; call RayTraceSettings::validate before packing or rendering.

§Arguments
  • u32 - The supersampling grid resolution per axis.
  • u32 - The maximum number of secondary bounces.
§Returns
  • RayTraceSettings - The new settings.
Source

pub fn rays_per_pixel(&self) -> u32

Returns the total number of rays traced per pixel, which is samples_per_axis squared.

§Returns
  • u32 - The per-pixel ray count.
Source

pub fn validate(&self) -> Result<(), String>

Checks that both fields are inside the range the CPU renderer and both shaders support.

samples_per_axis must be within 1..=[RAYTRACE_SAMPLES_PER_AXIS_MAX] and max_bounces within 0..=[RAYTRACE_MAX_BOUNCES_MAX]. Anything else is rejected rather than clamped, so a caller never silently gets a different image than it asked for.

§Returns
  • Result<(), String> - Ok(()) when both fields are in range, otherwise a message naming the offending field.
Source§

impl RayTraceSettings

Source

pub fn get_samples_per_axis(&self) -> u32

Source

pub fn get_mut_samples_per_axis(&mut self) -> &mut u32

Source

pub fn set_samples_per_axis(&mut self, val: u32) -> &mut Self

Source

pub fn get_max_bounces(&self) -> u32

Source

pub fn get_mut_max_bounces(&mut self) -> &mut u32

Source

pub fn set_max_bounces(&mut self, val: u32) -> &mut Self

Source§

impl RayTraceSettings

Source

pub fn new(samples_per_axis: u32, max_bounces: u32) -> Self

Trait Implementations§

Source§

impl Clone for RayTraceSettings

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for RayTraceSettings

Source§

impl Debug for RayTraceSettings

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for RayTraceSettings

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RayTraceSettings

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more