Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commitdd348ac6c3

README.md

fx_shaping

The curves and UV transforms that turn a field into a look — remapping, easing, gradient ramps over a small keypoint set, polar and radial UV, and flow-map distortion.

#include "@builtin::deprecated.deprecatedParticles.fx.fx_shaping"

Pure math — no bindings. A Surface-domain shader and a .computeShader see different generated frameworks and can share a function only when it touches neither, so an explosion's material and the pass that drives its lifetime read one curve.

Remap

fx_remap(v, in_lo, in_hi, out_lo, out_hi) extends past both ends, fx_remap_clamped holds at them, and fx_remap01(v, lo, hi) reports where v sits in a range as [0, 1]. All three divide through fx_nonzero, so a degenerate range gives a finite answer rather than an infinity that spreads through everything downstream of it.

Easing

Each curve takes x in [0, 1] and returns [0, 1], holding 0 at 0 and 1 at 1.

FunctionShape
fx_smoothstep01(x)cubic Hermite
fx_smootherstep(edge0, edge1, x)quintic Hermite — second derivative vanishes at both ends
fx_pulse(edge0, edge1, softness, x)1 inside the band, with a shoulder of width softness
fx_ease_in_expo / fx_ease_out_expo / fx_ease_in_out_expoexponential
fx_ease_in_pow(x, k) / fx_ease_out_pow(x, k)a knee whose sharpness is a parameter
fx_gain(x, k)contrast about (0.5, 0.5); k of 1 returns x

Gradient ramps

fx_ramp4(t, positions, values) and fx_ramp4_color(t, positions, c0, c1, c2, c3) evaluate four keypoints whose positions ascend in positions. t at a keypoint returns that keypoint's value exactly; between two neighbours it interpolates linearly; past either end it holds.

Polar and radial UV

fx_to_polar(uv, center) gives (radius, turns) with the angle over [0, 1) anticlockwise from +X, and fx_from_polar inverts it. fx_radial_uv(uv, center, repeat, spin) rewrites a UV so x runs around the centre repeat times and y runs out from it — the coordinates a shockwave ring or an arcane circle is drawn in. fx_rotate_uv(uv, center, turns) spins one about a point.

Flow-map distortion

fx_flow(uv, flow, time, strength) returns the two UVs to sample and the weight of the first:

let f = fx_flow(uv, flow_vector, time, 0.25);
let color = mix(textureSample(tex, samp, f.uv_b), textureSample(tex, samp, f.uv_a), f.blend);

The two samples are half a cycle out of phase, and each one's weight falls to 0 at the moment it resets, which is what hides the reset. time is in cycles.