sdfDomainRepeat

domain repetition with optional warping for complex patterns.

110 total functionsUpdated: Invalid Date

sdfDomainRepeat

domain repetition with optional warping for complex patterns.

Parameters

NameTypeDescription
positionvec3<f32>3D position to transform.
cellSizevec3<f32>Size of each repetition cell.
warpAmountf32Amount of warping to apply.
warpScalef32Scale of the warping effect.
seedf32Random seed for warping.

Returns

vec3<f32>repeated position.

Dependencies

WGSL Code

//! requires warpNoise3D
fn sdfDomainRepeat(position: vec3<f32>, cellSize: vec3<f32>, warpAmount: f32, warpScale: f32, seed: f32) -> vec3<f32> {
// Calculate warping for position
let warp = warpNoise3D(position * warpScale, seed) * warpAmount;
// Apply warping to position
let warpedPos = position + warp;
// Calculate repetition
return warpedPos - cellSize * round(warpedPos / cellSize);
}

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