I am using Unity's 2D Mathf.PerlinNoise(x, y) function and I would like to make it distorted. What I mean is described with this picture I made:

enter image description here

How can I do that? What transformations should I apply to Mathf.PerlinNoise(x, y) to achieve this effect?


1 Answer 1


It sounds like you want an effect called Domain Warping.

This is when you layer your noise using function composition:

  • First you sample some noise based on your input position

  • Then you add the results to your input position to get a shifted position

  • Then you sample some noise at that shifted position to produce your final output

It's called domain warping because you're distorting the space of inputs to your noise function (the function's domain)

Example of domain warped noise

On the left is basic Perlin noise, and on the right the same noise with a small amount of domain warping applied (with topographic contours to help show the effect)

In Unity C# code it might look a bit like this:

public float DistortedNoise(float x, float y, float distortionStrength) {
    // Take two samples from our distortion function
    // (Shifted in space by > 1 so they don't correlate with each other)
    float xDistortion = distortionStrength * Distort(x + 2.3f, y + 2.9f);
    float yDistortion = distortionStrength * Distort(x - 3.1f, y - 4.3f);

    return Mathf.PerlinNoise(x + xDistortion, y + yDistortion);

float Distort(float x, float y) {
    // Optionally, you can scale your internal noise frequency
    // or layer several octaves of noise to control the wiggly shapes.
    float wiggleDensity = 4.7f; 
    return Mathf.PerlinNoise(x * wiggleDensity, y * wiggleDensity);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .