How do I erode terrain?

In short, I’m trying to achieve the same effect that the terrain is erosion tool achieves. I’m trying to slowly eat away at terrain in game, with a variable brush size and erosion speed. I know Terrain has a FillBall() function, but that instantly gets rid of the terrain, similar to the subtraction terrain tool.

I’ve already tried to look at the Terrain Editor plugin code, and I can’t understand what it’s doing. If anyone familiar with the plug-in or anyone who’s done this before can help me understand how, please do.

Most operations of the terrain editor are done using ReadVoxels and WriteVoxels. The code for the erode terrain tool is here, in part of the operation function.

You could try editing this function to remove the code for each of the other operations and then use that. As you can see it first reads the occupancies of the voxels to be eroded and then modifies the desired occupancies of each of the voxels in a loop in a kind of complex way so it will probably also be easier to understand and replicate when you pull out just the code for erode.

1 Like