simvx.graphics.renderer.ocean_pass

Built-in FFT ocean pass (design D11, RM-E7).

A dedicated forward pass (its own GLSL shader pair, like the water / grid passes) drawn in the TRANSPARENT slot after the scene colour/depth copy (A7/A8), so it refracts what is behind it. It reuses the :class:~simvx.core.water.WaterMaterial shading model of the Gerstner water pass (design D16) but replaces the analytic vertex displacement with a sampled FFT displacement map and the analytic normal with the FFT slope map (design D11).

The FFT runs entirely on the GPU (:class:.ocean_compute.OceanCompute, design D11 / RM-E7gpu): three compute shaders time-evolve the frozen spectrum, run a Stockham radix-2 inverse FFT and assemble the per-cascade displacement / slope / foam fields directly into two sampled texture-2D-arrays (one layer per cascade), recorded into the frame command buffer BEFORE the main render pass begins (compute writes to sampled images are illegal inside a render pass). The ocean shader then samples them in the transparent slot. :mod:.ocean_fft stays the canonical spectrum builder (frozen h0 Phillips spectrum + dispersion, uploaded once per :meth:OceanFFT.configure) and the CPU reference the tests pin against; only the per-frame FFT hot path lives on the GPU (no per-frame numpy FFT, no per-frame field upload). The compute chain only runs when a visible OceanSurface3D is in the scene, so with no ocean nothing here runs and the frame is byte-identical (zero-cost when unused).

Set 0 is the shared forward descriptor set (FrameGlobals b13, environment cube b4, scene colour/depth b14/b15); set 1 is this pass’s own camera UBO (b0), the per-frame surface SSBO (b1) and the displacement / slope texture arrays (b2/b3).

Cascade texture size + count come from the design-D13 quality table (QualitySettings.ocean_size / ocean_cascades), resolved through WorldEnvironment.quality_tier so a tier means the same ocean everywhere.

Module Contents

Classes

OceanPass

Renders every submitted OceanSurface3D as an FFT ocean grid.

Data

API

simvx.graphics.renderer.ocean_pass.__all__

[‘OceanPass’, ‘OCEAN_SURFACE_DTYPE’]

simvx.graphics.renderer.ocean_pass.log

‘getLogger(…)’

simvx.graphics.renderer.ocean_pass.MAX_SURFACES

16

class simvx.graphics.renderer.ocean_pass.OceanPass(engine: Any)[source]

Renders every submitted OceanSurface3D as an FFT ocean grid.

Initialization

setup(ssbo_layout: Any, render_pass: Any = None) None[source]

Create GPU resources. ssbo_layout is the shared forward set-0 layout.

rebuild_pipeline(render_pass: Any) None[source]
begin_frame() None[source]
submit(model_matrix: numpy.ndarray, material: Any, subdivisions: int, size: tuple[float, float]) None[source]
property has_surfaces: bool[source]
prepare(cmd: Any, env: Any, time: float) None[source]

Record the GPU FFT compute chain into cmd (design D11 / RM-E7gpu).

MUST be called before the main render pass begins (the compute chain writes the sampled displacement / slope arrays, illegal inside a render pass) and only when :attr:has_surfaces. Rebuilds the spectrum on a quality change, re-uploads the frozen h0 buffer on a wind change, then dispatches spectrum -> Stockham IFFT -> assemble.

render(cmd: Any, view_proj: numpy.ndarray, cam_pos: numpy.ndarray, near: float, far: float, has_skybox: bool, extent: tuple[int, int], ssbo_set: Any) None[source]

Record the ocean draws. ssbo_set is the shared forward set 0.

cleanup() None[source]