euv_core/game/fluid/renderer/struct.rs
1use super::*;
2
3/// Persistent zero-allocation photorealistic optical liquid renderer producing RGBA8 frames with Snell refraction, Beer-Lambert depth absorption, Fresnel reflections, optical caustics, buoyant bodies, foam, and glass vessel framing.
4#[derive(Clone, Data, Debug)]
5pub struct LiquidOpticalRenderer {
6 /// Active scalar field grid width in cells.
7 #[get(type(copy))]
8 pub(crate) field_w: usize,
9 /// Active scalar field grid height in cells.
10 #[get(type(copy))]
11 pub(crate) field_h: usize,
12 /// Smoothed liquid density isosurface field `φ(x, y)`.
13 pub(crate) phi: Vec<f32>,
14 /// Separable horizontal smoothing scratch buffer for `φ`.
15 pub(crate) phi_tmp: Vec<f32>,
16 /// Optical fluid thickness field driving Beer-Lambert absorption and Snell ray depth.
17 pub(crate) thickness: Vec<f32>,
18 /// Separable horizontal smoothing scratch buffer for `thickness`.
19 pub(crate) thick_tmp: Vec<f32>,
20 /// Aerated wave-crest foam intensity field.
21 pub(crate) foam: Vec<f32>,
22 /// Precomputed surface gradient x-component `∂φ/∂x`.
23 pub(crate) grad_x: Vec<f32>,
24 /// Precomputed surface gradient y-component `∂φ/∂y`.
25 pub(crate) grad_y: Vec<f32>,
26 /// Precomputed optical caustic focusing intensity field derived from surface curvature.
27 pub(crate) caustic: Vec<f32>,
28 /// Last rendered output width in pixels.
29 #[get(type(copy))]
30 pub(crate) last_width: u32,
31 /// Last rendered output height in pixels.
32 #[get(type(copy))]
33 pub(crate) last_height: u32,
34}
35
36/// Immutable per-frame optical shading context shared safely across parallel horizontal scanline bands.
37#[derive(Clone, Copy, Debug)]
38pub(crate) struct FluidShadeParams {
39 /// Output framebuffer width in pixels.
40 pub(crate) out_w: usize,
41 /// Output framebuffer height in pixels.
42 pub(crate) out_h: usize,
43 /// Scalar field width in cells.
44 pub(crate) field_w: usize,
45 /// Scalar field height in cells.
46 pub(crate) field_h: usize,
47 /// Physical vessel width in meters.
48 pub(crate) vessel_w: f32,
49 /// Physical vessel height in meters.
50 pub(crate) vessel_h: f32,
51 /// Normalized gravity up-vector x-component for sky reflection alignment.
52 pub(crate) up_x: f32,
53 /// Normalized gravity up-vector y-component for sky reflection alignment.
54 pub(crate) up_y: f32,
55 /// Glass vessel inner margin in pixels.
56 pub(crate) bezel_px: f32,
57 /// Glass vessel outer corner radius in pixels.
58 pub(crate) corner_px: f32,
59 /// Active buoyant floating body count.
60 pub(crate) body_count: usize,
61 /// Snapshot of active buoyant bodies copied onto stack for lock-free parallel shading.
62 pub(crate) bodies: [BuoyantBody; FLUID_MAX_BUOYANT_BODIES],
63}
64
65/// Read-only borrowed slice bundle of precomputed scalar optical fields for parallel scanline shading.
66#[derive(Clone, Copy, Debug)]
67pub(crate) struct FluidFieldViews<'a> {
68 /// Smoothed liquid density isosurface field `φ`.
69 pub(crate) phi: &'a [f32],
70 /// Smoothed optical fluid thickness field.
71 pub(crate) thickness: &'a [f32],
72 /// Aerated wave-crest foam intensity field.
73 pub(crate) foam: &'a [f32],
74 /// Precomputed surface gradient x-component.
75 pub(crate) grad_x: &'a [f32],
76 /// Precomputed surface gradient y-component.
77 pub(crate) grad_y: &'a [f32],
78 /// Precomputed optical caustic focusing intensity field.
79 pub(crate) caustic: &'a [f32],
80}