Skip to content

Api > Mathf > PerlinNoise()


Mathf.PerlinNoise(number x, number y)⚓︎

Generate 2D Perlin noise.

Parameters:⚓︎

Name Type Description
x number X-coordinate of sample point.
y number Y-coordinate of sample point.

Returns:⚓︎

type Description
number Value 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.