= Hydron Solver =

#type: node
#context: sop
#internal: rvfx::hydron_solver
#icon: /nodes/sop/icons/hydron_source.svg
#tags: rvfx, hydron, flip, fluid, liquid, whitewater, gpu, cuda

"""GPU-accelerated FLIP liquid solver with Narrow Band simulation, Surface Tension, inline or modular Whitewater + 3D Air Advect, GPU Meshing, and async .hyc disk caching."""

RVFX Hydron Solver simulates high-resolution FLIP liquids directly on your NVIDIA RTX GPU, running safely alongside Karma XPU, Redshift, Octane, and other GPU renderers. You can run it as an all-in-one node (particles, whitewater, and GPU mesh together) or keep it in modular mode and hand off directly to downstream [Hydron Mesher|Node:sop/rvfx--hydron_mesher] and [Hydron Whitewater|Node:sop/rvfx--hydron_whitewater] nodes for fast, independent lookdev iterations.

TIP:
    Press *Enter* in the 3D Viewport with this node selected to activate the interactive domain bounding-box handle (`Domain Size` / `Domain Center`) whenever *Auto-Fit Domain* is off. Enable *Show Domain Box* to display the wireframe box in the viewport.

TIP:
    There are no separate Source, Collider, or Sink node types in RVFX Hydron. Wire standard Houdini polygon meshes, point clouds with `@v`, curves, or VDBs directly into Inputs 0–3.

@inputs

Fluid Source / Emitter:
    Input 0. Supplies initial or continuous liquid source geometry:
    - Closed or open polygon geometry for *Bounding Box Fill* (`source_mode = bbox`) on the start frame.
    - Point clouds (`source_mode = points`) with optional `v` (scaled by *Source Velocity Scale*) and persistent `id`.
    - Triangle meshes for *Continuous* emission (`emit_mode = continuous`), reading point `v` when *Use Point Velocity* is enabled or computing automatic finite-difference surface velocities when `@v` is absent.

Collider Geometry:
    Input 1. Optional static, keyframed, or deforming obstacle geometry. Accepts:
    - Polygon meshes (automatically fan-triangulated; reads `@v` or computes automatic GPU finite-difference vertex velocity).
    - OpenVDB SDF volumes (`surface`, `collision`, or `sdf` level sets) plus optional vector `vel` / `v` or scalar `vel.x/y/z` velocity VDBs sampled in parallel via OpenVDB `BoxSampler`.
    - Both polygon meshes and VDB SDFs merged into Input 1 simultaneously, combined via GPU CSG union (`min(phi_mesh, phi_vdb)`).

Sink Geometry:
    Input 2. Optional closed polygon mesh defining a drain volume that despawns FLIP particles (and optionally Whitewater particles when *Sink Kills Whitewater* is enabled).

Forces / VDB Fields (Optional):
    Input 3. Accepts any combination of:
    - One or more [Hydron Force|Node:sop/rvfx--hydron_force] SOPs combined with a Merge SOP (up to 32 simultaneous analytic Wind, Vortex, Point Gravity/Repulsor, and Curl Noise forces plus Pro Curve Force).
    - Raw Houdini polyline/NURBS/Bezier curves (evaluated with the built-in curve fallback).
    - VDB or standard Houdini Volume velocity/force fields named `vel` (`vel.x/y/z`) or `force` (`force.x/y/z`).

@outputs

Geometry & Groups:
    - Point group `flip`: Active FLIP liquid particles (present when *Output Mode* is `Particles` or `Both`).
    - Point groups `ww`, `hydron_whitewater`, `hydron_ww_bubbles`, `hydron_ww_foam`, `hydron_ww_spray`: Whitewater particles and per-phase groups (present when *Enable Whitewater* is on).
    - Point group `hydron_particles`: Combined FLIP + Whitewater particle group when *Output Mode* is `Both`.
    - Primitive group `hydron_mesh`: Watertight sparse GPU Marching Cubes triangle mesh with Houdini clockwise outward winding (present when *Output Mode* is `Mesh` or `Both`).
    - Primitive group `hydron_domain_box`: 12-edge cyan wireframe bounding box when *Show Domain Box* is enabled.
    - Primitive group `hydron_guides`: Color-coded force guides passed through from Input 3 when *Show Force Guides* and *Enable Input Forces* are enabled.

