In this series of posts I’m going to talk about the new hot stuff I’m working on for Mirage. This will be my first time doing a devlog, so bear with me 🙂
Our first stop is what I’ve doing for the past few months: the Rust port.
Port to Rust
Rust is a programming language focusing on safety, performance and concurrency. It lets you achieve the performance of C without the segfaults and overflows. All while having modern language features and superb tooling. In practical terms this means I’ve moved the terrain generation code to a native library that I can call from the Python side. If you’re curious I’m using the Py03 crate to generate a Python module.
Most of the terrain engine is already ported (although I’m still not happy with it). Consider that nothing I’m showing you here is final, I will probably change a lot of things. As a result of porting to Rust terrain generation is now a lot faster. It’s not useful to talk numbers now since the engine isn’t finished, but it’s gone from ~190ms to ~90ms. And I haven’t even optmized anything yet! SIMD instructions, parallelization and using the GPU are all possible now with Rust.
The port has brought some new features too:
- Offsetting the terrain noise in the X and Y axis
- Rotating the terrain noise
- Changing the scale (to make terrains that represent larger or smaller areas)
- The terrain used to have a height setting that wasn’t always respected. Now terrains always go from 0 to height in the Z axis
- There are now settings to control how plain or mountainous the terrain is
- Terrains can hay any resolution now. The base grid setting is gone (finally!) and we can have rectangular terrains as well
- Terrains can also be seamless now (they can be tiled).
- There is a live mode that lets you play with these settings and watch the changes in realtime
I’m going to talk more about these in future posts, once the engine is more stable and complete. I shared this quick demo video on Twitter some time ago. Note that some features have been removed and others added afterwards.
My initial plan was to port the basics of the engine and keep the modifiers as they were (in Python/Numpy). But when I started to work on this I found myself doing some very nasty hacks to keep everything working.
I don’t want users dealing with unstable code, or make the people who read my code think I’m anything less than an obsesive refactorer. So I’ve decided that I’m going to take my sweet time, port the whole thing and put out a great update without ugly hacks. Plus, I’m bringing even more improvements along the way.
Oh, and also that I’m going to blog about it!
Porting the first modifiers
So, that’s what I’ve been doing lately. But what about this week?
This week I ported the Invert and Strata modifiers. Invert is the easiest modifier, so no surprises here. Strata was a little more complicated to get right.
First I renamed “strata” to a more proper term: “Terraces”. The old strata effect was done purely in Numpy by converting the heights to a sine wave and squaring it. Simple and effective, but not very flexible at all. The new effect lets you have as many terraces as you want and position them at different heights in the terrain. Now we can create multiple plateaus as well as terraces. Also, “Invert Slope” actually looks good now. The old effect used to make the edges of the terrace higher than the flat part of the terrain.
I’m also thinking of adding an option to control the area between terraces. It would be nice to make them more or less vertical to make different kinds of terrains. Some noise maps to add more variation would also be interesting, but I think I’ll leave that one for a future version. Otherwise I’ll be releasing this for Blender 105.0. The terraces effect can now create better plateaus than the plateau setting, so I will be removing that option in favor of using the modifier.
Next week will be pretty busy, but I will start working on the smooth modifier. Hopefully I’ll be able to get both linear and radial smooth done in time for the next post.
If you want to have a seat in the first row when the next version of Mirage is released you can check it out on the BlenderMarket.