Half-pixel padding on atlasBounds #49
-
I've noticed that all the fonts I've tested with so far have a value of 0.5 added to each entry in the atlasBounds structure, for example on this 1-character 16px atlas I used to test with:
Is it safe to just truncate these values? In all your example code and others example code, the 0.5 is just ignored, so I am curious as to why it's added in the first place? EDIT: Ah is it to force the GPU to chose the correct pixel when calculating UVs? Great tool by the way, and really excellent paper as well. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
No, you shouldn't truncate in the context of texture mapping. It is to make sure that corners of the quads are in the middle of texels, to avoid having to add padding inbetween glyphs. The 0.5 pixels at the borders cannot be used in a meaningful way anyway, so saving a little bit of space in the atlas is the best solution. In contexts where you need integer coordinates (e.g. when cutting up the atlas bitmap), you have to keep in mind that these coordinates correspond to the quad |
Beta Was this translation helpful? Give feedback.
No, you shouldn't truncate in the context of texture mapping.
It is to make sure that corners of the quads are in the middle of texels, to avoid having to add padding inbetween glyphs. The 0.5 pixels at the borders cannot be used in a meaningful way anyway, so saving a little bit of space in the atlas is the best solution.
In contexts where you need integer coordinates (e.g. when cutting up the atlas bitmap), you have to keep in mind that these coordinates correspond to the quad
planeBounds
, so those would also have to be changed accordingly in order to remain valid.