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.
impl LumenRadianceCache
World-space quantization, O(1) multi-bounce irradiance lookup, temporal EMA accumulation, and motion-vector reprojection for LumenRadianceCache.
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Sourcepub fn invalidate(&mut self)
pub fn invalidate(&mut self)
Clears every spatial hash cell in-place without freeing backing memory (e.g. on sun change or world reset).
Sourcepub fn begin_frame(&mut self, sun_direction: Vec3)
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.
Sourcepub fn quantize_key(
&self,
world_pos: Vec3,
normal: Vec3,
camera_pos: Vec3,
) -> (u64, usize)
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).
Sourcepub fn lookup(
&self,
world_pos: Vec3,
normal: Vec3,
camera_pos: Vec3,
) -> Option<(Vec3, f32, f32)>
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.
Sourcepub fn accumulate_sample(
&mut self,
world_pos: Vec3,
normal: Vec3,
camera_pos: Vec3,
irradiance: Vec3,
ambient_occlusion: f32,
sun_visibility: f32,
)
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].
Sourcepub fn reproject_world_to_prev_probe(
world_pos: Vec3,
prev_view_proj: &Mat4,
prev_viewport: (usize, usize),
grid_layout: (usize, usize, usize),
) -> Option<LumenReprojectedProbe>
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.
Sourcepub fn stats(&self) -> LumenCacheStats
pub fn stats(&self) -> LumenCacheStats
Returns a snapshot of current radiance cache telemetry.
§Returns
LumenCacheStats- Active cell count and cumulative update statistics.