This will probably be a quick one, I am trying to find the best way of programming 'edge padding' to the UV islands on texture maps:
http://wiki.polycount.com/wiki/Edge_padding
I first started using a naive algorithm that searches outwards from each transparent pixel to find the nearest uv island (valid) pixel. This works but is very slow.
[attachment=34483:facemapREF.png]
Up till now I've been using a cellular automaton to 'grow' the edges of the uv islands. This works, but produces 45 degree angle or 90 degree angle growth only (because of the neighbourhood of the CA being 8 cells). It's also not super fast.
Instead of just padding, say 8 or 16 pixels, I'd like to be able to pad reasonably quickly all the empty space if possible, for large tex sizes (4096x4096), so I'm having another look at it.
I'm getting the impression most other developers are using 'dilation', which seems to be a fancy word for the cellular automaton approach. However I'm wondering if anyone has got a good optimized version of the search approach?
My first thoughts were that when checking neighbouring transparent pixels A and B, the closest possible one to B must be within 1 pixel distance of the closest to A. Considerably narrowing the search. I've done this and it is faster, but not blindingly fast.
Then I'm wondering whether it is possible to take some kind of 'mipmapping' type approach .. find the closest neighbour on a low res version, then progressively scale up to the full res version, only checking the pixels necessary.
Finally I was wondering about some kind of 'progressive field' approach as I move through the x pixels, just processing the incoming y line, rather than the whole 'kernel'.
Any thoughts anyone? :mellow: (should I be happy with the dilation approach for example?)