smoothStepVec2

interpolation between two vectors with smooth acceleration and deceleration.

110 total functionsUpdated: Invalid Date

smoothStepVec2

interpolation between two vectors with smooth acceleration and deceleration.

Parameters

NameTypeDescription
edge0vec2<f32>Lower edge of interpolation range.
edge1vec2<f32>Upper edge of interpolation range.
xvec2<f32>Input vector to interpolate.

Returns

vec2<f32>interpolated vector between 0 and 1.

WGSL Code

fn smoothStepVec2(edge0: vec2f, edge1: vec2f, x: vec2f) -> vec2f {
let t = clamp((x - edge0) / (edge1 - edge0), vec2f(0.0), vec2f(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 { smoothStepVec2, getFns } from 'wgsl-fns'
Usage:getFns(['smoothStepVec2'])