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.

wave_query.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

MAX_QUERIES

#
const MAX_QUERIES: u32 = 256u

LOD_TRANSITION_START

#
const LOD_TRANSITION_START: f32 = 1.0

MORPH_BLACK_POINT

#
const MORPH_BLACK_POINT: f32 = 0.05

MORPH_FADE_SIDES

#
const MORPH_FADE_SIDES: f32 = 2.0

UV_CENTER

#
const UV_CENTER: f32 = 0.5

MIN_SAMPLE_WEIGHT

#
const MIN_SAMPLE_WEIGHT: f32 = 0.001

MIN_NORMAL_Y

#
const MIN_NORMAL_Y: f32 = 0.0001

Bindings

lod_data

#
@group(0)
@binding(0)
var lod_data: texture_2d_array<f32>

lod_sampler

#
@group(0)
@binding(1)
var lod_sampler: sampler

params

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

requests

#
@group(0)
@binding(3)
var<storage, read> requests: array<QueryRequest>

results

#
@group(0)
@binding(4)
var<storage, read_write> results: array<QueryResult>

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 { }

QueryRequest

#

flow: xy current (m/s), z signed bank margin (m), w channel half-width (m). Zero current selects cascade sampling.

struct QueryRequest {
world_xz: vec2<f32> ,
slot: f32 ,
kind: f32 ,
flow: vec4<f32> ,
}

QueryResult

#
struct QueryResult {
displacement_slot: vec4<f32> ,
normal_validity: vec4<f32> ,
signals: vec4<f32> ,
}

Functions

lod_count

#
fn lod_count ()

lod_alpha

#
fn lod_alpha (
world_xz: vec2<f32>
) -> f32

world_to_uv

#
fn world_to_uv (
world_xz: vec2<f32>
) -> vec2<f32>

sample_displacement

#
fn sample_displacement (
world_xz: vec2<f32>
lod: u32
alpha: f32
) -> vec3<f32>

select_lod

#
fn select_lod (
world_xz: vec2<f32>
) -> u32

river_surface

#
fn river_surface (
world_xz: vec2<f32>
) -> vec3<f32>

sample

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