noiseWave

a wave using interpolated noise for organic variation.

110 total functionsUpdated: Invalid Date

noiseWave

a wave using interpolated noise for organic variation.

Parameters

NameTypeDescription
xf32Input position.
frequencyf32Wave frequency.
amplitudef32Wave amplitude.
seedf32Random seed for noise generation.

Returns

f32wave value.

Dependencies

WGSL Code

//! requires hash1D
fn noiseWave(x: f32, frequency: f32, amplitude: f32, seed: f32) -> f32 {
// Create interpolated noise
let t = x * frequency;
let floorT = floor(t);
let fractT = fract(t);
// Get four noise values and interpolate between them
let n0 = hash1D(floorT + seed);
let n1 = hash1D(floorT + 1.0 + seed);
// Smooth interpolation
let u = fractT * fractT * (3.0 - 2.0 * fractT); // Smoothstep
return mix(n0, n1, u) * amplitude;
}

About wgsl-fns

A JavaScript library providing WGSL utility functions as strings for WebGPU shader development. Includes mathematical utilities, noise generation, signed distance fields, and color manipulation functions.

Install:npm install wgsl-fns
Import:import { noiseWave, getFns } from 'wgsl-fns'
Usage:getFns(['noiseWave'])