This week in mirage

In this series of posts I’m going to talk about the new hot stuff I’m work­ing 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 pro­gram­ming lan­guage focus­ing on safe­ty, per­for­mance and con­cur­ren­cy. It lets you achieve the per­for­mance of C with­out the seg­faults and over­flows. All while hav­ing mod­ern lan­guage fea­tures and superb tool­ing. In prac­ti­cal terms this means I’ve moved the ter­rain gen­er­a­tion code to a native library that I can call from the Python side. If you’re curi­ous I’m using the Py03 crate to gen­er­ate a Python mod­ule.

Most of the ter­rain engine is already port­ed (although I’m still not hap­py with it). Consider that noth­ing I’m show­ing you here is final, I will prob­a­bly change a lot of things. As a result of port­ing to Rust ter­rain gen­er­a­tion is now a lot faster. It’s not use­ful to talk num­bers now since the engine isn’t fin­ished, but it’s gone from ~190ms to ~90ms. And I haven’t even opt­mized any­thing yet! SIMD instruc­tions, par­al­leliza­tion and using the GPU are all pos­si­ble now with Rust.

The port has brought some new fea­tures too:

  • Offsetting the ter­rain noise in the X and Y axis
  • Rotating the ter­rain noise
  • Changing the scale (to make ter­rains that rep­re­sent larg­er or small­er areas)
  • The ter­rain used to have a height set­ting that was­n’t always respect­ed. Now ter­rains always go from 0 to height in the Z axis
  • There are now set­tings to con­trol how plain or moun­tain­ous the ter­rain is
  • Terrains can hay any res­o­lu­tion now. The base grid set­ting is gone (final­ly!) and we can have rec­tan­gu­lar ter­rains as well
  • Terrains can also be seam­less now (they can be tiled).
  • There is a live mode that lets you play with these set­tings and watch the changes in real­time

I’m going to talk more about these in future posts, once the engine is more sta­ble and com­plete. I shared this quick demo video on Twitter some time ago. Note that some fea­tures have been removed and oth­ers added after­wards.

My ini­tial plan was to port the basics of the engine and keep the mod­i­fiers as they were (in Python/Numpy). But when I start­ed to work on this I found myself doing some very nasty hacks to keep every­thing work­ing.

I don’t want users deal­ing with unsta­ble code, or make the peo­ple who read my code think I’m any­thing less than an obsesive refac­tor­er. So I’ve decid­ed that I’m going to take my sweet time, port the whole thing and put out a great update with­out ugly hacks. Plus, I’m bring­ing even more improve­ments 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 late­ly. But what about this week?

This week I port­ed the Invert and Strata mod­i­fiers. Invert is the eas­i­est mod­i­fi­er, so no sur­pris­es here. Strata was a lit­tle more com­pli­cat­ed to get right.

First I renamed “stra­ta” to a more prop­er term: “Terraces”. The old stra­ta effect was done pure­ly in Numpy by con­vert­ing the heights to a sine wave and squar­ing it. Simple and effec­tive, but not very flex­i­ble at all. The new effect lets you have as many ter­races as you want and posi­tion them at dif­fer­ent heights in the ter­rain. Now we can cre­ate mul­ti­ple plateaus as well as ter­races. Also, “Invert Slope” actu­al­ly looks good now. The old effect used to make the edges of the ter­race high­er than the flat part of the ter­rain.

Notice the lit­tle bridge cre­at­ed by the sec­ond ter­race

I’m also think­ing of adding an option to con­trol the area between ter­races. It would be nice to make them more or less ver­ti­cal to make dif­fer­ent kinds of ter­rains. Some noise maps to add more vari­a­tion would also be inter­est­ing, but I think I’ll leave that one for a future ver­sion. Otherwise I’ll be releas­ing this for Blender 105.0. The ter­races effect can now cre­ate bet­ter plateaus than the plateau set­ting, so I will be remov­ing that option in favor of using the mod­i­fi­er.

Next week will be pret­ty busy, but I will start work­ing on the smooth mod­i­fi­er. Hopefully I’ll be able to get both lin­ear and radi­al smooth done in time for the next post.

If you want to have a seat in the first row when the next ver­sion of Mirage is released you can check it out on the BlenderMarket.

Various(Addon, Blender, BlenderMarket, Development, Mirage, Python)Last updated 14.06.2019
All the posts you can read

No comments yet

Leave a Reply

Your email address will not be published.