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

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

/// Hardware safety upper bound per axis for native 1:1 physical optical fluid surfaces (`16384px`, lossless up to 16K).
pub const FLUID_RENDER_MAX_DIM: u32 = 16_384;

/// Minimum explicit user-configured optical resolution scale multiplier (`0.25x`).
pub const FLUID_MIN_RESOLUTION_SCALE: f32 = 0.25;

/// Maximum explicit user-configured optical resolution scale multiplier (`2.0x` supersampling).
pub const FLUID_MAX_RESOLUTION_SCALE: f32 = 2.0;

/// Default lossless optical resolution scale multiplier (`1.0x` native 1:1 physical pixels).
pub const FLUID_DEFAULT_RESOLUTION_SCALE: f32 = 1.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 irrational-angle isotropic Gerstner-trochoidal ocean wave trains `(dir_x, dir_z, freq, amp, speed)` tuned for crisscrossing glassy emerald swells and organic broken sun-glitter ripples.
pub(crate) const OCEAN_WAVE_SPECTRUM: [[f32; 5]; 8] = [
    [0.2419, 0.9703, 0.56, 0.205, 0.84],
    [-0.5592, 0.8290, 0.94, 0.145, 1.12],
    [0.7986, 0.6018, 1.58, 0.092, 1.48],
    [-0.9455, 0.3256, 2.63, 0.056, 1.92],
    [0.5299, 0.8480, 4.38, 0.034, 2.46],
    [-0.7880, -0.6157, 7.21, 0.021, 3.08],
    [0.7314, -0.6820, 11.85, 0.013, 3.82],
    [-0.3746, 0.9272, 19.30, 0.0078, 4.68],
];

/// 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;

/// Camera horizon vertical damping rate in Hertz decoupling ocean horizon pitch from transient PBF particle slosh.
pub(crate) const FLUID_CAM_HORIZON_DAMP_HZ: f32 = 2.5;

/// Maximum gentle steady-state fill-level horizon offset (`±0.012` normalized height) preventing particle bounce from shaking the horizon.
pub(crate) const FLUID_CAM_MAX_FILL_SHIFT: f32 = 0.012;

/// Camera horizon roll damping rate in Hertz for smooth dt-invariant gyroscope and virtual-tilt horizon tracking.
pub(crate) const FLUID_CAM_ROLL_DAMP_HZ: f32 = 7.5;

/// Camera roll angular deadband in radians suppressing handheld MEMS accelerometer micro-tremor on the horizon.
pub(crate) const FLUID_CAM_ROLL_DEADBAND_RAD: f32 = 0.0015;

/// Ocean wave agitation damping rate in Hertz preventing transient PBF velocity spikes from twitching wave heights and boat heave.
pub(crate) const FLUID_CAM_AGITATION_DAMP_HZ: f32 = 3.5;

/// Sailboat horizontal and angular sway damping rate in Hertz isolating the rendered boat from 60Hz PBF particle impact jitter.
pub(crate) const FLUID_CAM_BOAT_SWAY_DAMP_HZ: f32 = 6.0;