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.

foam.wgsl

Constants

NO_BED_DEPTH

#
const NO_BED_DEPTH: f32 = 256.0

UV_CENTER

#
const UV_CENTER: f32 = 0.5

Bindings

source_foam

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

source_sampler

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

anim_waves

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

waves_sampler

#
@group(0)
@binding(3)
var waves_sampler: sampler

bed_height

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

target_foam

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

foam

#
@group(0)
@binding(6)
var<uniform> foam: FoamUniform

fft_surface

#
@group(0)
@binding(7)
var fft_surface: texture_2d_array<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> ,
}

FoamUniform

#
struct FoamUniform {
source_layout: CascadeLayout ,
target_layout: CascadeLayout ,
step: vec4<u32> ,
wave: vec4<f32> ,
shore: vec4<f32> ,
}

Functions

world_to_uv

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

texel_world

#
fn texel_world ( ) -> vec2<f32>

inside_source

#
fn inside_source ( ) -> bool

reproject

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

displacement

#
fn displacement (
world_xz: vec2<f32>
slice: u32
) -> vec4<f32>

jacobian_foam_source

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

averaged_foam_source

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

bed_water_depth

#

Water depth below sea level. Unmapped samples use the cleared full-depth value.

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

update

#
fn update (
use_previous_layout: bool
)

main

#
@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

Shader defs requirments:

🟢 FOAM_REPROJECT_PREVIOUS

fn main (
@builtin(global_invocation_id)
id: vec3<u32>
)

main

#
@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

Shader defs requirments:

🟢 FOAM_UPDATE_CURRENT

fn main (
@builtin(global_invocation_id)
id: vec3<u32>
)

main

#
@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 main (
@builtin(global_invocation_id)
id: vec3<u32>
)