Class NoiseUtils
java.lang.Object
com.github.tommyettinger.textra.utils.NoiseUtils
Some 1D noise methods to be used when an effect needs smooth but random changes.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic float
noise1D
(float x, int seed) Quilez' 1D noise, with some changes to work on the CPU.static float
octaveNoise1D
(float x, int seed) Just gets two octaves ofnoise1D(float, int)
; still has a range of -1 to 1.
-
Constructor Details
-
NoiseUtils
public NoiseUtils()
-
-
Method Details
-
noise1D
public static float noise1D(float x, int seed) Quilez' 1D noise, with some changes to work on the CPU. Takes a distance x and any int seed, and produces a smoothly-changing value as x goes up or down and seed stays the same. Uses a quartic curve.
The distance (x
) should be between -16384 and 1073733631 for this to return correct results. Because floats incur precision loss earlier than 1073733631, the actual upper bound is lower. The limit of -8192 comes from how this usesMathUtils.floor(float)
internally onx + x
.- Parameters:
x
- should go up and/or down steadily and by small amounts (less than 1.0, certainly)seed
- should stay the same for a given curve- Returns:
- a noise value between -1.0 and 1.0
-
octaveNoise1D
public static float octaveNoise1D(float x, int seed) Just gets two octaves ofnoise1D(float, int)
; still has a range of -1 to 1.- Parameters:
x
- should go up and/or down steadily and by small amounts (less than 1.0, certainly)seed
- should stay the same for a given curve- Returns:
- a noise value between -1.0 and 1.0
-