Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.

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 {
cascades: array<CascadeParams, CASCADE_COUNT>,
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 {
cascade_layout: CascadeLayout,
waves: array<GerstnerWave, WAVE_COUNT>,
ranges: array<vec4<u32>, LOD_COUNT>,
time: vec4<f32>,
flow: vec4<f32>,
}

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 () -> u32

lod_alpha

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

world_to_uv

#
fn world_to_uv (
world_xz: vec2<f32>,
cascade: CascadeParams
) -> 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>,
request: QueryRequest
) -> 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>
)
Contents