|
Pixel-align tile grid |
Bungow
Member #16,693
June 2017
|
Hello, I'm actually drawing a tilemap using ALLEGRO_TRANSFORM, the problem is when I apply scale and translation, the grid is not anymore pixel-aligned so alot of artifacts appears between tiles. I know how to solve this creating a one pixel border in the tile bitmaps, but I feel is more clean fixing this in the drawing routine, than changing all bitmaps. So the question is: how can I floor (or similar) the final drawing position using the ALLEGRO_TRANSFORM, to ensure it's pixel are aligned? |
Edgar Reynaldo
Major Reynaldo
May 2007
|
The drawing routine isn't broken. You're getting artifacts because you don't have a border around your sprites. You need that border so that the gpu knows where the end of the texture is, otherwise it will draw from the other side and wrap around, which is not what you want. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Bungow
Member #16,693
June 2017
|
Hello, Thanks for you answer, but if I understand correctly, this lines appear when drawing in subpixel locations, and because of that we don't get the lines when drawing with unescaled tiles (the scale transforms make draw locations not-pixel aligned ie. 123.7346289). So the 1px border arround the texture is only a "trick" to disguise these lines, but the proper solution should be draw in pixel locations. Maybe I'm totally wrong with this. Also I'm deploying my "game" into android phone and tablet and this problems not appear, can be this because of OPENGL ES profile? |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Don't think of it as a 'trick'. It's just the way the hardware works. If you're upscaling your images, the sampler has to 'read' the neighbor pixels to determine the correct color. When you have RGBA 0,0,0,0 as your border color it fades to transparent and smooths the edges instead of trying to read from the other side of the image. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Bungow
Member #16,693
June 2017
|
Thanks |
|