noise2D

2D Perlin-style noise for procedural textures and patterns.

110 total functionsUpdated: Invalid Date

noise2D

2D Perlin-style noise for procedural textures and patterns.

Parameters

NameTypeDescription
pvec2<f32>Input 2D coordinate.

Returns

f32value typically in range [-1, 1].

Dependencies

WGSL Code

//! requires hash22
fn noise2D(p: vec2<f32>) -> f32 {
let i = floor(p);
let f = fract(p);
let u = f * f * (3.0 - 2.0 * f);
return mix(
mix(dot(hash22(i + vec2<f32>(0.0, 0.0)), f - vec2<f32>(0.0, 0.0)),
dot(hash22(i + vec2<f32>(1.0, 0.0)), f - vec2<f32>(1.0, 0.0)), u.x),
mix(dot(hash22(i + vec2<f32>(0.0, 1.0)), f - vec2<f32>(0.0, 1.0)),
dot(hash22(i + vec2<f32>(1.0, 1.0)), f - vec2<f32>(1.0, 1.0)), u.x), u.y);
}

Other functions in Noise & Procedural

hash22

a 2D hash from a 2D input vector for procedural generation.

fbm2D

Brownian Motion - combines multiple octaves of noise for complex patterns.

fbm3D

Brownian Motion - combines multiple octaves of noise for complex patterns.

hash1D

a 1D hash value from an input value for noise generation.

hash31

a 1D hash value from a 3D input vector.

hash3D

a 3D hash vector from a 3D input for displacement effects.

noise3D

3D noise using trilinear interpolation.

warpNoise3D

3D warping noise using fractal Brownian motion.

pcg

and fast integer hash using PCG algorithm.

pcg2d

PCG hash function for fast procedural generation.

pcg3d

PCG hash function for volumetric procedural generation.

pcg4d

PCG hash function for advanced procedural generation.

xxhash32

integer hash using xxHash algorithm.

xxhash322d

xxHash for strong integer hashing in 2D.

xxhash323d

xxHash for strong integer hashing in 3D.

xxhash324d

xxHash for strong integer hashing in 4D.

rand11Sin

float from 1D input using sine (platform dependent).

rand22Sin

float from 2D input using sine (platform dependent).

valueNoise1D

1D value noise using random interpolation.

valueNoise2D

2D value noise using smooth interpolation.

mod289

289 operation for Perlin noise.

perm4

function for Perlin noise.

valueNoise3D

value noise using permutation tables.

perlinNoise2D

Perlin noise implementation.

perlinNoise3D

Perlin noise implementation.

simplexNoise2D

simplex noise implementation for efficient 2D procedural generation.

simplexNoise3D

simplex noise implementation for volumetric procedural generation.

simplexNoise4D

simplex noise implementation for high-quality procedural generation.

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 { noise2D, getFns } from 'wgsl-fns'
Usage:getFns(['noise2D'])