Author Topic: Spike removal  (Read 8712 times)

0 Members and 1 Guest are viewing this topic.

Rhalph

  • Testing Team
  • World Machine Guru
  • *****
  • Posts: 388
    • View Profile
    • http://terrafgen.free.fr
Spike removal
« on: January 05, 2008, 06:55:32 AM »
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)
« Last Edit: January 05, 2008, 07:04:22 AM by Rhalph »

nikita

  • Testing Team
  • World Machine Guru
  • *****
  • Posts: 627
  • B.S. in Macro Science
    • View Profile
    • My WM Macros
Re: Spike removal
« Reply #1 on: January 05, 2008, 04:33:16 PM »
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. :)
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 :)

edit: maybe only subtracting spikes that exceed a certain height
« Last Edit: January 05, 2008, 04:35:19 PM by nikita »
"Every time you read or write beyond the end of an array, somewhere a fairy dies."
Richard Buckland

Rhalph

  • Testing Team
  • World Machine Guru
  • *****
  • Posts: 388
    • View Profile
    • http://terrafgen.free.fr
Re: Spike removal
« Reply #2 on: January 05, 2008, 05:54:50 PM »
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...
« Last Edit: January 05, 2008, 06:16:46 PM by Rhalph »

nikita

  • Testing Team
  • World Machine Guru
  • *****
  • Posts: 627
  • B.S. in Macro Science
    • View Profile
    • My WM Macros
Re: Spike removal
« Reply #3 on: January 06, 2008, 03:40:31 AM »
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 :)
"Every time you read or write beyond the end of an array, somewhere a fairy dies."
Richard Buckland