Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class Noise
- Object
- Noise
Procedural noise built from ShaderNode math, so it runs in either stage
on every backend and needs no texture. Every function takes a VEC2
coordinate; scale it to set the feature size.
The hashes avoid sin, whose precision differs between GPUs, and use
only additions, multiplications and fract.
Methods
Inherited methods
Method details
hash
public static ShaderNode hash(ShaderNode p)A pseudo random
FLOAT in [0, 1) for each point, constant over no
region: feed it floor of a coordinate for one value per cell.Parameters
pShaderNode- a
VEC2
Returns
a
FLOAThash2
public static ShaderNode hash2(ShaderNode p)Two independent pseudo random values in [0, 1).
Parameters
pShaderNode- a
VEC2
Returns
a
VEC2value
public static ShaderNode value(ShaderNode p)Smooth value noise in [0, 1], one feature per unit.
Parameters
pShaderNode- a
VEC2
Returns
a
FLOATfbm
public static ShaderNode fbm(ShaderNode p, int octaves)Fractal value noise:
octaves layers, each twice the frequency and
half the weight of the one before. Clouds, terrain, dirt.Parameters
pShaderNode- a
VEC2 octavesint- 1 to 6
Returns
a
FLOAT in about [0, 1]ridged
public static ShaderNode ridged(ShaderNode p, int octaves)Ridged fractal noise: sharp creases where plain noise crosses its
middle. Mountain ridges, lightning, cracks.
Parameters
pShaderNode- a
VEC2 octavesint- 1 to 6
Returns
a
FLOAT in [0, 1]cellular
public static ShaderNode cellular(ShaderNode p)Cellular (Worley) noise: the distance to the nearest of one random
point per cell. Foam, caustics, scales, cobbles, lava crust.
Parameters
pShaderNode- a
VEC2
Returns
a
FLOAT, 0 at a feature point and about 1 at mostcellular
public static ShaderNode cellular(ShaderNode p, ShaderNode phase)Cellular noise whose feature points drift in circles over time, for
moving water light and bubbling surfaces.
Parameters
pShaderNode- a
VEC2 phaseShaderNode- a
FLOATthat animates the points, such astime(), or null for still points
Returns
a
FLOATbumpNormal
public static ShaderNode bumpNormal(ShaderNode p, int octaves, float strength)The slope of fractal noise, as a tangent space normal for
ShaderNode.perturbNormal: bumps without a normal map.Parameters
pShaderNode- a
VEC2 octavesint- 1 to 6
strengthfloat- how steep the bumps are
Returns
a
VEC3