Terrain Sculpting Eraser

Several weeks ago I had a discussion with a friend regarding some of the terrain tools limitations within Unreal Engine comparing to other tools we used to use, and that discussion made me interested into checking and digging more into that part of Epic’s source-code, and see if it can be juicy enough to drive me into an adventure of adding stuff.

While the first thing we had in mind, was the layers system, both of us used to deal with some in-house engines that support layers sculpting, something similar to what you can see in Mudbox or ZBrush, but for terrain. You can’t imaging the amount of productivity and creativity that can be reached with such a system. And with that as a driving force, I started to write some code for a layers based terrains sculpting. It didn’t take much time, couple of days I guess, until I started to find some code that seems familiar and make sense, and by keep tracking it, I found out that Epic is actually doing the same feature at the same time, but it is experimental, and require to be activated from within the editor preferences. So I stopped working on that feature, and decided to just share that finding!

With that kida dead end, I decided to kill that feature branch, and start on the second thing we have in the list of “How to make terrain workflow in UE4 much robust“, which was the eraser.

Erasing brush is not something exist within Unreal (yet!) and it can be super super useful in many scenarios. So I decided to put one in to UE4, and after couple of weeks to making and replacing to find the best use case, I ended up on a decent erasing brush, but on day while merging the latest master into my feature branch, i got some conflicts and errors due to some matching naming conventions for a new tool called “Erase Brush” !!!! I did build the master to check it, and found out it is something very recent been made by one of Epic’s team, but fortunately it is totally different than what I’ve been building, while epics eraser is basically a Flatten brush that is hard-coded to zero, which means it always erase the terrain values to a flat surface, the eraser I’m working on in more of erasing what you been sculpted, and leave you with a previous iteration of your work!

https://twitter.com/_mamoniem/status/1127894903600472065

And with that in mind, I decided to clean up my branch, rename all my new functions and data, and give the tool a proper name that more describing it’s usage, and do a pull request in order to have it within UE4.

What been added?

There are couple of new options within the context menu of the sculpting layer, the first one is “Fetch a restore point” which is the core step of using the erase brush, this option will keep a snapshot of the current terrain data as it is. The reason this feature is added, is to make the erase sculpted brush more robust in terms of erasing any part of the terrain to a previous sculpted value, not erasing to a flat surface with a high of zero.

The second new item within the context menu is “Reset to restore point”, as the name implies, this will revert the entire terrain layer to the saved restore point. At anytime while sculpting, can just revert to the base restore point without doing a hundred Ctrl+Z.

The third addition is the brush itself, which is located within the drop-down list of the sculpting brushes. This brush works as any other brush, just press and drag across the terrain, the result will be cleaning the brushed areas to reset them to the restore point. So this eraser is not cleaning to the default flat terrain, but to something the user already have sculpted.

Test Case

What about a test case to explain more?
This is a terrain with some sculpted areas, hills and valleys. The artist like it, so just did “Fetch a restore point” to be able to return to it or to any part of it in the future.

Then the artist kept sculpting up, down, smoothing and flatten some areas

But want to bring back the two simple hills that was at screen left and screen right, so simply can use the erase brush, and brush the needed areas. And the final result will be containing what been liked in the new sculpt mixed with what been liked from the old sculpt.

Finally, you can get all the code for that feature into your own Unreal fork from this pull request!

-m

Leave a Reply

Your email address will not be published. Required fields are marked *