Spike removal

Hi,

Someone asked on another forum if it was possible to remove the spikes that can appear on the terrain.
I made a macro for this, after a technique Stephen gave me some time ago :

  • Apply a Blur to the terrain
  • Substract the result from the original terrain - you get the spikes
  • Substract these spikes to the original terrain.

The macro has one parameter, which controls the Blur radius (…which controls the size of the spikes to be removed).

You can download the macro here: http://terrafgen.free.fr/Downloads/Macros/Spike%20Removal.dev
You’ll need the registered version of WM (because of the Blur device).

And here is a screenshot of the effect (before/after):

(Note that this is also the screenshot made by Stephen some time ago, so you can thank him :D)

You can make the macro smaller/faster by replacing the two subtracting combiners (I only noticed I’ve spelled “subtract” wrong my entire life) with a single combiner in Min mode. :slight_smile:
It becomes clear if you draw yourself a quick sketch.
(At a point, where the height x of the blurred heightfield is less than the height h of the original heightfield, your macro does this: h-(h-x), which can be reduced to: h-(h-x) = x)

Unfortunately, the macro seems pretty trivial now. Your current method would also cut off “spikes” that are only small hills, thus removing the details on these.
That being said, maybe that method can be improved to select spikes in a more clever way, pushing that select and subtract approach, which is a very effective one for many purposes :slight_smile:

edit: maybe only subtracting spikes that exceed a certain height

Good idea…

I updated the macro (but I needed to keep the old way, because I needed the information concerning spikes…
But I’m not sure about the best way of selecting the spikes height. I used a Height Selector, but with no falloff, so…

I think it works that way. The only problem remaining are very small spikes. But reducing these without erasing the structure of the rest of the terrain would probably make the macro too big and complicated :slight_smile: