Border around procedural height map

After following Sebastian Lague’s tutorial on procedural terrain generation, I then continued to add a manual limited generation script which works fine and allows me to control size.

I then wanted that specific sized area to have a water boundary fading off to the edge of the map, so usign Sebastian’s falloff map example I made gradient maps to apply to each individual chunks.

These are created procedurally using Lerp between zero and one and then subtracting said map from the original heightmap of each edge chunk. This alos works and gives the border chunks a fading down of terrain to sea border.

The issue arises with adding the edge maps to the height map, it appears to leave a border of two pixels on the left and bottom of each chunk.

As you can see it’s as though the height map is of a larger resolution than the edge map i created, which I have found to be true as in Sebastian’s code he pluses two to eahc map chunk size when generating them, but simply applying a plus two to my gradient map genertation seems to not solve the issue.

Please find attached Sebastian’s original code and my added code:

//This generates an array of values from 0 to 1 that form a gradient
public static float[,] GenerateTopGradient(int size)
        float[,] gradient = new float[size , size];
        float t = 0.001f;
        float tIncrement = 0.005f;
        for (int y = 0; y < size; y++)
            float vertColor = Mathf.Lerp(1.0f, 0.0f, t);
            for (int x = 0; x < size; x++)
                gradient[x, y] = Evaluate(vertColor);
            t += tIncrement;
        return gradient;

Applying the gradient

//The gradient array is then subtracted from the height map array
 if (edge == 2)
                    noiseMap[x, y] = Mathf.Clamp01(noiseMap[x, y] - topEdgeMap[x, y ]);

Any help would be much appreciated, I can add more detail as I’m sure will be needed.

Found the issue!!

It was being caused after the noisemap and the edgemap were combined, they then are passed into a colormap and matched to their correct height and as such their colour. The issue as b1gry4n rightly pointed out was to do with the sizing of the arrays. The noisemap had a size of 241 so I upped the egdemap to also have that, but never increase the colormap, the thing that actually implemented all this data to the screen!

Thanks for you help b1gry4n, always helps to talk it out with some.