sdfToStroke

a signed distance field to a stroke/outline.

110 total functionsUpdated: Invalid Date

sdfToStroke

a signed distance field to a stroke/outline.

Parameters

NameTypeDescription
signedDistancef32Signed distance field value.
thicknessf32Stroke thickness.
centerf32Center distance for the stroke.

Returns

f32if within stroke, 0.0 if not.

WGSL Code

fn sdfToStroke(signedDistance: f32, thickness: f32, center: f32) -> f32 {
return select(0.0, 1.0, abs(signedDistance - center) <= thickness * 0.5);
}

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