Point Attributes:
    - `P` (`vector3`): World-space particle or mesh vertex positions (always present).
    - `v` (`vector3`): Particle velocity or trilinearly sampled mesh velocity (controlled by *Velocity (v)*, `On` by default).
    - `id` (`int64`): Persistent 64-bit particle ID used for zero-flicker deterministic viewport thinning (controlled by *ID (id)*, `On` by default).
    - `age` (`float`): Particle age in seconds (controlled by *Age (age)*, `On` by default).
    - `life` (`float`): Whitewater lifetime in seconds (controlled by *Life (life)*, `On` by default).
    - `pscale` (`float`): Particle radius in meters (automatically scaled by `1 / cbrt(surface_oversampling)` inside the oversampling band; controlled by *Particle Scale (pscale)*, `On` by default).
    - `Cd` (`vector3`): Preview color driven by *Color Mode* (`Speed Ramp` or `WW State`) and *WW Color Mode* (`State`, `Speed Ramp`, `Age / Life`, or `Density`) when *Color (Cd)* (`On` by default) is enabled. Omitted completely when *Color (Cd)* is off or *Color Mode* is `None`.
    - `vorticity` (`vector3`): Particle curl/vorticity vector when *Vorticity (vorticity)* (`Off` by default) is enabled.
    - `density` (`float`): Whitewater local neighbor density (`0..1`, controlled by *Density (density)*, `On` by default).
    - `ww_state` (`int32`, plus legacy `state`): Whitewater phase (`0 = Bubble`, `1 = Foam`, `2 = Spray`, controlled by *WW State (ww_state)*, `On` by default).
    - `N` (`vector3`, normal): Analytical SDF gradient normals on `hydron_mesh` when *Compute Normals* is enabled.
    - `speed` (`float`): Scalar speed magnitude on `hydron_mesh` vertices.

Detail Attributes (Modular Handoff):
    - `hydron_live_token` (`int64`): Live GPU handoff token used automatically by downstream [Hydron Mesher|Node:sop/rvfx--hydron_mesher] and [Hydron Whitewater|Node:sop/rvfx--hydron_whitewater] nodes.
    - `hydron_sim_frame` (`int32`), `hydron_time_scale` (`float`), `hydron_dx` (`float`), `hydron_domain_origin` (`vector3`), `hydron_domain_size` (`vector3`), `hydron_cache_path` (`string`): Simulation frame, time scale, domain bounds, and active `.hyc` cache path forwarded to downstream Hydron nodes.

@parameters

Enable:
    #id: enable
    Turns simulation cooking on or off. When disabled, particle/mesh cooking is skipped (guide boxes and force guides can still display). Default `On`.

Reset Simulation:
    #id: reset_sim
    Destroys the active GPU simulation state and forces a fresh rebuild from *Start Frame* on the next cook.

== Main ==

Start Frame:
    #id: start_frame
    Timeline frame corresponding to simulation frame `0` (default `1`, UI range `0..1000`). Cooking at or below this frame initializes/rebuilds the simulation.

Time Scale:
    #id: time_scale
    Animatable simulation speed multiplier (default `1.0`, clamped `>= 0.0`, UI slider `0.0..2.0`, manual values `> 2.0` accepted). Keyframe `0.1..0.5` for smooth slow-motion, animate speed ramps (`1.0 -> 0.1 -> 1.0`), or set `0.0` (`<= 1e-6`) for a *True Freeze Frame* that skips solver stepping while keeping VRAM particles, live GPU meshing, and `hydron_time_scale` handoff active.

Division Size (dx):
    #id: dx
    Uniform MAC velocity grid voxel spacing in meters (default `0.03 m`, minimum `0.002 m`). Smaller values capture finer splashes and thinner sheets at higher VRAM and compute cost; automatically safety-clamped if grid cells exceed `60,000,000`.

Narrow Band:
    #id: narrow_band
    Enables GPU Narrow Band FLIP (default `Off`). Restricts particles to a thin shell around the free surface and moving colliders while tracking interior liquid on the Eulerian SDF, drastically cutting particle count and VRAM on large oceans and wakes.

Narrow Band Width (Voxels):
    #id: narrow_band_width_voxels
    Thickness of the active particle band in voxels when *Narrow Band* is enabled (default `4.0`, clamped `2.0..16.0`).

Narrow Band Min Depth (m):
    #id: narrow_band_min_depth_m
    Minimum physical band thickness in meters regardless of `dx` (default `0.08 m`, `0 = disabled`). Prevents the narrow-band shell from becoming too thin at fine voxel sizes.

=== Domain Boundaries ===

