Reputation: 31851
I have an image atlas with elements arranged in boxes packed beside each other. When I position/scale these so that they are pixel-for-pixel rendered everything works fine. However then moment I start doing sub-pixel positioning I can get bleed from the neigbouring image in the atlas.
If I understand correctly this is caused by the fragment shader, or rather the texture position interpolation. A pixel near the border of the texture position will end up getting some of the value from the neighbouring pixel.
Though I'm uncertain since if I do some searching this problem usually only shows up in relation to using layers in a mip-map. Is my understanding correct, or am I doing something wrong? I know how to fix it (for both tiling and not-tiling textures) but I'd like to make sure I've got the basics correct first.
Upvotes: 1
Views: 1430
Reputation: 2662
From what I hear, yes, when you are doing sub-pixel manipulation you will get pixels blending with each other which what MSAA actually does to achieve anti-aliasing.
Upvotes: 1
Reputation: 86
It depends on what rendering engine you use and the platform.
The simple solution is add a 1 pixel transparent border between each box in the texture atlas, that should solve the artifacts problem in most cases.
In plain OpenGL, vertex positions are floats so subpixel precision is easy to achieve. anti-aliasing occurs naturally by the opengl implementation when you position sprites on a non integer boundaries. The quality depends on the OpenGL implementation, you can also use glHint() to make sure you're on the safe side.
Upvotes: 3