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

/// Dual-filter mip-chain bloom settings with soft-knee thresholding and Karis firefly suppression.
#[derive(Clone, Copy, Data, Debug, PartialEq)]
pub struct BloomConfig3D {
    /// Enables or disables the bloom pass.
    #[get(type(copy))]
    pub(crate) enabled: bool,
    /// Linear luminance threshold above which highlights enter bloom.
    #[get(type(copy))]
    pub(crate) threshold: f32,
    /// Soft-knee transition width in `[0.0, 1.0]` preventing harsh threshold banding.
    #[get(type(copy))]
    pub(crate) soft_knee: f32,
    /// Energy-conserving bloom scattering blend fraction in `[0.0, 0.5]`.
    #[get(type(copy))]
    pub(crate) intensity: f32,
    /// Number of mip levels in the downsample/upsample pyramid (`1..=POSTFX_MAX_BLOOM_MIPS`).
    #[get(type(copy))]
    pub(crate) mip_count: usize,
}

/// Histogram log-luminance automatic eye-adaptation exposure settings.
#[derive(Clone, Copy, Data, Debug, PartialEq)]
pub struct AutoExposureConfig3D {
    /// Enables or disables histogram auto-exposure adaptation.
    #[get(type(copy))]
    pub(crate) enabled: bool,
    /// Minimum log2 luminance covered by histogram bin `0`.
    #[get(type(copy))]
    pub(crate) min_log_lum: f32,
    /// Maximum log2 luminance covered by the top histogram bin.
    #[get(type(copy))]
    pub(crate) max_log_lum: f32,
    /// Target middle-gray key luminance (`0.18` standard photographic gray).
    #[get(type(copy))]
    pub(crate) target_key_value: f32,
    /// Adaptation speed when brightening from dark to bright scenes (per second).
    #[get(type(copy))]
    pub(crate) adapt_speed_up: f32,
    /// Adaptation speed when darkening from bright to dark scenes (per second).
    #[get(type(copy))]
    pub(crate) adapt_speed_down: f32,
    /// Lower exposure multiplier clamp.
    #[get(type(copy))]
    pub(crate) min_exposure: f32,
    /// Upper exposure multiplier clamp.
    #[get(type(copy))]
    pub(crate) max_exposure: f32,
}

/// Linear HDR color grading controls applied prior to tone mapping.
#[derive(Clone, Copy, Data, Debug, PartialEq)]
pub struct ColorGradingConfig3D {
    /// Manual exposure offset in EV stops (`2^exposure_ev`).
    #[get(type(copy))]
    pub(crate) exposure_ev: f32,
    /// Contrast multiplier pivoted around mid-gray `0.18`.
    #[get(type(copy))]
    pub(crate) contrast: f32,
    /// Rec.709 chroma saturation multiplier (`0.0` grayscale, `1.0` neutral).
    #[get(type(copy))]
    pub(crate) saturation: f32,
    /// Additive shadow lift offset `(r, g, b)`.
    #[get(type(copy))]
    pub(crate) lift: Vec3,
    /// Midtone gamma exponent `(r, g, b)` (`1.0` neutral).
    #[get(type(copy))]
    pub(crate) gamma: Vec3,
    /// Highlight gain multiplier `(r, g, b)` (`1.0` neutral).
    #[get(type(copy))]
    pub(crate) gain: Vec3,
    /// White-balance temperature shift in `[-1.0, 1.0]` (negative cool, positive warm).
    #[get(type(copy))]
    pub(crate) temperature: f32,
    /// White-balance green/magenta tint shift in `[-1.0, 1.0]`.
    #[get(type(copy))]
    pub(crate) tint: f32,
}