Closed -X / +X / -Y / +Y / -Z / +Z:
    #id: closed_neg_x
    Per-face boundary toggles (all `On` by default). When `On`, the domain wall acts as a solid free-slip boundary (`Wall Friction` applies tangentially). When `Off`, the face acts as an atmospheric `p = 0` outflow boundary that deletes particles exiting that face and reports cumulative removals in `Killed`.

Use Custom Domain:
    #id: domain_custom
    Overrides default or auto-fitted bounds with explicit *Domain Size* and *Domain Center* (default `Off`). Automatically enabled by the `RVFX Hydron` shelf builders and interactive viewport handle.

Domain Size:
    #id: domain_size
    Explicit simulation bounding box dimensions `{sx, sy, sz}` in meters (default `(2.00, 1.50, 2.00)`, clamped `0.05..500.0`).

Domain Center:
    #id: domain_center
    Explicit simulation bounding box center `{cx, cy, cz}` in world meters (default `(1.00, 0.75, 1.00)`).

Auto-Fit Domain:
    #id: domain_autofit
    Automatically computes tight domain bounds around connected Source, Collider, and Sink inputs plus *Fit Padding (m)* at simulation start (default `Off`). Takes precedence over *Use Custom Domain* when enabled.

Fit Padding (m):
    #id: domain_fit_padding
    Extra padding in meters added on all sides when *Auto-Fit Domain* is active (default `0.2 m`, clamped `0.0..5.0`).

=== Live GPU Telemetry ===

Info:
    #id: info_telemetry
    Read-only multi-line GPU HUD displaying GPU model, SM architecture, VRAM usage/peak, grid resolution, `dx`, Narrow Band/Full-Vol mode, MG-PCG levels, active and viewport particle counts, Whitewater/Air Advect stats, Mesher/Collider timings, open boundaries, cache status, any active FLIP particle cap warning, and step/D2H/GDP timings.

== Sourcing ==

Use Input 0 Source:
    #id: use_input_source
    Reads geometry from Input 0 to initialize or emit liquid particles (default `On`).

Emit Mode:
    #id: emit_mode
    Controls how Input 0 spawns fluid:
    - `Initial Frame Only` (default): Spawns fluid volume/points once at *Start Frame*.
    - `Continuous`: Emits particles continuously from the Input 0 mesh every frame while *Emit Active* is on.

Source Input Mode:
    #id: source_mode
    When *Emit Mode* is `Initial Frame Only`:
    - `Bounding Box Fill` (default): Fills the bounding box of Input 0 with stratified jittered FLIP particles.
    - `Input Points`: Directly uploads Input 0 points (`P`, optional `v`, `id`) as the initial particle set.

Source Velocity Scale:
    #id: source_vel_scale
    Multiplier applied to Input 0 point `@v` when *Source Input Mode* is `Input Points` (default `1.0`).

Emit Active:
    #id: emit_active
    Keyframeable toggle gating continuous emission on the current frame (default `On`). Use expressions such as `int($FF <= 36)` to stop pouring cleanly.

Use Point Velocity (@v):
    #id: use_point_vel
    When *Emit Mode* is `Continuous`, samples point `@v` from the Input 0 emitter mesh (default `On`). When off, uses finite-difference mesh motion instead.

Emitter Velocity Scale:
    #id: emitter_vel_scale
    Multiplier applied to continuous emitter velocity before *Add Velocity* (default `1.0`).

Add Velocity:
    #id: emitter_add_vel
    Constant world-space velocity offset `{vx, vy, vz}` in `m/s` added to continuously emitted particles (default `(0.0, 0.0, 0.0)`).

=== Collider (Input 1) ===

Use Input 1 Collider:
    #id: use_input_collider
    Enables collision against polygon meshes and/or OpenVDB SDFs connected to Input 1 (default `On`).

Collision Padding:
    #id: collider_padding
    Offsets the collider surface in voxels (default `0.0`, clamped `-2.0..4.0`). Positive values expand the solid boundary outward.

Thin Shell Thickness:
    #id: collider_shell_thickness
    Thickens open or thin-walled meshes (cups, bowls, curved planes, ship hulls) by this radius in voxels so fast liquid cannot tunnel through single-sided surfaces (default `0.0`, clamped `0.0..4.0`; `1.5` recommended for thin open vessels).

Collider Vel Scale:
    #id: collider_vel_scale
    Multiplier on collider surface velocity from `@v` or automatic GPU finite differences (default `1.0`, clamped `0.0..3.0`).

