Skip to main content

LumenRadianceCache

Struct LumenRadianceCache 

Source
pub struct LumenRadianceCache { /* private fields */ }
Expand description

UE5 Lumen-style World-Space Two-Cascade Spatial-Hash Radiance Cache enabling zero-allocation O(1) multi-bounce GI feedback.

Implementations§

Source§

impl LumenRadianceCache

World-space quantization, O(1) multi-bounce irradiance lookup, temporal EMA accumulation, and motion-vector reprojection for LumenRadianceCache.

Source

pub fn with_capacity(capacity: usize) -> Self

Constructs a LumenRadianceCache rounded up to a power-of-two capacity (>= 64).

§Arguments
  • usize - Requested minimum slot capacity.
§Returns
  • Self - Zero-allocation-after-init radiance cache.
Source

pub fn invalidate(&mut self)

Clears every spatial hash cell in-place without freeing backing memory (e.g. on sun change or world reset).

Source

pub fn begin_frame(&mut self, sun_direction: Vec3)

Begins a new frame, invalidating cached indirect radiance automatically if the directional sun shifted meaningfully.

§Arguments
  • Vec3 - Current active unit directional sun vector.
Source

pub fn quantize_key( &self, world_pos: Vec3, normal: Vec3, camera_pos: Vec3, ) -> (u64, usize)

Quantizes a world position, surface normal, and camera distance into a deterministic non-zero 64-bit spatial key and primary bucket index.

§Arguments
  • Vec3 - World-space surface position.
  • Vec3 - Unit outward surface normal.
  • Vec3 - Active camera world position selecting near vs far cascade.
§Returns
  • (u64, usize) - (non_zero_spatial_key, base_bucket_index).
Source

pub fn lookup( &self, world_pos: Vec3, normal: Vec3, camera_pos: Vec3, ) -> Option<(Vec3, f32, f32)>

Queries the world-space radiance cache in O(1) for temporally accumulated (irradiance, ao, sun_visibility).

§Arguments
  • Vec3 - World-space surface position.
  • Vec3 - Unit outward surface normal.
  • Vec3 - Active camera world position.
§Returns
  • Option<(Vec3, f32, f32)> - Cached (indirect_irradiance, ao, sun_visibility) when present and fresh.
Source

pub fn accumulate_sample( &mut self, world_pos: Vec3, normal: Vec3, camera_pos: Vec3, irradiance: Vec3, ambient_occlusion: f32, sun_visibility: f32, )

Accumulates a freshly traced surface lighting sample into the world-space radiance cache via damped temporal EMA.

§Arguments
  • Vec3 - World-space surface position.
  • Vec3 - Unit outward surface normal.
  • Vec3 - Active camera world position.
  • Vec3 - Measured linear HDR indirect irradiance RGB.
  • f32 - Measured ambient occlusion in [0.35, 1.0].
  • f32 - Measured directional sun visibility in [0.0, 1.0].
Source

pub fn reproject_world_to_prev_probe( world_pos: Vec3, prev_view_proj: &Mat4, prev_viewport: (usize, usize), grid_layout: (usize, usize, usize), ) -> Option<LumenReprojectedProbe>

Analytically reprojects a world-space probe point into the previous frame’s coarse RT probe grid using prev_view_proj.

§Arguments
  • Vec3 - Current-frame world-space surface position.
  • &Mat4 - Previous frame’s view-projection matrix.
  • (usize, usize) - Previous frame internal framebuffer (width, height) in pixels.
  • (usize, usize, usize) - (rt_step, prev_grid_width, prev_grid_height).
§Returns
  • Option<LumenReprojectedProbe> - Valid previous-frame probe index and depth when inside previous viewport bounds.
Source

pub fn stats(&self) -> LumenCacheStats

Returns a snapshot of current radiance cache telemetry.

§Returns
  • LumenCacheStats - Active cell count and cumulative update statistics.
Source§

impl LumenRadianceCache

Source

pub fn get_slot_mask(&self) -> usize

Source

pub fn get_mut_slot_mask(&mut self) -> &mut usize

Source

pub fn set_slot_mask(&mut self, val: usize) -> &mut Self

Source

pub fn get_current_frame(&self) -> u32

Source

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

Source

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

Source

pub fn get_cached_sun_dir(&self) -> Vec3

Source

pub fn get_mut_cached_sun_dir(&mut self) -> &mut Vec3

Source

pub fn set_cached_sun_dir(&mut self, val: Vec3) -> &mut Self

Source

pub fn get_active_cells(&self) -> usize

Source

pub fn get_mut_active_cells(&mut self) -> &mut usize

Source

pub fn set_active_cells(&mut self, val: usize) -> &mut Self

Source

pub fn get_total_updates(&self) -> u64

Source

pub fn get_mut_total_updates(&mut self) -> &mut u64

Source

pub fn set_total_updates(&mut self, val: u64) -> &mut Self

Trait Implementations§

Source§

impl Clone for LumenRadianceCache

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 Debug for LumenRadianceCache

Source§

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

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

impl Default for LumenRadianceCache

Default 8,192-slot two-cascade LumenRadianceCache.

Source§

fn default() -> Self

Creates an empty pre-allocated LumenRadianceCache with LUMEN_RADIANCE_CACHE_SLOTS slots.

§Returns
  • Self - Ready world-space radiance cache.

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.