Advertisement

How to implement texture padding/dilation in code?

Started by August 23, 2021 08:27 AM
1 comment, last by JoeJ 3 years, 5 months ago

Does anyone know how to implement texture padding/dilation as seen here https://substance3d.adobe.com/documentation/spdoc/padding-134643719.html​ through code?

Is there code out there that can do it?

2 methods come to my mind, the above link shows the first:

  1. Generate a signed distance field, using the UV charts edges as boundary. Calculate gradient of SDF, for every empty texel do gradient descend to find the closest color pixel and pick that color.
  2. Make a alpha channel (1 = color pixels, 0 = empty pixels). Make copy of the texture and blur it, but empty pixels do not contribute. Add the sharp original texture on top with blending, so you get a dilated soft edge from the blurred texture. Recursively repeat the process to grow those dilated edges.

The latter is less work and also gives better results, because there are no sharp features in empty texture space. I have ‘implemented’ the method in Photoshop actions in the past for automation, requiring no coding at all : )

This topic is closed to new replies.

Advertisement