xxhash32

integer hash using xxHash algorithm.

110 total functionsUpdated: Invalid Date

xxhash32

integer hash using xxHash algorithm.

Parameters

NameTypeDescription
nu32Input unsigned integer to hash.

Returns

u32unsigned integer value.

WGSL Code

fn xxhash32(n: u32) -> u32 {
var h32 = n + 374761393u;
h32 = 668265263u * ((h32 << 17) | (h32 >> (32 - 17)));
h32 = 2246822519u * (h32 ^ (h32 >> 15));
h32 = 3266489917u * (h32 ^ (h32 >> 13));
return h32^(h32 >> 16);
}

Other functions in Noise & Procedural

hash22

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

noise2D

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

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.

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