Skip to main content

Mathf.PerlinNoise(number x, number y)

Generate 2D Perlin noise.

Parameters:

NameTypeDescription
xnumberX-coordinate of sample point.
ynumberY-coordinate of sample point.

Returns:

typeDescription
numberValue between 0.0 and 1.0. (Return value might be slightly below 0.0 or beyond 1.0.)

Usage

---@type number
local x;

---@type number
local y;


local val0 = Mathf:PerlinNoise(x, y)

Extra Detail

Perlin noise is a pseudo-random pattern of float values generated across a 2D plane (although the technique does generalise to three or more dimensions, this is not implemented in Unity). The noise does not contain a completely random value at each point but rather consists of "waves" whose values gradually increase and decrease across the pattern. The noise can be used as the basis for texture effects but also for animation, generating terrain heightmaps and many other things.