simvx.graphics.renderer.ocean_compute

GPU FFT ocean compute chain (design D11, RM-E7gpu).

Moves the per-frame ocean hot path off the CPU: instead of a numpy inverse FFT + a per-frame texture upload (:class:OceanFFT.evaluate), three compute shaders run entirely on the GPU each frame, writing straight into the sampled displacement / slope texture-2D-arrays the ocean shader reads (so ocean.vert / ocean.frag are unchanged):

  1. ocean_spectrum.comp – time-evolve the frozen h0 spectrum (uploaded once per :meth:OceanFFT.configure) into four packed complex IFFT inputs per cascade (two real fields per complex transform, design D11).

  2. ocean_fft.comp – radix-2 Stockham autosort inverse FFT: log2(N) row stages then log2(N) column stages, ping-ponging two RGBA32F storage image-2D-arrays (one dispatch per stage covers every cascade + packed field).

  3. ocean_assemble.comp – unpack + scale the transforms, fold in choppiness, accumulate the Jacobian folding foam, and write the b2 displacement + b3 slope arrays the forward ocean pass samples.

Owns the FFT ping-pong images, the static spectrum SSBO and the two output arrays; :class:OceanPass binds the output views into its render descriptor set. Reuses the project compute idiom (glslc .comp via

func:

create_compute_pipeline, storage images, push constants, ping-pong) from the SSR / SSGI / particle passes. Everything here only runs when a visible OceanSurface3D is in the scene, so with no ocean the frame is byte-identical.

Module Contents

Classes

OceanCompute

GPU compute FFT: time-evolve + inverse-FFT + assemble the ocean fields.

Data

API

simvx.graphics.renderer.ocean_compute.__all__

[‘OceanCompute’]

simvx.graphics.renderer.ocean_compute.log

‘getLogger(…)’

class simvx.graphics.renderer.ocean_compute.OceanCompute(engine: Any)[source]

GPU compute FFT: time-evolve + inverse-FFT + assemble the ocean fields.

Initialization

setup() None[source]

Create the three shared compute pipelines (size-independent).

property disp_view: Any[source]
property grad_view: Any[source]
property size: int[source]
property cascades: int[source]
resize(fft: simvx.graphics.renderer.ocean_fft.OceanFFT, size: int, cascades: int) None[source]

(Re)allocate the size-dependent resources for an N x N / cascades ocean.

Recreates the two complex ping-pong arrays, the two output arrays, the static spectrum SSBO and the descriptor sets, then transitions the images to their steady-state layouts. Foam is reset on the next dispatch (the new output image starts undefined).

upload_spectrum_if_dirty(fft: simvx.graphics.renderer.ocean_fft.OceanFFT) None[source]

Re-upload the frozen static spectrum when :meth:OceanFFT.configure rebuilt it.

dispatch(cmd: Any, time: float, choppiness: float, foam_threshold: float, foam_decay: float) None[source]

Record the full GPU FFT chain into cmd (outside any render pass).

Evolves the spectrum, runs the Stockham inverse FFT and assembles the displacement / slope arrays, leaving both in SHADER_READ_ONLY_OPTIMAL ready for the forward ocean pass to sample. Must be called after

Meth:

upload_spectrum_if_dirty and only when a visible ocean exists.

cleanup() None[source]