Invert Collider:
    #id: collider_invert
    Inverts the collider SDF sign so liquid is contained inside a closed vessel rather than excluded from its exterior (default `Off`).

=== Sink / Drain (Input 2) ===

Enable Sink (Input 2):
    #id: enable_sink
    Enables particle despawning inside the triangle mesh wired to Input 2 (default `On`).

Sink Kills Whitewater:
    #id: sink_kills_ww
    Also removes Whitewater particles that enter the Input 2 sink volume (default `On`).

== FLIP ==

Min Substeps:
    #id: min_substeps
    Minimum solver substeps per timeline frame (default `1`, UI `1..10`, minimum `1`).

Max Substeps:
    #id: max_substeps
    Maximum CFL-adaptive substeps per timeline frame (default `2`, UI `1..10`, hard solver cap `32`). Increase to `4..12` for macro small-scale `dx <= 0.01 m` pours or very fast animated colliders.

Max FLIP Particles:
    #id: max_flip_particles
    Optional explicit ceiling on active FLIP particles (`0` = automatic VRAM-safe ceiling based on detected GPU VRAM and Narrow Band settings, exceeding 20M on 24 GB GPUs when free VRAM permits). Whenever emission or seeding hits the active cap, the node logs a warning and reports it in *Live GPU Telemetry*.

FLIP/PIC Blend:
    #id: flip_pic_blend
    Substep-invariant exponential velocity smoothing weight between pure FLIP (`0.0`, energetic/splashy) and pure PIC (`1.0`, viscous/damped). Default `0.10` (`90%` FLIP / `10%` PIC).

Velocity Smoothing:
    #id: velocity_smoothing
    Substep-invariant spatial face velocity filter strength (default `0.05`, clamped `0.0..1.0`). Reduces high-frequency FLIP particle jitter without killing bulk momentum.

Wall Friction:
    #id: wall_friction
    Tangential boundary drag on closed tank walls and Input 1 colliders (default `0.05`, clamped `0.0..1.0`).

Reseeding:
    #id: reseed
    Maintains uniform particle distribution (`8` particles per voxel) by pruning overcrowded cells and spawning in underresolved liquid cells (default `On`).

Surface Oversampling:
    #id: surface_oversampling
    Reseeding density multiplier applied inside the free-surface band (default `1.0`, slider `1.0..4.0`, manual values accepted up to `16.0`). Works on both closed volumes and continuous emitters/flowing rivers—higher values (`2.0..12.0`) pack finer particles along splashes, pouring streams, and thin sheets and automatically shrink surface `pscale` for crisper meshes with minimal extra solve time.

Oversampling Bandwidth:
    #id: oversampling_bandwidth
    Thickness of the free-surface oversampling band in voxels (`|phi| <= bw * dx`; default `1.5`, clamped `0.5..4.0`).

=== Surface Tension ===

Enable Surface Tension:
    #id: enable_surface_tension
    Enables Ghost-Fluid GPU Surface Tension in pressure projection with automatic capillary CFL substepping (default `Off`, zero overhead when off).

Surface Tension:
    #id: surface_tension
    Physical surface tension coefficient `sigma` in `N/m` (default `0.072`, water at 20 °C). Higher values pull thin threads into droplets and round zero-G blobs faster.

Curvature Smoothing:
    #id: st_curvature_smooth
    Band-limited Laplacian SDF smoothing passes (`0..3`, default `1`) applied before computing normalized curvature `kappa` to suppress stair-step noise.

== Whitewater ==

Enable Whitewater:
    #id: enable_ww
    Enables single-pass coupled GPU Whitewater 2.0+ (default `Off`). For independent lookdev without re-simulating FLIP, leave this off and wire the solver into [Hydron Whitewater|Node:sop/rvfx--hydron_whitewater].

Bubbles / Foam / Spray:
    #id: ww_enable_bubbles
    Independent toggles for submerged *Bubbles* (default `On`), surface *Foam* (default `On`), and airborne *Spray* (default `Off`). Keep *Spray* off for calm wakes or turn it on for waterfalls and violent impacts.

Max WW Particles:
    #id: max_ww_particles
    Hard GPU allocation cap for Whitewater particles (default `2,000,000`, clamped `100,000..20,000,000`).

=== Emission & Wedging ===

WW Emission Scale:
    #id: ww_emission_scale
    Global multiplier on Whitewater birth rate across all active phases (default `1.0`, range `0.0..50.0`).

