Adjust Terrain edges

Hello to everyone,
I need your help to solve a problem with a terrain I am using in my project.

I have a terrain of dimensions 900x600. I need to change it so that the borders of the terrain smoothly lowers to height=0

Here’s a screenshot of a border of my terrain:

And here’s another terrain (not mine) with terrain heights that lowers at the edges:

My question is: is there a way to achieve these smooth edges automatically or programmatically?

Why would you make a terrain so it has a hill at the edge when you could just create your hills/mountains at the center and leave the edges at 0? What kind of borders are you using?

I need to be free to build a terrain as I desire. In my game there will be a lot of different terrains, so it would be ugly to have all terrains flat at the edges. And… I really love those smooth borders :wink:

Fractscape has an option to clamp terrain borders to a given height.

–Eric

Hmmm… nice idea. Can you please tell me if the clamp operation is smooth and if I can use fratscape on my already existing terrains? I am curious and I’ve got no time today to test it

The clamp operation looks like the attached screenshot, and you can use pre-existing heightmaps. Although you do have to give it at least a little leeway for randomization–if you use the exact same resolution for the heightmap as the terrain, then the edge clamping isn’t smooth.

–Eric

i spent alot of time to get my dynamic terrain works bet every time i have spaces between terrains tiles any one can help me please :

my code :
note that map size is the number of col and row

public float[,] _floatheightData;
// Here where i have all elevation data stored from parsing elevation file

where i have all elevation data stored from parsing elevation file
Code (CSharp):
  
public float[,] GetTileHeightMap(TerrainPrefs prefs,TerrainData tdata)
    {
        if (_floatheightData.Length > 0)
        {
            float[,] m_TileHeightMap = new float[tdata.heightmapWidth, tdata.heightmapHeight];
            float elevationRange = MaxElevation - MinElevation;
            float thx = tdata.heightmapWidth - 1;
            float thy = tdata.heightmapHeight - 1;
            var y_Terrain_Col_num = (mapSize_row_x);
            var x_Terrain_row_num = (mapSize_col_y);
            // heightmap rotation
            int tw = tdata.heightmapWidth - 1;
            int th = tdata.heightmapHeight - 1;
            float wRatio = (y_Terrain_Col_num ) / (tw);
            float hRatio = (x_Terrain_row_num ) / (th);
            for (int y = 0; y < tw; y++)
            {
                for (int x = 0; x < th; x++)
                {
                    var elevation = (_floatheightData[(int)((y) * hRatio), (int)(x * wRatio)]);
                    float v = ((elevation - MinElevation) / elevationRange);
                    m_TileHeightMap[x, y] = v;
                }
            }
            return m_TileHeightMap;
        }
        else return new float[0, 0];
    }

/ Im using terrain.SetNeighbors but it not work

after excuting code i have this :

i have same problem, clamp seems to be close to what im trying to do.

1 Like