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.

utils.wgsl

Import path

Constants

SPIRAL_OFFSET_0_

#
const SPIRAL_OFFSET_0_: vec2<f32> = vec2<f32>(-0.7071, 0.7071)

SPIRAL_OFFSET_1_

#
const SPIRAL_OFFSET_1_: vec2<f32> = vec2<f32>(-0.0000, -0.8750)

SPIRAL_OFFSET_2_

#
const SPIRAL_OFFSET_2_: vec2<f32> = vec2<f32>( 0.5303, 0.5303)

SPIRAL_OFFSET_3_

#
const SPIRAL_OFFSET_3_: vec2<f32> = vec2<f32>(-0.6250, -0.0000)

SPIRAL_OFFSET_4_

#
const SPIRAL_OFFSET_4_: vec2<f32> = vec2<f32>( 0.3536, -0.3536)

SPIRAL_OFFSET_5_

#
const SPIRAL_OFFSET_5_: vec2<f32> = vec2<f32>(-0.0000, 0.3750)

SPIRAL_OFFSET_6_

#
const SPIRAL_OFFSET_6_: vec2<f32> = vec2<f32>(-0.1768, -0.1768)

SPIRAL_OFFSET_7_

#
const SPIRAL_OFFSET_7_: vec2<f32> = vec2<f32>( 0.1250, 0.0000)

Functions

rand_u

#
fn rand_u ( ) -> u32

rand_f

#

Generates a random f32 in range [0, 1.0].

fn rand_f ( ) -> f32

rand_vec2f

#

Generates a random vec2 where each value is in range [0, 1.0].

fn rand_vec2f ( ) -> vec2<f32>

rand_range_u

#

Generates a random u32 in range [0, n).

fn rand_range_u ( ) -> u32

coords_to_viewport_uv

#

returns the (0-1, 0-1) position within the given viewport for the current buffer coords . buffer coords can be obtained from @builtin(position).xy. the view uniform struct contains the current camera viewport in view.viewport. topleft = 0,0

fn coords_to_viewport_uv (
position: vec2<f32>
viewport: vec4<f32>
) -> vec2<f32>

octahedral_encode

#

For encoding normals or unit direction vectors as octahedral coordinates.

fn octahedral_encode ( ) -> vec2<f32>

octahedral_decode

#

For decoding normals or unit direction vectors from octahedral coordinates.

fn octahedral_decode ( ) -> vec3<f32>

octahedral_decode_signed

#

Like octahedral_decode, but for input in [-1, 1] instead of [0, 1].

fn octahedral_decode_signed ( ) -> vec3<f32>

interleaved_gradient_noise

#
fn interleaved_gradient_noise (
pixel_coordinates: vec2<f32>
frame: u32
) -> f32