Streaks Across My Procedurally Generated Terrain

So I’m generating a height map via code with Perlin Noise and the applying it to terrains, but I’m getting these slightly streaks across the terrain.

I don’t mind posting my code up if anyone wants to see it, but it’s a lot and I’m just not sure where this might be taking place so I was hoping someone might have seen something like this before and have some advice on where to look.

Like I said; I’m generating the terrain by first creating a perlin noise map into a 2D array. Then I’m applying those heights using the terrainData.SetHeights method.

I’m also generating the noise map on a plane and the streaks seem to be missing there, so it’s something that’s happening somewhere when I’m setting the heights to the mesh.

Can you write the height map into an image and check if the streaks are already present?

The texture looks normal, so the streaks seem to be happening during the terrain shaping.

Do a simple cheesy 2x2 gaussian blur on the heightmap data before writing it… does the banding go away?

How would I do that? Using a shader? Or is there a way to blur/blend the actual height map values?

Just loop in 2 dimensions and do it… it’s just test code you’re going to throw away.

for (int y = 0; y < height - 1; y++)
{
  for (int x = 0; x < width - 1; x++)
  {
     float total = getCell( x, y) +
                  getCell( x + 1, y) +
                  getCell( x + 1, y + 1) +
                  getCell( x, y + 1);
     total /= 4;
     // todo: write this total to a fresh array (NOT THE SAME ARRAY!)
  }
}

(Obviously the “getCell()” method is based on however you’re storing this 2d float array.)

1 Like

The only point of trying this is to isolate where the regular ridged noise is coming from: is it a terrain bug or does your data actually contain this noise?

So it looks like I’m still getting the streaks on the terrain. Here is a look at what I did:

int width = 1 + terrainSO.AlphaMapResolution * 2 * worldLength;
        int height = 1 + terrainSO.AlphaMapResolution * 2 * worldLength;
        float[,] noiseMap = NewNoiseMap(width, height, seed, noiseScale,
            octaves, persistance, lacunarity, offset);
        DrawMesh(noiseMap, meshHeightMultiplier, meshHeightCurve);

        float[,] newArray = new float[noiseMap.GetLength(0) - 1, noiseMap.GetLength(1) - 1];

        for (int x = 0; x < noiseMap.GetLength(0) - 1; x++)
        {
            for (int y = 0; y < noiseMap.GetLength(1) - 1; y++)
            {
                float total = noiseMap[x, y] +
                    noiseMap[x + 1, y] +
                    noiseMap[x + 1, y + 1] +
                    noiseMap[x, y + 1];

                total /= 4;
                newArray[x, y] = total;
            }
        }

        for (int x = 0; x < noiseMap.GetLength(0) - 1; x++)
        {
            for (int y = 0; y < noiseMap.GetLength(1) - 1; y++)
            {
                noiseMap[x, y] = newArray[x, y];
            }
        }

This is the code leading up to actually setting the heights of the terrain, where I’m creating the noiseMap array.

And here is the code setting the heights:

for (int x = 0; x < terrainSO.Terrains.GetLength(0); x++)
        {
            for (int z = 0; z < terrainSO.Terrains.GetLength(1); z++)
            {
                int xStart = terrainSO.AlphaMapResolution * 2 * x;
                int xEnd = 1 + terrainSO.AlphaMapResolution * 2 * (x + 1);
                int zStart = terrainSO.AlphaMapResolution * 2 * z;
                int zEnd = 1 + terrainSO.AlphaMapResolution * 2 * (z + 1);
                terrainSO.Terrains[x, z].terrainData.SetHeights(0, 0, NoiseMapFragment(noiseMap, worldLength,
                    xStart, xEnd, zStart, zEnd));
            }
        }

There are a few methods there I’m not showing, let me know if it would be helpful to see any of them and I can post them. Really stumped with this!

To my eyes it almost looks like the distortion texture is squished. As in the X Y scale values are not the same to make a square texture.

what if you apply the same distortion to an imported subdivided grid plane?
could rule-out anything to do with terrane

Sorry not sure I’m following you. Not sure why X and Y wouldn’t be the same. I’ll see if I can try the grid plane idea though