Bubbles Scale / Foam Scale / Spray Scale:
    #id: ww_bubbles_scale
    Per-phase emission multipliers (defaults `1.0`, UI `0.0..20.0`). Enabled when the corresponding phase toggle is active.

WW Random Seed:
    #id: ww_random_seed
    Integer seed for stochastic birth and noise variations when wedging sims (default `0`).

=== Emission Control ===

Speed Gate Min (m/s) / Speed Gate Max (m/s):
    #id: ww_emit_speed_min
    Smoothstep speed gate (`m/s`, defaults `0.0` / `0.0` = disabled). When *Speed Gate Max* > *Speed Gate Min*, multiplies Whitewater emission by `smoothstep(min, max, |v|)` to silence calm-water emission.

Curvature Weight / Curvature Min / Curvature Max:
    #id: ww_emit_curv_weight
    Adds positive free-surface curvature emission (`0.0` default = unchanged baseline). When *Curvature Weight* > `0`, smoothsteps positive surface curvature between *Curvature Min* (`0.0`) and *Curvature Max* (`5.0`) to boost crest and splash birth.

Birth Noise Size (m) / Birth Noise Contrast:
    #id: ww_emit_noise_size
    World-space 3D fBm birth breakup (`size = 0.25 m`, `contrast = 0.0` default = disabled). Modulates spawn probability at birth (`lerp(1.0, noise_mask, contrast)`) for organic patchy breakup.

=== Foam Webbing, Erosion & Spray Physics ===

Cellular Webbing:
    #id: ww_cellular_strength
    Strength of multi-scale repellent forces that organize surface foam into lacy cellular filaments and open voids (default `0.65`, clamped `0.0..2.0`).

Repellent Radius (dx):
    #id: ww_repellent_radius_dx
    Spatial radius in liquid voxels for cellular foam repulsion (default `2.5`, clamped `0.5..8.0`).

Foam Relaxation:
    #id: ww_foam_relaxation
    Smoothing relaxation applied to foam repellent drift (default `0.25`, clamped `0.0..1.5`).

Density Erosion Rate:
    #id: ww_erosion_rate
    Rate at which isolated low-density foam/bubbles erode and dissolve faster than dense rafts (default `0.75`, clamped `0.0..3.0`).

Mist Aerodynamic Drag:
    #id: ww_mist_drag
    Aerodynamic drag applied to airborne spray and fine mist particles (default `1.20`, clamped `0.0..5.0`).

Curl Turbulence:
    #id: ww_curl_turbulence
    3D divergence-free curl turbulence applied to airborne spray/mist (default `0.60`, clamped `0.0..3.0`).

Surface Lock Strength:
    #id: ww_surface_lock_strength
    Projection strength keeping Foam particles locked to the moving liquid free surface `phi = 0` (default `0.85`, clamped `0.0..1.0`).

Fractal Noise Scale:
    #id: ww_fractal_noise_scale
    Spatial scale multiplier for emission and breakup noise (default `1.00`, clamped `0.1..5.0`).

WW Boundary Mode:
    #id: ww_boundary_mode
    Controls Whitewater behavior at the FLIP domain bounds: `Open (Ballistic)` (default, open `+Y` and `+-X/Z` ballistic flight with far-kill safety margin), `Kill at Bounds (Outflow)` (`+Y` open, immediate kill at `+-X/Z` and `-Y`), or `Closed Box` (clamp all 6 walls).

=== Air Advect (Waterfall / Mist Billow) ===

Enable Air Advect:
    #id: enable_air_advect
    Enables the coarse-grid 3D incompressible Eulerian air velocity solver coupled to liquid entrainment and spray/mist drag (default `Off`). Essential for realistic billowing waterfall plunge-pool mist clouds.

Air Grid Scale:
    #id: air_grid_scale
    Coarse grid factor relative to fluid `dx`: `2x Coarser (Detailed)` (default), `3x Coarser`, or `4x Coarser (Fast)`.

Air Entrainment:
    #id: air_entrainment
    Momentum transfer rate (`1/s`) from fast falling liquid into surrounding air cells (default `8.0`).

Air Advect Strength:
    #id: air_advect_strength
    Aerodynamic coupling (`1/s`) pulling airborne Whitewater Spray/Mist toward the 3D air velocity field (default `4.0`).

Air Dissipation:
    #id: air_dissipation
    Exponential damping (`1/s`) decaying air velocity away from liquid (default `0.5`).

Vorticity Confinement:
    #id: air_vorticity
    Swirl reinforcement inside the coarse air grid to preserve rolling mist vortices (default `0.35`).

