- Home /
What is the exact size of texture padding required to avoid seams
Greetings. I have recently found a Unity manual page mentioning the need to leave padding on my textures outside of UV islands. That's a fairly reasonable part, but I would also like to know exactly how far apart I should put my UV islands to avoid seams, whether it be related to texture size or not. The manual page mentioned is: http://docs.unity3d.com/462/Documentation/Manual/HOWTO-alphamaps.html Thanks in advance.
Answer by Eno-Khaon · Aug 10, 2015 at 05:38 AM
Well, there's really not any strict answer to that question, so instead let's talk about why it happens to give you something to experiment with to learn for yourself.
I'll elaborate on what that page is referring to when they talk about "Downsampling". Before that, however, we start from the top with a friendly lecture on textures!
When you have a texture in 3D space, it will (almost) ALWAYS be a square power of two. For example, 256x256, 512x512, 1024x1024, etc. (rectangular textures are also commonly supported, but are still based around a power of two anyway).
When a 3D model reads from a texture, however, it's not based around a power-of-2 texture; the UV coordinates used range from zero to one instead. Any texture of any size can be used to fill these dimensions, so the same position in a 0-1 range will exist the same percentage of the way across the texture.
Now, downsampling is when you save computer resources by using a lower-resolution texture when the higher resolution isn't necessary. Rather than using the full 1024x1024 image to fill a 100x100-pixel area, either a 64x64 or 128x128 variant would potentially best be used in its place.
So, what does this have to do with padding textures?
I'm getting to that, so hold your horses!
The 3D model still uses Vector coordinates in a 0-1 range rather than full texture dimensions. This winds up meaning that the model has infinite granularity in the pixels it reads from, whereas the image itself is limited by number of pixels.
The buffer is there to account for potential problems if your image is downsampled.<or filtered or partially transparent or just unlucky>
When you take a close look at the UV map of a lower resolution image, you'll find that pixel-perfect painting might not be as precise as you're hoping for. Because the UV coordinates are still essentially perfect. They will always fit the image. But if your image doesn't have buffers to account for texture resolution changes <downsampling>, your 3D model may be showing edges outside of your lines on your texture when you're not expecting it to.
Just because your UV map matches up perfectly with your high-resolution texture doesn't mean it will still fit at a lower resolution, so the padding is there to account for that.
That said, just because I said at first that there isn't a strict answer to how many pixels you need for a buffer doesn't mean you can't approximate it.
For every power of two that the texture is reduced in quality, your image essentially has a 50% chance of each resulting pixel being in the same place relative to the UVs... per vertex. So your odds are actually extremely LOW that it'll still fit the size on a perfect matchup. But for every pixel of buffer you add, it's not as direct of an issue anymore.
The pixels from the high-resolution blend with their neighboring pixels at lower resolution, so black and white can blend into grey, then another blend with white makes it just a lighter grey, and the image continuously loses detail without shoving things too far out of the way.
At some point, you'll always get the wrong color when you downsample enough. A 16x16 image simply doesn't have enough pixels available to separate out the details that a 2048x2048 image could provide.
Anyway, I hope this gave you some insight, and now I really regret not finding this any sooner. There's a much better description here with numerous pictures (I could display two) demonstrating Texture Bleeding thoroughly.
Your answer
Follow this Question
Related Questions
Good uv mapping tutorial? 1 Answer
3DS Max Seams from Unity Cubes 2 Answers
Get texture with UV Mesh Mapping 0 Answers
Procedural Mesh UVs Edge Case? 1 Answer
Render Texture out from a 3D Object 1 Answer