euv-core 0.52.1

Core cross-platform runtime for euv featuring arena-based fine-grained reactivity, deterministic layout, flat scene graph, multi-mode rendering, and direct OS platform adapters.
Documentation
use super::*;

/// Single spatial-hash cell storing temporally filtered multi-bounce indirect irradiance and occlusion in `LumenRadianceCache`.
#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
pub struct LumenCacheCell {
    /// Non-zero spatial hash key identifying `(voxel_x, voxel_y, voxel_z, normal_bucket, cascade)`.
    #[get(type(copy))]
    pub(crate) key: u64,
    /// Temporally filtered linear HDR indirect diffuse red radiance.
    #[get(type(copy))]
    pub(crate) irradiance_r: f32,
    /// Temporally filtered linear HDR indirect diffuse green radiance.
    #[get(type(copy))]
    pub(crate) irradiance_g: f32,
    /// Temporally filtered linear HDR indirect diffuse blue radiance.
    #[get(type(copy))]
    pub(crate) irradiance_b: f32,
    /// Temporally filtered ambient occlusion factor in `[0.35, 1.0]`.
    #[get(type(copy))]
    pub(crate) ambient_occlusion: f32,
    /// Temporally filtered directional sun visibility factor in `[0.0, 1.0]`.
    #[get(type(copy))]
    pub(crate) sun_visibility: f32,
    /// Accumulated sample confidence weight capped at `LUMEN_MAX_TEMPORAL_WEIGHT`.
    #[get(type(copy))]
    pub(crate) sample_weight: f32,
    /// Monotonic frame index when this cell was last refreshed.
    #[get(type(copy))]
    pub(crate) last_frame: u32,
}

/// Telemetry counters describing hit rate and occupancy of `LumenRadianceCache`.
#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
pub struct LumenCacheStats {
    /// Total active occupied cells in the world-space radiance hash table.
    #[get(type(copy))]
    pub(crate) active_cells: usize,
    /// Cache hits served during the most recent frame.
    #[get(type(copy))]
    pub(crate) frame_hits: u64,
    /// Cache misses encountered during the most recent frame.
    #[get(type(copy))]
    pub(crate) frame_misses: u64,
    /// Total temporal updates accumulated into the cache.
    #[get(type(copy))]
    pub(crate) total_updates: u64,
}

/// UE5 Lumen-style World-Space Two-Cascade Spatial-Hash Radiance Cache enabling zero-allocation O(1) multi-bounce GI feedback.
#[derive(Clone, Data, Debug)]
pub struct LumenRadianceCache {
    /// Power-of-two slot mask (`cells.len() - 1`).
    #[get(type(copy))]
    pub(crate) slot_mask: usize,
    /// Monotonic frame counter driving stale-entry eviction.
    #[get(type(copy))]
    pub(crate) current_frame: u32,
    /// Last directional sun vector validating cache freshness across lighting changes.
    #[get(type(copy))]
    pub(crate) cached_sun_dir: Vec3,
    /// Number of occupied cells currently storing valid radiance.
    #[get(type(copy))]
    pub(crate) active_cells: usize,
    /// Cumulative temporal updates recorded across frames.
    #[get(type(copy))]
    pub(crate) total_updates: u64,
    /// Fixed-capacity open-addressed hash table cells.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) cells: Vec<LumenCacheCell>,
}

/// Result of analytically reprojecting a current-frame world probe into the previous frame's coarse RT probe grid.
#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
pub struct LumenReprojectedProbe {
    /// Linear index inside `prev_rt_probes` (`prev_gy * prev_gw + prev_gx`).
    #[get(type(copy))]
    pub(crate) prev_index: usize,
    /// Reprojected previous-frame coarse probe column index.
    #[get(type(copy))]
    pub(crate) prev_gx: usize,
    /// Reprojected previous-frame coarse probe row index.
    #[get(type(copy))]
    pub(crate) prev_gy: usize,
    /// Reprojected previous-frame linear camera depth (`prev_clip_w`).
    #[get(type(copy))]
    pub(crate) prev_depth: f32,
}