Projection Iterations:
    #id: air_pressure_iters
    Incompressible pressure projection iterations on the coarse air grid (default `20`, clamped `0..100`).

== Forces ==

=== Gravity ===

Enable Gravity:
    #id: enable_gravity
    Enables world gravity (default `On`). Turn off for zero-gravity orbital/abstract effects with Point Gravity or Curve Force.

Gravity:
    #id: gravity
    World gravity acceleration vector `{gx, gy, gz}` in `m/s^2` (default `(0.0, -9.81, 0.0)`).

=== Global Drag ===

Global Drag:
    #id: drag_coeff
    Global velocity damping rate (`1/s`) applied to particles (default `0.0`).

=== Input 3: Modular GPU Forces ===

Enable Input Forces:
    #id: enable_input_forces
    Reads [Hydron Force|Node:sop/rvfx--hydron_force] primitives and curves wired into Input 3 (default `On`).

Input Force Scale:
    #id: input_force_scale
    Global multiplier applied to all Input 3 procedural forces (default `1.0`).

=== Input 3: VDB Fields ===

Enable VDB Fields:
    #id: enable_vdb_fields
    Samples `vel` and `force` VDB or Houdini Volume grids wired into Input 3 (default `On`).

VDB Force Scale:
    #id: vdb_force_scale
    Acceleration multiplier for Input 3 `force` volumes (default `1.0`).

VDB Velocity Blend:
    #id: vdb_vel_blend
    Blend weight (`0.0..1.0`, default `0.0`) pulling particle velocity toward Input 3 `vel` volumes.

== Mesh ==

Output Mode:
    #id: output_mode
    Selects node output geometry: `Particles` (default), `Mesh` (inline Sparse GPU Mesher), or `Both` (`hydron_particles` + `hydron_mesh` groups). For adaptive velocity-masked meshing and independent mesh lookdev, keep this on `Particles` and connect [Hydron Mesher|Node:sop/rvfx--hydron_mesher] downstream.

Voxel Scale:
    #id: voxel_scale
    Meshing voxel size `h = dx * voxel_scale` (default `0.75`, clamped `0.5..1.5`).

Influence Scale:
    #id: influence_scale
    Particle radius splat multiplier (default `1.75`, clamped `0.5..3.5`).

Droplet Scale:
    #id: droplet_scale
    Radius multiplier for isolated airborne droplets (default `0.75`, clamped `0.1..1.5`).

Smoothing:
    #id: smoothing_iters
    GPU morphological `Dilate -> Smooth -> Erode` passes (default `2`, clamped `0..5`).

Subtract Colliders:
    #id: subtract_colliders
    Subtracts Input 1 collider geometry from the meshed liquid volume on the GPU (default `Off`). Prevents liquid mesh clipping through glass cups, vessels, or rocks.

Collider Offset (m):
    #id: collider_offset
    Shifts the subtracted collider surface in meters (default `0.0 m`, UI `-0.1..0.1 m`). Use small positive values (`0.001..0.003 m`) for clean glass refraction contact without air gaps.

Compute Normals:
    #id: compute_normals
    Computes smooth point normals `N` on the GPU mesh (default `On`).

Trim Domain Boundaries:
    #id: trim_domain_bounds
    Cleanly clips flat liquid walls pressed against the simulation domain boundary using exact plane clipping (default `Off`). Eliminates sawtooth edges and tank-wall corner fillets.

Trim Mode / -X / +X / -Y / +Y / -Z / +Z:
    #id: trim_bounds_mode
    Selects which domain faces are clipped when *Trim Domain Boundaries* is enabled: `Surface Only (Sides + Bottom)` (default), `Closed FLIP Walls`, `All 6 Domain Faces`, or `Custom Faces` (controlled by the six per-face toggles).

=== Velocity Smoothing ===

Adaptive Velocity Smoothing:
    #id: vel_smooth_enable
    Enables *additive* velocity-driven adaptive SDF smoothing on top of base *Smoothing* (`smoothing_iters`) on the inline GPU mesher so slow/calm water (`|v| <= Velocity Min`) receives extra smoothing while fast splashes (`|v| >= Velocity Max`) remain sharp (default `Off`). Base *Smoothing* always runs uniformly whether this toggle is on or off; set *Smoothing = 0* with *Smooth Strength > 0* for purely velocity-masked smoothing.