/// Complete configuration bundle for `PostFxPipeline3D`.
#[derive(Clone, Copy, Data, Debug, PartialEq)]
pub struct PostFxConfig3D {
    /// Dual-filter bloom settings.
    #[get(type(copy))]
    pub(crate) bloom: BloomConfig3D,
    /// Histogram auto-exposure settings.
    #[get(type(copy))]
    pub(crate) auto_exposure: AutoExposureConfig3D,
    /// Linear color grading controls.
    #[get(type(copy))]
    pub(crate) color_grading: ColorGradingConfig3D,
    /// Radial lens vignette darkening strength in `[0.0, 1.0]`.
    #[get(type(copy))]
    pub(crate) vignette_intensity: f32,
    /// Radial vignette falloff smoothness in `[0.1, 1.0]`.
    #[get(type(copy))]
    pub(crate) vignette_smoothness: f32,
    /// Subtle radial RGB chromatic aberration offset in `[0.0, 0.05]`.
    #[get(type(copy))]
    pub(crate) chromatic_aberration: f32,
    /// Active HDR tone-mapping operator (`AgX`, `AcesFilmic`, or `Reinhard`).
    #[get(type(copy))]
    pub(crate) tone_mapper: ToneMapOperator3D,
    /// Enables or disables post-tonemap FXAA luma anti-aliasing.
    #[get(type(copy))]
    pub(crate) fxaa_enabled: bool,
}

/// Single pre-allocated bloom mip level storing linear RGB pixels and dimensions.
#[derive(Clone, Data, Debug, PartialEq)]
pub struct BloomMipBuffer3D {
    /// Mip width in texels.
    #[get(type(copy))]
    pub(crate) width: usize,
    /// Mip height in texels.
    #[get(type(copy))]
    pub(crate) height: usize,
    /// Contiguous row-major linear HDR RGB texels (`len == width * height`).
    pub(crate) pixels: Vec<[f32; 3]>,
}

/// Zero-steady-state-allocation HDR post-processing pipeline (Bloom mip-chain, Auto-Exposure, Color Grading, Vignette, Chromatic Aberration, AgX/ACES/Reinhard, and FXAA).
#[derive(Clone, Data, Debug, PartialEq)]
pub struct PostFxPipeline3D {
    /// Active framebuffer width in pixels.
    #[get(type(copy))]
    pub(crate) width: usize,
    /// Active framebuffer height in pixels.
    #[get(type(copy))]
    pub(crate) height: usize,
    /// Post-processing configuration bundle.
    #[get(type(copy))]
    pub(crate) config: PostFxConfig3D,
    /// Current temporally adapted linear exposure multiplier.
    #[get(type(copy))]
    pub(crate) adapted_exposure: f32,
    /// Latest log-average scene luminance estimated from the exposure histogram.
    #[get(type(copy))]
    pub(crate) adapted_avg_luminance: f32,
    /// Total luminance energy entering the bloom prefilter in the latest frame.
    #[get(type(copy))]
    pub(crate) last_bloom_input_energy: f32,
    /// Total luminance energy exiting the final upsampled bloom mip in the latest frame.
    #[get(type(copy))]
    pub(crate) last_bloom_output_energy: f32,
    /// Inline fixed-size log-luminance histogram bins (`zero` heap allocations).
    #[get(pub(crate))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) histogram_bins: [u32; POSTFX_HISTOGRAM_BINS],
    /// Pre-allocated bloom mip-chain scratch buffers.
    #[get(pub(crate))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) bloom_mips: Vec<BloomMipBuffer3D>,
    /// Pre-allocated intermediate post-tonemap linear/sRGB RGB buffer (`len == width * height`).
    #[get(pub(crate))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) graded_srgb: Vec<[f32; 3]>,
    /// Pre-allocated perceptual luma scratch buffer for FXAA (`len == width * height`).
    #[get(pub(crate))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) luma_buffer: Vec<f32>,
    /// Pre-allocated final sRGB RGBA8 output framebuffer (`len == width * height * 4`).
    #[get(pub(crate))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) output_rgba8: Vec<u8>,
}