sdfToSmoothSolid

a signed distance field to a smooth solid with anti-aliasing.

110 total functionsUpdated: Invalid Date

sdfToSmoothSolid

a signed distance field to a smooth solid with anti-aliasing.

Parameters

NameTypeDescription
signedDistancef32Signed distance field value.
thresholdf32Threshold for solid determination.
smoothingf32Smoothing factor for anti-aliasing.

Returns

f32value between 0.0 and 1.0.

WGSL Code

fn sdfToSmoothSolid(signedDistance: f32, threshold: f32, smoothing: f32) -> f32 {
return 1.0 - smoothstep(threshold - smoothing, threshold + smoothing, signedDistance);
}

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