In-Game drawing on terrain feels slow.

I’m trying to draw on terrain in-game (by adjusting splatmap values).
The code I have works, but feels realy slow compared to the unity editor.

public void DrawOnTerrain(TerrainData terrainData, Vector2 texCoord) {
	//Calculate splatmap positions based on given texture coordinate 
	int pointx = (int)(terrainData.alphamapHeight * texCoord.x);
	int pointy = (int)(terrainData.alphamapWidth * texCoord.y);
	//Make new splatmap values
	float[,,] maps = new float[1,1,4];
	maps[0, 0, 0] = 0;       
	maps[0, 0, 1] = 0;   
	maps[0, 0, 2] = 0;   
	maps[0, 0, 3] = 1;   
	//Place them back in the terrain 
	terrainData.SetAlphamaps(pointx, pointy, maps);
}

SetAlphamaps causes a huge decrease in performance (± 35ms)
The terrain has 4 splatmaps. The splatmap resolution is 512 x 512.
According to the profiler, the performance is going into
Camera.render

Culling

Terrain.CullAllTerrains()

If I change the camera culling mask to not include the terrain, it doesn’t take nearly as much performance, but obviously you don’t see the changes untill the culling mask is set to include the terrain again.
The Unity terrain editor feels a LOT smoother, even when used in a paused game. Is it possible to edit terrain in-game with the same performance ?

Same exact problem here. A solution would be nice. My performance drops from about 65 fps to 25 fps when drawing on the terrain using almost the exact same script you posted above.

There is no solution. The built in terrain in unity does not perform adequately for run time modification.

You can roll your own terrain, use a third party terrain, or wait for the upgrade.

Ahhhh, okay :frowning:

Any suggestions for third party terrain?