sdfPlane

a signed distance field for an infinite plane.

110 total functionsUpdated: Invalid Date

sdfPlane

a signed distance field for an infinite plane.

Parameters

NameTypeDescription
positionvec3<f32>3D position to evaluate.
normalvec3<f32>Normal vector of the plane (should be normalized).

Returns

f32distance to the plane surface.

WGSL Code

fn sdfPlane(position: vec3<f32>, normal: vec3<f32>) -> f32 {
let n = normalize(normal);
return dot(position, n);
}

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