eulerjs API / @eulerjs/marine/webgpu
@eulerjs/marine/webgpu
The spectral sea drawn with three's WebGPURenderer (on WebGPU, or on its WebGL 2 fallback), apart from the main entry so that importing @eulerjs/marine doesn't pull in three/webgpu.
Classes
| Class | Description |
|---|---|
| GpuWaveFields | 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. |
| QuadtreeLod | The sea as a quadtree of square nodes (Strugar's CDLOD, 2009): from a few nodes the size of the whole sea around the centre, each splits into four while the centre is near enough, so that nodes grow with distance from it. Every node is the same grid, drawn in one instanced call; its vertices morph onto the grid twice as coarse by the distance its parent stops splitting at, so neighbours of different sizes meet without cracks. Given the camera, nodes out of its view are left out. |
| RingLod | The sea as a geometry clipmap (Losasso and Hoppe 2004): square rings around the centre, each with twice the vertex spacing of the one inside it, every level snapped to its own grid so that vertices stay put on the sea as the centre moves. Snapping leaves the hole in each ring one cell off from the level inside it on two sides; thin trims fill it. The outer band of every level morphs onto the coarser grid, so the rings meet without cracks. |
| SpectralWater | A SpectralWaves sea drawn to the horizon with three's WebGPURenderer, on WebGPU or its WebGL 2 fallback: every wave of every patch on the GPU, the same sea the physics floats bodies on. For WebGLRenderer, draw a SumOfSines sea with WaterMesh instead. |
Interfaces
| Interface | Description |
|---|---|
| FieldPatch | One patch of the sea as the fields hold it: layer i of the field textures is patch i. |
| GpuWaveFieldsOptions | - |
| QuadtreeLodOptions | - |
| RingLodOptions | - |
| SeaFogOptions | - |
| SeaFogUniforms | The fog's settings that can change as it runs: set their value. |
| SpectralWaterMaterialOptions | - |
| SpectralWaterUniforms | The material's settings that can change as it runs, in material.userData.uniforms: set their value. |
| WaterVertex | Where a level of detail puts a vertex of the water before the waves move it: its undisplaced position on the sea, and the spacing of its vertices there. |
| WaveFieldTextures | The textures every patch's waves are drawn from: texture arrays, layer i of each holding patch i (as GpuWaveFields.patches numbers them), each layer repeating every patch size. Arrays, so that a material samples a handful of textures however many patches the sea has: WebGPU allows only 16 to a shader stage unless asked for more. |
Type Aliases
| Type Alias | Description |
|---|---|
| SpectralWaterMaterial | Either material: physically lit, or shaded as a mirror of the sky given one. |
| SpectralWaterOptions | - |
Functions
| Function | Description |
|---|---|
| createSpectralWaterMaterial | The material of a SpectralWater: each vertex moved by every patch's displacement, each sampled at the mip level of the vertex spacing so that waves too short for the mesh fade out of it instead of aliasing; each pixel lit with the slopes of every wave, mipmapped too, and foam where GpuWaveFields keeps it. |
| seaFog | A haze over the sea for scene.fogNode, as Acerola's atmosphere makes it (github.com/GarrettGunnell/Water): thicker the farther off, as e^-(distance / visibility)², and thinner the higher up; coloured as the sky is the way one looks, brought down to the horizon, so that the sea fades into the sky with no line between them, and glowing toward the sun. It hides the sea's farthest reaches, where its patches' repeats show most. |
