Advanced search tips: use spaces to require multiple terms (AND), | for alternatives (OR), wrap phrases in quotes (="a b"), =term for exact match, 'term to include, !term to exclude, ^term to match prefix, !^term to exclude prefix, .ext$ to match suffix, and !.ext$ to exclude suffix.

anim_waves.wgsl

Constants

LOD_COUNT

#
const LOD_COUNT: u32 = 5u

CASCADE_COUNT

#
const CASCADE_COUNT: u32 = LOD_COUNT + 1u

WAVE_COUNT

#
const WAVE_COUNT: u32 = 40u

TAU

#
const TAU: f32 = 6.283185307179586

PI

#
const PI: f32 = 3.141592653589793

NO_BED_DEPTH

#
const NO_BED_DEPTH: f32 = 256.0

Bindings

output

#
@group(0)
@binding(0)
var output: texture_storage_2d_array<rgba16float, write>

params

#
@group(0)
@binding(1)
var<uniform> params: AnimWavesUniform

bed_height

#
@group(0)
@binding(2)
var bed_height: texture_2d<f32>

Structures

CascadeParams

#
struct CascadeParams {
center: vec2<f32> ,
scale: f32 ,
texture_res: f32 ,
inv_texture_res: f32 ,
texel_width: f32 ,
weight: f32 ,
max_wavelength: f32 ,
}

CascadeLayout

#
struct CascadeLayout {
center: vec4<f32> ,
bed_transform: vec4<f32> ,
bed_range: vec4<f32> ,
}

GerstnerWave

#
struct GerstnerWave {
direction: vec2<f32> ,
amplitude: f32 ,
wave_number: f32 ,
angular_frequency: f32 ,
phase: f32 ,
chop_amplitude: f32 ,
}

AnimWavesUniform

#
struct AnimWavesUniform { }

Functions

bed_water_depth

#

Water depth under the sea level from the game’s bed height map. Outside the mapped area (or with no map at all) the sample keeps the deep default, mirroring a full-depth capture texel. Nearest-texel read: the shoaling profile is smooth enough that one 5 m-class bed texel suffices.

fn bed_water_depth (
world_xz: vec2<f32>
) -> f32

shoaling_weights

#

A bounded finite-depth shoaling profile. The vertical lane retains more energy than horizontal chop through the breaker zone, producing steeper near-shore crests without changing deep-water phase or world anchoring.

fn shoaling_weights (
depth: f32
wave_number: f32
) -> vec2<f32>

generate

#
@compute
Runs custom parallel code on the GPU, not limited to graphics
@workgroup_size(8, 8, 1)
Defines the size of a thread group. One to three numbers: width (x), height (y), and depth (z). Missing values default to 1
fn generate (
@builtin(global_invocation_id)
id: vec3<u32>
)