🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How to implement texture padding/dilation in code?

Started by
1 comment, last by JoeJ 2 years, 10 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?

Advertisement

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