Modifying an heightmap at runtime

Hi,

I’ve been working on a procedural terrain generator. I first create the heightmap than I apply it to a terrain data object. My problem is the following: I can’t seem to understand how to modify the heighmap.

	private float[,] GenerateHeightmap(float[,] heightMap, Vector2 arraySize) //A flat heightmap is received here and the arraysize contains the x and y of the heightmap
{
	for (int My = 0; My < arraySize.y; My++) {
		for (int Mx = 0; Mx < arraySize.x; Mx++) {
			heightMap[Mx, My] = (float)(Mx / 1000);//Because my heightmap is 513x513 I'm just making sure the value of heightMap[Mx, My] is under 1
		}
	}
	return heightMap;
}
//After receiving the heightmap I do:
terData.SetHeights(0, 0, heightMap);
//I think everything should be running fine but it isn't. 

The problem is that I don’t see any modifications on the terrain. Am I missing something?
At the moment I just want to modify the heightmap and see those modification in the terrain.

Plus, can anyone explain to me better why the range between 0 and 1 for the heightmap???

Thanks.

Mx is an int, Mx/1000 is gonna be zero all the time. Try ((float)Mx / 1000.0f)
I don’t know why they clamp it to 0,1, but you can scale Y. Find your min/max height and scale accordingly.

The heightmap is a bitmap with 0 for black and 1 as white. It’s then multiplied by your heightmap height value for scale. When editing the heightmap procedurally you might as well ignore the scale as it’s only used at the end.