Skip to content

eulerjs API / @eulerjs/marine/webgpu / GpuWaveFields

GpuWaveFields ​

Defined in: packages/marine/src/webgpu/GpuWaveFields.ts:85

The full sea of a SpectralWaves, every wave of every patch, evaluated on the GPU each frame with the same inverse FFT the physics does on the CPU (waves/fft.ts): one render pass to turn the spectra on to the frame's time, one per stage of the transform's rows and of its columns, and one per patch to unpack the result into textures the water's material samples.

The patches lie side by side in one atlas, so each pass does them all, and each texel carries four complex fields in two render targets: the eight real fields height, sideways x and z, the height's slopes and the sideways motion's gradients, two to a complex field.

Render passes rather than compute shaders, so the same code runs on WebGPU and on WebGPURenderer's WebGL 2 fallback, which has neither workgroup memory nor storage textures.

Constructors ​

Constructor ​

ts
new GpuWaveFields(waves, options?): GpuWaveFields;

Defined in: packages/marine/src/webgpu/GpuWaveFields.ts:142

Parameters ​

ParameterType
wavesSpectralWaves
options?GpuWaveFieldsOptions

Returns ​

GpuWaveFields

Properties ​

PropertyModifierTypeDescriptionDefined in
choppinessNodereadonlyanyThe waves' choppiness, as the transform has it: for the swell's sideways motion too.packages/marine/src/webgpu/GpuWaveFields.ts:103
foamPhasereadonlyUniformNode<"float", number>Which of each patch's two foam textures is the newer: 0 or 1.packages/marine/src/webgpu/GpuWaveFields.ts:93
foamSettingsreadonlyobjectSettings of the foam that can change as it runs: set their value.packages/marine/src/webgpu/GpuWaveFields.ts:108
foamSettings.biaspublicobject-packages/marine/src/webgpu/GpuWaveFields.ts:108
foamSettings.bias.valuepublicnumber-packages/marine/src/webgpu/GpuWaveFields.ts:108
foamSettings.decaypublicobject-packages/marine/src/webgpu/GpuWaveFields.ts:108
foamSettings.decay.valuepublicnumber-packages/marine/src/webgpu/GpuWaveFields.ts:108
foamSettings.growthpublicobject-packages/marine/src/webgpu/GpuWaveFields.ts:108
foamSettings.growth.valuepublicnumber-packages/marine/src/webgpu/GpuWaveFields.ts:108
foamSettings.peakLiftpublicobject-packages/marine/src/webgpu/GpuWaveFields.ts:108
foamSettings.peakLift.valuepublicnumber-packages/marine/src/webgpu/GpuWaveFields.ts:108
gustinessreadonlyUniformNode<"float", number>How much the gusting patches' waves are scaled from place to place: as SpectralWaves.gustAt.packages/marine/src/webgpu/GpuWaveFields.ts:106
passCountreadonlynumberRender passes a frame: for the comparisons in the ocean example.packages/marine/src/webgpu/GpuWaveFields.ts:91
patchesreadonlyreadonly FieldPatch[]-packages/marine/src/webgpu/GpuWaveFields.ts:88
resolutionreadonlynumber-packages/marine/src/webgpu/GpuWaveFields.ts:87
swellreadonlyobject[]The swell's long waves, which no patch holds, each (kx, kz, amplitude, phase): its wavenumber along its way, how high it is, and its phase this frame, worked out on the CPU in double precision. Summed where they are, as SpectralWaves sums them for the physics.packages/marine/src/webgpu/GpuWaveFields.ts:101
texturesreadonlyWaveFieldTextures-packages/marine/src/webgpu/GpuWaveFields.ts:89
waveHeightreadonlyUniformNode<"float", number>The sea's significant wave height, Hs, in metres: for gauging how near a crest the surface stands.packages/marine/src/webgpu/GpuWaveFields.ts:95
wavesreadonlySpectralWaves-packages/marine/src/webgpu/GpuWaveFields.ts:86

Accessors ​

atlas ​

Get Signature ​

ts
get atlas(): RenderTarget;

Defined in: packages/marine/src/webgpu/GpuWaveFields.ts:318

The transform's result for every patch before unpacking, as evaluateFields lays it out on the CPU: for checking one against the other.

Returns ​

RenderTarget

Methods ​

dispose() ​

ts
dispose(): void;

Defined in: packages/marine/src/webgpu/GpuWaveFields.ts:322

Returns ​

void


gustAt() ​

ts
gustAt(grid): any;

Defined in: packages/marine/src/webgpu/GpuWaveFields.ts:244

How much the gusting patches' waves are scaled by at the undisplaced grid position grid (vec2), as SpectralWaves.gustAt works it out.

Parameters ​

ParameterType
gridany

Returns ​

any


gusts() ​

ts
gusts(patchIndex): boolean;

Defined in: packages/marine/src/webgpu/GpuWaveFields.ts:251

Whether a patch's waves gust.

Parameters ​

ParameterType
patchIndexnumber

Returns ​

boolean


update() ​

ts
update(renderer, time): void;

Defined in: packages/marine/src/webgpu/GpuWaveFields.ts:256

Evaluates the sea at time, the same time the physics is given, into patches' textures.

Parameters ​

ParameterType
rendererRenderer
timenumber

Returns ​

void

Released under the MIT License.