'Falloff map not smoothing edge of terrain

I have a procedurally generated terrain where I am looking to smooth the edges of the terrain using a falloff map so the edges do not abruptly cut off. The falloff map applies itself but it does not seem to smooth out the edge of the terrain and I cannot seem to figure out why. Would appreciate any insight into what might be causing this.

Full script with falloff applied TerrainGeneration.cs

Falloff map generation

float[] FallOff() {

float[] falloffmap = new float[(Width + 1) * (Depth + 1)];

int n = 0;
for(int h = 0; h < Depth; h++)
{
    for(int w = 0; w < Width; w++) {

        float x = w / (float)Width * 2 - 1;
        float y = h / (float)Depth * 2 - 1;

        float value = Mathf.Max(Mathf.Abs(x), Mathf.Abs(y));
        falloffmap[n] = EvaluateFallOff(value);
        n++;
    }
}
return falloffmap;
}

Applying the falloff

public void CreateMesh()
{

vertices = new Vector3[(Width + 1) * (Depth + 1)];
noiseArray = PerlinNoise();

int i = 0;
for(int z = 0; z <= Depth; z++)
{
    for(int x = 0; x <= Width; x++)
    {
        noiseArray[i] = Mathf.Clamp01(noiseArray[i] - falloffmap[i]);
        var currentHeight = noiseArray[i];

        if(currentHeight > HeightThreshold)
        {
            currentHeight = heightCurve.Evaluate(currentHeight) * HeightMultiplier;
        }

        vertices[i] = new Vector3(x, currentHeight, z);
        i++;
    }
}

Output I am getting with the applied falloff map enter image description here

The falloff map enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source