1
\$\begingroup\$

I am having an issue with texture bleeding, I am getting these lines that border each tile:

enter image description here

I have tried to solve the issue by rounding/flooring, but that does not work either.

The texture atlas has 32x32 pixel tiles.

\$\endgroup\$
0

1 Answer 1

1
\$\begingroup\$

The texture size usually does not match the screen area, so it needs to be enlarger or reduced.

That means that the border of your tiles are blended with the transparent border between tiles. And it shows part of the color that you use to clear the screen.

Option 1: Modify the way you access the texture data.

Texture2D - set_filter

Texture2D - FilterMode

atlas.set_filter(FilterMode::Nearest);

Option 2: Your tiles are 32x32 with 3 pixels between tiles. Using the same atlas (do not modify the picture), try using 30x30 as you tile area and 5 pixels between tiles.

match tiles[1] {
    ' ' => blit(atlas, 0, 0,  1.0, 36.0, 30.0, 30.0),
    '*' => blit(atlas, 0, 0, 71.0,  1.0, 30.0, 30.0),
    _=> (),                        
}

Option 3: Modify the picture adding a border (1 pixel) of the same color to each tile.

Disclaimer: I have never used neither Rust nor Macro-Quad.

\$\endgroup\$
2
  • \$\begingroup\$ Option 3 worked for me. I would accept your answer, but wouldn't that make my tiles 33 x 33, or does it render them as 32 x 32? Because my program needs the tiles to be 32 x 32. \$\endgroup\$ Apr 21, 2022 at 15:26
  • \$\begingroup\$ With option 3, tiles are 32x32 in the code. No changes needed. But you need to surround each tile in the picture (atlas) with a "1 pixel" border of the same color. Current picture: 32+1+1+1+32+1+1+1+32+1+1+1+32 << current has 3 transparent pixels New picture: 33+1+34+1+34+1+33 << new, only one pixel transparent between tiles. Tiles bigger 1 pixel using the previous border. \$\endgroup\$
    – gotanod
    Apr 21, 2022 at 16:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .