sdfSmoothIntersect

two SDFs with smooth blending.

110 total functionsUpdated: Invalid Date

sdfSmoothIntersect

two SDFs with smooth blending.

Parameters

NameTypeDescription
distanceAf32First signed distance field.
distanceBf32Second signed distance field.
smoothingf32Smoothing factor for the blend.

Returns

f32intersected signed distance field.

WGSL Code

fn sdfSmoothIntersect(distanceA: f32, distanceB: f32, smoothing: f32) -> f32 {
let h = clamp(0.5 - 0.5 * (distanceB - distanceA) / smoothing, 0.0, 1.0);
return mix(distanceB, distanceA, h) + smoothing * h * (1.0 - h);
}

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