Simulating erosion in Blender

Hi,

I started working on a script to simulate erosion. The idea is to develop it into a proper addon that can be used together with landscape generating addons like ANT.

For now it just simulates thermal erosion but the next milestone will be weathering by rainfall to create canyons and gullies, but because it’s always better to receive cooments and suggestions before finishing a project :slight_smile: I thought it would be a good idea to make available in its current form.

Details and instructions can be found here. C&C are very wellcome of course.

cheers

3 Likes

@varkenvarken Nice to see you back :slight_smile: How is the back?
Ever since you very nice tree addon I have been very impressed by all you ideas. This one looks ver y useful as well. When you say it can load a height map do you mean it can generate a mesh from that?

@ejnaren: thank you, the back’s getting better every day :slight_smile:
The script in its current form can read .raw files and heightmaps but that heightmap format is specific for this script, I.e a format that I made up :slight_smile: (Currently AFAIK there are no addons that can read DEMs directly but there is I think an addon that can read .img files (produced by NASA for mars and moon maps I believe) and I have seen tutorials to convert DEMs with external programs.

Anyway the .raw format is basically a list of triangles with the coordinates of the three vertices in plain ascii seperated by spaces.

The format I devised is even simpler, its just a line stating the number of grid cells in the x and y direction followed by Y lines with a z-value (height) for each cell in the x-direction:
2 2
1.0 0.9
0.9 0.8

The format was chosen so that it was easy to create a surface graph in Excel :slight_smile: It is also quite easy to construct such heightmap by hand and yes then it is posdible to convert it to a .raw file


#just convert
python erode.py -i -infile handmade.dat -outfile map.raw -ro -I 0

(just specify zero iterations)

cheers,

– michel.

ps> it would be very useful if someone could write a import addon that could read .dem files natively ( hint :slight_smile:

the erosion images look great.ANT was missing erosion to make natural looking features.Bryce has a instant “fake erosion” brush which you can use to paint erosion on needed areas of the heightmap.

This is another really interesting project! I was playing right in these days with world machine, which I read is the best for this kind of filters. I look forward to see your script! Thanks for all your great work! :slight_smile:

Meanwhile I made a first attempt at simulating ersion by water. Certainly not perfect yet, but already interesting (I think :slight_smile:

Details in this article.

Next step will be turning this into a proper Blender add-on, not because it is finished yet but because I think experimentation is a lot easier with direct visual feedback instead of with the current workflow of exporting/command line/importing.

cheers,

– Michel.

Bring it on! Time to get rid of Vue!

That sounds a bit ambitious but I’ll certainly try :wink:

I look forward to creating landscapes with this addon! The water erosion looks very natural to my eye.

I like to live in my dream world where I can uninstall most of my other 3D packages :smiley:

I reworked the code to a proper addon: not terribly interesting yet because as an addon it does just diffusion, but now I have a proper framework in place to add and test the other functionality in a more interactive way.

Brave souls willing to try can read about it in this article.

cheers,

– Michel.

I added the hydraulic erosion to the addon. Details and doc here.

Let me know what you think of it and if you find a good set of settings for the options, please share your results. The defaults are pretty decent but I am still looking for that ‘instant awesome’ :slight_smile: Even with the limited number of options we have now, the range of possibilities is vast, too vast to explore on my own, so any good finds are welcome.

cheers,

– Michel.

On a fair sized grid (1024x1024) and a few repetitions of the basic settings it almost looks decent:


version 0.0.2 adds a way to control the distribution of rain with a vertex group and shows some relevant mesh statistics. The addon is now quite usable IMHO so now it’s time to experiment and have a closer look at the erosion algorithms.

cheers,

– michel.

Great work as usual. Is it be possible to map the water erosion flow to a vertex color layer, in order to use it as a mask/texture? This always gives a nice effect to the terrain material when generating terrain in other programs. Thanks!

@Superflea: not yet but it’s certainly on my list. Of course there are several interpretations of what this means: it is quite simple to add the equilibrium height of the water as a vcol layer but probably what we want also is the transported water volume at each point of the grid (shallow water can flow fast). This is what we calculate in each step to determine where to move water and deposit or erode sediment but it is currently not stored so I have to figure out a way to do that. Doesn’t sound too difficult though :slight_smile:

Varkenvarken,

Thanks a lot for your efforts! It’s a big deal to get these simulations in Blender.
I hope you’ll participate in the next GSoC with some similar task (or one of yours that will be WIP if it’s not prohibited).

varkenvarken,

I’d like to thank you for your efforts with this plugin. I do have a couple of questions I’d like to ask. First, are you still working on this plugin? I think it has the potential to be the de facto tool for adding that natural look to terrains created in blender. My second question is about the settings. It seems that no matter what settings I use, the one thing that eludes me is the ability to create channeling in my erosion. A simple example would be to just create a plane and subdivide it a few times. Pull the middle section of verts down to create a canyon with angled walls. Now what I would like would be for the water from the top of the cliff to channel down into the canyon bed below creating that cut look that a lot of erosion simulators have, something similar to the basic erosion settings in world machine. Is it possible that I am just missing something in the settings or is it not yet possible to properly channel the water flow to create rivers and such?

Thanks very much for your add on varkenvarken! I used it a little after you first posted it, although I didn’t experiment with the settings. I just did a few iterations and it helped with a background mountain I was working on.

Recently I needed a volcano in the background. I thought I’d come back to this addon and it would help with the lava flows. However, I had the issue that kook refers to - the hydraulic erosion didn’t produce the chanelling effect I was after.

I have a little bit of experience with python, even less with the blender api, and none with numpy, but I thought I’d have a look at the code to see what was going on. The way you’ve written this is so nice and efficient, it was like reading a text book. Very interesting and informative.

For others using this add on, I could see why it wan’t working how I thought it would. The water is initialized every time you press the refresh button, and the water only travels 1 grid position every interation. So using the default 10 interations, it’s like sprinkling water on sand - the water runs a short way and is absorbed, and the effect is a lot like the diffusion.

Putting the rain to 0.01 and the interations to 1000 gave more like the effect I was expecting, but as the rock is eroded every iteration, its rather unstable, and there are many spikes and problems.

The add on is such a great start, I thought I might have a go at altering it to work the way I need it too - hope you don’t mind! So far it’s been going quite well. I’ll post some results shortly.

Here’s the default 64 division ANT landscape, on which I’ve used the modified erosion add-on to demonstrate the three erosion types that varkenvarken had implemented, with the changes I’ve added. I added vertex groups to help me understand what was happening, and like SuperFlea said, once they were there, they look to be very useful for texturing (and are maybe more important that the actual erosion!) Of course, the idea is you mix the three methods together the way you want. In particular, the hydraulic erosion needs the other weathering modes to stop the rivers digging unnatural holes.

Diffusion - for soft rolling hills:
(I couldn’t think of a useful vertex group)

Avalanche (or talis slope) - tall mountains
There are vertex groups for where the material was removed, and for where it ends up.


Hydraulic (or rivers) - for gullies
There are many vertex groups as this one is a bit tricky. Although some are similar, I think that’s still handy for texturing as it can give subtle variations.


The biggest change was to iterate the water and sediment levels separately before moving the landscape around. This lets the rivers settle into a pattern, and run from top to bottom.

However, there are downsides! Varkenvarken went to a lot of trouble to make his algorithms very efficient, and I haven’t, so the speed is no doubt slower. It doesn’t seem to matter much for small meshes, but I’m sure it will for big meshes. I also haven’t bothered with the numexpr at this stage. I just wanted the add on for distant mountains, so I don’t think it will worry me much.

I’ll try to tidy up and package the new version of the addon and publish it here shortly if anyone else would like to try. I’m not sure of the etiquette of modifying someone else’s work? I’d be more than happy for varkenvarken to carry on with his version! I thought I’d call the modified add on erosionR (R for river) to distinguish it from the original. Does that sound reasonable?