Class NoiseMath

Namespace
CodeSmile.AnyMotion.Core.Noise
/
Assembly
ApiSource.dll

Pure, allocation-free noise and oscillator functions shared by every product. Rig-agnostic: takes and returns plain numbers only, so the same functions can drive a humanoid bone, a camera, or a machine part unmodified. See shake-noise-spec.md §2 and §4 for why this lives in Core and why per-axis 1D noise was chosen over a 3D/vector noise field.

public static class NoiseMath
Expand Details ...
Inheritance
object
NoiseMath

Methods

AttenuateByDistance(Vector3, Vector3, float, AnimationCurve)

0..1 falloff from source to listener: 1 at zero distance, 0 at or beyond radius. Pure function, no spatial index — the caller (an explosion, an impact) already knows which listeners are nearby and calls this once per listener.

public static float AttenuateByDistance(Vector3 source, Vector3 listener, float radius, AnimationCurve falloff = null)

Parameters

Type Name Description
Vector3
source
Vector3
listener
float
radius
AnimationCurve
falloff

Returns

float

Blend(float, float, float)

0 = pure periodic, 1 = pure noise.

public static float Blend(float periodic, float noise, float regularity)

Parameters

Type Name Description
float
periodic
float
noise
float
regularity

Returns

float

HashToSignedUnit(int, int, int)

Deterministic -1..1 value from three integers. Not noise over time and not random: the same three inputs always give the same result, in this process and every later one.

public static float HashToSignedUnit(int seed, int channel, int index)

Parameters

Type Name Description
int
seed
int
channel
int
index

Returns

float

Remarks

For per-instance variation that has to survive a domain reload, a scene reload and a rebind — a crowd whose members differ from each other but do not re-randomise every time a script is saved. UnityEngine.Random cannot do that, and a re-randomising crowd makes the Scene view unstable while authoring and a defect unreproducible.

Integer avalanche (the finaliser of MurmurHash3's 32-bit mixer, one round per input) rather than Sample1D(float, int, int): Perlin noise is spatially continuous, so neighbouring seeds would produce neighbouring values and a crowd seeded 1, 2, 3 would barely differ. Here neighbouring inputs are uncorrelated, which is the whole requirement.

Sample1D(float, int, int)

One octave of Perlin noise, remapped to -1..1. seed and axisIndex place this sample on a different, non-integer lattice line so multiple axes and channels do not read as the same signal offset in time. The +0.5 keeps that line off UnityEngine.Mathf.PerlinNoise(float, float)'s degenerate integer-coordinate artefact.

public static float Sample1D(float time, int seed, int axisIndex = 0)

Parameters

Type Name Description
float
time
int
seed
int
axisIndex

Returns

float

SampleFbm1D(float, int, int, int, float, float)

Fractional Brownian motion: octaves summed at increasing frequency (lacunarity per octave) and decreasing amplitude (persistence per octave). One octave costs the same as Sample1D(float, int, int); this is what separates a plain "tremor" from a textured "chatter"/"judder".

public static float SampleFbm1D(float time, int seed, int axisIndex, int octaves, float persistence, float lacunarity)

Parameters

Type Name Description
float
time
int
seed
int
axisIndex
int
octaves
float
persistence
float
lacunarity

Returns

float

SamplePeriodic(float)

Plain periodic oscillator. phase is in cycles, not radians.

public static float SamplePeriodic(float phase)

Parameters

Type Name Description
float
phase

Returns

float

SampleSharpenedWave(float, float)

SamplePeriodic(float) flattened towards a square wave as sharpness rises. At 0 this is SamplePeriodic(float); near 1 the wave holds a value then changes suddenly instead of easing. Originated in WalkGait's gait shaping and moved here 2026-08-04 so any oscillator-based feature can reuse it instead of re-deriving the same curve.

public static float SampleSharpenedWave(float phase, float sharpness)

Parameters

Type Name Description
float
phase
float
sharpness

Returns

float