euv-core 0.56.0

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::*;

/// Persistent primary G-buffer storing world normals, linear depths, base albedo, and hit mask for SVGF edge-stopping.
#[derive(Clone, Data, Debug, Default, PartialEq)]
pub struct RtGBuffer {
    /// Viewport width in pixels.
    #[get(type(copy))]
    pub(crate) width: u32,
    /// Viewport height in pixels.
    #[get(type(copy))]
    pub(crate) height: u32,
    /// Primary surface base albedo per pixel (`len == width * height`).
    pub(crate) albedo: Vec<Vec3>,
    /// Primary world-space shading normal per pixel (`len == width * height`).
    pub(crate) normal: Vec<Vec3>,
    /// Primary linear hit distance in meters (`RT_SKY_DEPTH` on sky misses).
    pub(crate) depth: Vec<f32>,
    /// Per-pixel geometry hit flag (`1` = geometry hit, `0` = background sky).
    pub(crate) hit_mask: Vec<u8>,
}

/// Progressive temporal radiance and luminance-moment (`M1`, `M2`) accumulator with automatic camera/scene motion reset.
#[derive(Clone, Data, Debug, Default, PartialEq)]
pub struct TemporalAccumulator {
    /// Buffer width in pixels.
    #[get(type(copy))]
    pub(crate) width: u32,
    /// Buffer height in pixels.
    #[get(type(copy))]
    pub(crate) height: u32,
    /// Running mean linear HDR radiance per pixel.
    pub(crate) radiance: Vec<Vec3>,
    /// Running first luminance moment `E[L]` per pixel.
    pub(crate) moment_1: Vec<f32>,
    /// Running second luminance moment `E[L^2]` per pixel.
    pub(crate) moment_2: Vec<f32>,
    /// Accumulated sample count per pixel.
    pub(crate) sample_counts: Vec<u32>,
    /// Cached camera fingerprint used to detect camera motion.
    #[get(type(copy))]
    pub(crate) camera_fingerprint: u64,
    /// Cached scene revision used to detect dynamic scene edits.
    #[get(type(copy))]
    pub(crate) scene_revision: u64,
    /// Optional history length cap (`0` = unbiased unlimited progressive accumulation).
    #[get(type(copy))]
    pub(crate) max_history_samples: u32,
    /// Total automatic or explicit accumulation resets performed.
    #[get(type(copy))]
    pub(crate) reset_count: u64,
}

/// Edge-stopping and iteration configuration parameters for `SvgfDenoiser`.
#[derive(Clone, Copy, Data, Debug, PartialEq)]
pub struct SvgfConfig {
    /// Number of À-Trous wavelet spatial passes (`1..=5`, step sizes `1, 2, 4, 8, 16`).
    #[get(type(copy))]
    pub(crate) iterations: u32,
    /// Normal similarity exponent (`max(0, n_p · n_q)^phi_normal`).
    #[get(type(copy))]
    pub(crate) phi_normal: f32,
    /// Linear depth edge-stopping sensitivity.
    #[get(type(copy))]
    pub(crate) phi_depth: f32,
    /// Luminance variance edge-stopping sensitivity.
    #[get(type(copy))]
    pub(crate) phi_luma: f32,
    /// Minimum variance floor preventing over-strict luminance rejection in low-sample regions.
    #[get(type(copy))]
    pub(crate) variance_floor: f32,
    /// When `true`, demodulates primary albedo before filtering and remodulates after to preserve fine textures.
    #[get(type(copy))]
    pub(crate) demodulate_albedo: bool,
}

/// Zero-steady-state-allocation multi-pass edge-stopping À-Trous wavelet SVGF denoiser.
#[derive(Clone, Data, Debug, Default, PartialEq)]
pub struct SvgfDenoiser {
    /// Edge-stopping and pass-count settings.
    #[get(type(copy))]
    pub(crate) config: SvgfConfig,
    /// Allocated viewport width in pixels.
    #[get(type(copy))]
    pub(crate) width: u32,
    /// Allocated viewport height in pixels.
    #[get(type(copy))]
    pub(crate) height: u32,
    /// Persistent ping HDR color scratch buffer.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) ping_color: Vec<Vec3>,
    /// Persistent pong HDR color scratch buffer.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) pong_color: Vec<Vec3>,
    /// Persistent ping luminance variance scratch buffer.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) ping_variance: Vec<f32>,
    /// Persistent pong luminance variance scratch buffer.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) pong_variance: Vec<f32>,
}