euv-core 0.49.4

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

/// Maximum internal optical framebuffer dimension (pixels) balancing Retina crispness with 120-240Hz frame pacing.
pub const FLUID_RENDER_MAX_DIM: u32 = 960;

/// Minimum internal optical framebuffer dimension in pixels.
pub const FLUID_RENDER_MIN_DIM: u32 = 160;

/// Maximum internal optical pixel budget on native multi-threaded targets (`840 x 520`).
#[cfg(not(target_arch = "wasm32"))]
pub(crate) const FLUID_RENDER_MAX_PIXELS: f32 = 840.0 * 520.0;

/// Maximum internal optical pixel budget on single-threaded WebAssembly (`576 x 360`).
#[cfg(target_arch = "wasm32")]
pub(crate) const FLUID_RENDER_MAX_PIXELS: f32 = 576.0 * 360.0;

/// Pre-baked spherical primary storm-cloud sky LUT width in texels.
pub(crate) const SKY_LUT_W: usize = 384;

/// Pre-baked spherical primary storm-cloud sky LUT height in texels.
pub(crate) const SKY_LUT_H: usize = 192;

/// Pre-baked hemi-octahedral 360-degree ocean-reflection sky LUT width in texels.
pub(crate) const REFL_LUT_W: usize = 80;

/// Pre-baked hemi-octahedral 360-degree ocean-reflection sky LUT height in texels.
pub(crate) const REFL_LUT_H: usize = 80;

/// Cloud drift interval in seconds between amortized spherical sky LUT refreshes (`12.5 Hz`).
pub(crate) const SKY_LUT_REFRESH_INTERVAL_SECS: f32 = 0.08;

/// Number of entries in the L1-resident ACES filmic + sRGB gamma LUT (`0..=1024`).
pub(crate) const ACES_LUT_SIZE: usize = 1025;

/// Rational hyperbolic knee mapping linear HDR radiance `[0, inf)` onto `[0, 1]` for the ACES+sRGB LUT.
pub(crate) const ACES_LUT_KNEE: f32 = 0.38;

/// Reciprocal of `pi / 2` (`2 / pi`) for fast branchless polynomial `fast_sin_cos` range reduction.
pub(crate) const FAST_TRIG_INV_HALF_PI: f32 = 2.0 / PI;

/// Half-pi (`pi / 2`) for fast branchless polynomial `fast_sin_cos` range reduction.
pub(crate) const FAST_TRIG_HALF_PI: f32 = FRAC_PI_2;

/// Maximum internal scalar field grid width for PBF interactive wake extraction.
pub(crate) const FLUID_FIELD_MAX_W: usize = 128;

/// Maximum internal scalar field grid height for PBF interactive wake extraction.
pub(crate) const FLUID_FIELD_MAX_H: usize = 96;

/// Minimum internal scalar field grid dimension.
pub(crate) const FLUID_FIELD_MIN_DIM: usize = 48;

/// Schlick Fresnel base normal-incidence reflectance for air-water (`((1.333 - 1) / (1.333 + 1))^2 ≈ 0.0204`).
pub(crate) const WATER_FRESNEL_F0: f32 = 0.0204;

/// Parallel worker band height in output scanlines for native multi-threaded optical shading.
pub(crate) const FLUID_RENDER_BAND_ROWS: usize = 16;

/// Perspective camera focal length matching a natural ~50mm cinematic ocean lens.
pub(crate) const OCEAN_CAMERA_FOCAL: f32 = 1.62;

/// Perspective camera height above mean ocean surface in meters.
pub(crate) const OCEAN_CAMERA_HEIGHT_M: f32 = 1.42;

/// Default normalized screen Y coordinate of the open-sea horizon (`54.5%` from top).
pub(crate) const OCEAN_HORIZON_V: f32 = 0.545;

/// Sun azimuth X offset in camera ray space placing the sun slightly left of center.
pub(crate) const OCEAN_SUN_RAW_X: f32 = -0.30;

/// Sun elevation Y component in camera ray space placing the sun low above the horizon.
pub(crate) const OCEAN_SUN_RAW_Y: f32 = 0.132;

/// Sun depth Z component in camera ray space.
pub(crate) const OCEAN_SUN_RAW_Z: f32 = 1.62;

/// Eight multi-scale directional Gerstner-trochoidal ocean wave trains `(dir_x, dir_z, freq, amp, speed)` tuned for crisscrossing glassy emerald swells and crisp broken sun-glitter ripples.
pub(crate) const OCEAN_WAVE_SPECTRUM: [[f32; 5]; 8] = [
    [0.18, 0.984, 0.62, 0.230, 0.88],
    [-0.36, 0.933, 1.08, 0.160, 1.18],
    [0.52, 0.854, 1.88, 0.098, 1.62],
    [-0.60, 0.800, 3.10, 0.062, 2.08],
    [0.46, 0.888, 5.15, 0.038, 2.62],
    [-0.68, 0.733, 8.40, 0.024, 3.18],
    [0.74, 0.673, 13.80, 0.015, 3.85],
    [-0.76, 0.650, 22.40, 0.0090, 4.65],
];

/// Total number of 3D origami paper boat triangles projected per frame.
pub(crate) const BOAT_TRI_COUNT: usize = 16;

/// Number of 3D vertices defining the symmetric watertight folded origami paper boat mesh.
pub(crate) const BOAT_VERT_COUNT: usize = 15;

/// Local 3D origami paper boat vertices `[x_length, y_up, z_camera]` in meters (`-z` faces the camera).
pub(crate) const BOAT_LOCAL_VERTS: [[f32; 3]; BOAT_VERT_COUNT] = [
    [-1.50, 0.56, 0.00],
    [1.50, 0.60, 0.00],
    [-0.86, -0.02, -0.28],
    [0.00, -0.02, -0.30],
    [0.86, -0.02, -0.28],
    [0.00, 0.38, -0.58],
    [-0.86, -0.02, 0.28],
    [0.00, -0.02, 0.30],
    [0.86, -0.02, 0.28],
    [0.00, 0.38, 0.58],
    [0.02, 1.38, 0.00],
    [-0.60, 0.28, 0.00],
    [0.60, 0.28, 0.00],
    [0.00, 0.24, -0.26],
    [0.00, 0.24, 0.26],
];

/// Origami paper boat triangle index list `(i0, i1, i2, facet_kind)` where `facet_kind`: `0=outer_left`, `1=center_flap_left`, `2=sail_left`, `3=inner_cavity`, `4=outer_right`, `5=sail_right`, `6=center_flap_right`.
pub(crate) const BOAT_TRIANGLES: [(usize, usize, usize, u8); BOAT_TRI_COUNT] = [
    (11, 13, 10, 2),
    (13, 12, 10, 5),
    (14, 11, 10, 2),
    (12, 14, 10, 5),
    (0, 5, 11, 3),
    (5, 1, 12, 3),
    (0, 11, 9, 3),
    (12, 1, 9, 3),
    (0, 2, 5, 0),
    (2, 3, 5, 1),
    (3, 4, 5, 6),
    (5, 4, 1, 4),
    (6, 0, 9, 0),
    (7, 6, 9, 1),
    (8, 7, 9, 6),
    (1, 8, 9, 4),
];

/// Luminance threshold above which HDR sun and wave glitter radiance enters the quarter-res optical bloom buffer.
pub(crate) const OCEAN_BLOOM_THRESHOLD: f32 = 1.35;