Velocity Min / Velocity Max:
    #id: vel_smooth_min
    Speed thresholds in `m/s` (defaults `0.5` / `3.0 m/s`) mapping `|v| <= min` to mask `1.0` and `|v| >= max` to mask `0.0`.

Smooth Strength:
    #id: vel_smooth_strength
    Additive masked smoothing pass count on top of base *Smoothing* (`0.0..10.0` UI range, internal cap `0.0..32.0`, default `1.0`). `0.0` skips the additive stage completely so mesh geometry matches disabled bit-for-bit; values `> 0.0` run `floor(strength)` full masked passes plus an optional fractional pass on calm regions while keeping fast splashes sharp.

Invert Velocity Mask:
    #id: vel_smooth_invert
    Inverts the evaluated velocity mask (`1.0 - mask`, default `Off`).

== Visualization ==

Show Domain Box:
    #id: show_domain_box
    Appends a 12-edge wireframe box in primitive group `hydron_domain_box` showing the active simulation domain (default `Off`).

Show Force Guides:
    #id: show_force_guides
    Passes color-coded `hydron_guides` wireframe curves from Input 3 into the solver's viewport output (default `On`).

Visualize Emission:
    #id: ww_visualize_emission
    Toggles a read-only 1-frame emission heatmap preview on the current frame's FLIP points (`f@emit` in `[0..1]` and deep blue -> yellow -> red `Cd`) without stepping Whitewater.

Visualize Smooth Mask:
    #id: vel_smooth_visualize
    Writes `f@smooth_mask` (`0..1`) and a deep blue (`0.0` = sharp) -> yellow (`0.5`) -> red (`1.0` = max smoothing) heatmap `Cd` onto inline mesh vertices (default `Off`).

=== Viewport Thinning ===

Viewport FLIP % / Viewport WW %:
    #id: vp_flip_pct
    Flicker-free viewport display thinning percentage (`0..100%`, defaults: FLIP `10%`, WW `50%`). Keeps particle IDs consistent across frames so scrubbing stays fast without visual popping.

Export Full Res on Render:
    #id: full_res_render
    Automatically outputs 100% of active FLIP and Whitewater particles when rendering or writing ROP caches (default `On`).

=== Particle Color ===

Color Mode:
    #id: color_mode
    Selects FLIP particle `Cd` preview coloring (controlled by *Color (Cd)*):
    - `Speed Ramp` (default): Maps particle speed (`|v|`) from *Speed Ramp Min* to *Speed Ramp Max* through the *Speed Color Gradient* RGB ramp.
    - `WW State`: Tints FLIP particles deep ocean blue while Whitewater follows *WW Color Mode*.
    - `None`: Skips creating and writing `Cd` on FLIP particles completely, keeping geometry clean for downstream `Color` SOPs and Karma XPU shaders.

Speed Ramp Min (m/s):
    #id: color_speed_min
    Lower velocity bound (`m/s`, default `0.0 m/s`) mapped to `0.0` on *Speed Color Gradient* when *Color Mode* is `Speed Ramp`.

Speed Ramp Max (m/s):
    #id: color_speed_max
    Upper velocity bound (`m/s`, default `3.8 m/s`) mapped to `1.0` on *Speed Color Gradient* when *Color Mode* is `Speed Ramp`.

Speed Color Gradient:
    #id: speed_color_ramp
    Native Houdini RGB color ramp (`#143280` -> `#00B8E6` -> `#F2FBFF` default ocean-to-foam gradient) baked once per cook into a 256-entry RGB lookup table when *Color Mode* is `Speed Ramp`.

WW Color Mode:
    #id: ww_color_mode
    Selects integrated Whitewater particle `Cd` coloring:
    - `State (Spray / Foam / Bubbles)` (default): Uses *Spray Color*, *Foam Color*, and *Bubble Color*.
    - `Speed Ramp`: Maps Whitewater speed (`|v|`) from *WW Speed Min* to *WW Speed Max* through *WW Color Gradient*.
    - `Age / Life`: Maps normalized particle age (`age / life` in `0..1`) through *WW Color Gradient* for tuning fade-out and density erosion.
    - `Density`: Maps Whitewater `density` (`0..1`) through *WW Color Gradient*.
    - `None`: Skips creating and writing `Cd` on Whitewater particles completely. If FLIP *Color Mode* is also `None` (or only Whitewater is output), no `Cd` attribute is created at all.

Spray Color:
    #id: ww_spray_color
    Editable RGB color for airborne Whitewater Spray particles (default `(0.75, 0.92, 1.0)`) when *WW Color Mode* is `State (Spray / Foam / Bubbles)`.

