smoothStep

interpolation between two values with smooth acceleration and deceleration.

110 total functionsUpdated: Invalid Date

smoothStep

interpolation between two values with smooth acceleration and deceleration.

Parameters

NameTypeDescription
edge0f32Lower edge of interpolation range.
edge1f32Upper edge of interpolation range.
xf32Input value to interpolate.

Returns

f32interpolated value between 0 and 1.

WGSL Code

fn smoothStep(edge0: f32, edge1: f32, x: f32) -> f32 {
let t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
return t * t * (3.0 - 2.0 * t);
}

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