0
Completed

How to erode

Maestro Pivetta 7 years ago updated by Chris Tian 7 years ago 1

Hi, I was wondering, cause it would be a pretty useful function, if there is a way to recreate the Dilate/Erode effect trough shaderforge nodes, I am not getting the maths behind it so I am asking here.

It would be fantastic for many uses (eg, appear disappear effects, sprites border shading)

.Here is the explanation of what it does in OpenCV
http://docs.opencv.org/2.4/doc/tutorials/imgproc/erosion_dilatation/erosion_dilatation.html

I hope I didn't asked the obvious neither the impossible,

Best regards

Pivetta

Answer

Answer
Completed

It's sorta covered in the gradients tutorial. The math is pretty simple - you could use Add or Subtract to do this. The main thing you want to keep in mind though is that in order for things to dilate/erode evenly and slowly you will need a gradient texture of some sort so the dissolve has an even and consistent "path". So if you had a solid circle for instance, just subtracting from it would cause the whole circle to disappear rather abruptly since every pixel is the same value and gets affected equally at the same time. If the circle had soft edges, it would erode starting at the edges and move inward nice and slow.... If you wanted to erode a hard shape, you could use something with same general shape with a gradient to drive where the dissolve happens on the hard shape. Like put in a "soft" circle in the Alpha of texture of a Hard circle and use the dissolve effect from the soft circle to change the edges on the original.






Answer
Completed

It's sorta covered in the gradients tutorial. The math is pretty simple - you could use Add or Subtract to do this. The main thing you want to keep in mind though is that in order for things to dilate/erode evenly and slowly you will need a gradient texture of some sort so the dissolve has an even and consistent "path". So if you had a solid circle for instance, just subtracting from it would cause the whole circle to disappear rather abruptly since every pixel is the same value and gets affected equally at the same time. If the circle had soft edges, it would erode starting at the edges and move inward nice and slow.... If you wanted to erode a hard shape, you could use something with same general shape with a gradient to drive where the dissolve happens on the hard shape. Like put in a "soft" circle in the Alpha of texture of a Hard circle and use the dissolve effect from the soft circle to change the edges on the original.