Foam Color:
    #id: ww_foam_color
    Editable RGB color for surface Whitewater Foam particles (default `(0.98, 0.99, 1.0)`) when *WW Color Mode* is `State (Spray / Foam / Bubbles)`.

Bubble Color:
    #id: ww_bubble_color
    Editable RGB color for submerged Whitewater Bubble particles (default `(0.15, 0.55, 0.85)`) when *WW Color Mode* is `State (Spray / Foam / Bubbles)`.

WW Speed Min (m/s):
    #id: ww_speed_min
    Lower velocity bound (`m/s`, default `0.0 m/s`) mapped to `0.0` on *WW Color Gradient* when *WW Color Mode* is `Speed Ramp`.

WW Speed Max (m/s):
    #id: ww_speed_max
    Upper velocity bound (`m/s`, default `5.0 m/s`) mapped to `1.0` on *WW Color Gradient* when *WW Color Mode* is `Speed Ramp`.

WW Color Gradient:
    #id: ww_color_ramp
    Native Houdini RGB color ramp baked once per cook into a 256-entry RGB lookup table when *WW Color Mode* is `Speed Ramp`, `Age / Life`, or `Density`.

== Output ==

=== Export Attributes ===

Velocity (v) / ID (id) / Age (age) / Life (life) / Particle Scale (pscale) / Color (Cd) / Vorticity (vorticity) / Density (density) / WW State (ww_state):
    #id: attr_v
    Per-attribute export toggles (`v`, `id`, `age`, `life`, `pscale`, `Cd`, `density`, `ww_state` default `On`; `vorticity` defaults `Off`). Unchecked attributes are skipped on GPU download and omitted from Houdini point attributes to avoid unnecessary PCIe copy time and geometry memory overhead.

=== Disk Cache (Async .hyc) ===

Cache Mode:
    #id: cache_mode
    Double-buffered asynchronous pinned-memory `.hyc` cache mode:
    - `Off` (default): Live VRAM simulation only.
    - `Write (Async)`: Simulates and writes `<Cache Directory>/v<NNN>/<prefix>_####.hyc` in a background thread.
    - `Read (Playback)`: Reads cached `.hyc` frames from disk for instant timeline scrubbing.
    - `Auto (Read or Sim+Write)`: Reads `.hyc` if present on disk; otherwise simulates and writes. Flags stale caches via `.hyc_sig` if simulation parameters changed.

Frame Range:
    #id: cache_range
    Start Frame, End Frame, and Increment (`Start / End / Inc`, defaulting to `$FSTART`, `$FEND`, `1`) used when clicking *Cache*.

Cache Version:
    #id: cache_version
    Integer cache version (`1..999`, default `1`), creating `v001`, `v002`, etc. subfolders.

Cache Directory / File Prefix:
    #id: cache_dir
    Base folder (default `"$HIP/cache/hydron"`) and filename prefix (default `"hydron"`).

Cache FLIP / Cache Whitewater / Cache Mesh:
    #id: cache_flip
    Channel toggles controlling which streams are written into `.hyc` files (all `On` by default).

Cache / Clear Disk Cache:
    #id: cache_save_to_disk
    *Cache* steps and writes the configured *Frame Range* to `.hyc` with an interruptible progress bar (`ESC` cancels cleanly) and automatically flushes all pending async disk writes before returning; *Clear Disk Cache* flushes and deletes `.hyc` / `.hyc_sig` files in the active version folder.

== About ==

Info / Diagnostics:
    #id: about_info
    Read-only panel displaying `RVFX Hydron v1.0-beta1`, `Hydron Core v1.0.0`, build date, Houdini target version, offline VIP Beta license validity (`Valid until 2027-01-31` and days remaining), detected GPU device and VRAM summary, and copyright notice (`Copyright (c) 2026 RVFX Ltd. All rights reserved.`).

Open Manual:
    #id: about_open_manual
    Opens the packaged `RVFX_Hydron_Manual.html` documentation in your default web browser.

Copy System Info:
    #id: about_copy_sysinfo
    Copies a compact multi-line diagnostics summary (plugin/core version, Houdini version, OS, GPU/VRAM, and VIP Beta expiry status) to the clipboard for beta bug reports.

@related
- [Node:sop/rvfx--hydron_mesher]
- [Node:sop/rvfx--hydron_whitewater]
- [Node:sop/rvfx--hydron_force]
