sdfTranslate

an SDF by moving its position.

110 total functionsUpdated: Invalid Date

sdfTranslate

an SDF by moving its position.

Parameters

NameTypeDescription
positionvec3<f32>3D position to transform.
offsetvec3<f32>Translation offset.

Returns

vec3<f32>position.

WGSL Code

fn sdfTranslate(position: vec3<f32>, offset: vec3<f32>) -> vec3<f32> {
return position - offset;
}

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