Image tiling issue

About Monkey 2 Forums Monkey 2 Programming Help Image tiling issue

This topic contains 7 replies, has 5 voices, and was last updated by  peterigz 2 years, 3 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #5944

    peterigz
    Participant

    Having an issue where the edge of tiles seem to be wrapping round and displaying a slither of the tile adjacent in the sprite atlas. See attached image what I mean and the tile map in question. Is there a texture flag I’m missing to prevent that? The strange thing is I’m loading the sprite atlas and creating a separate image for each tile but it seems to be bleeding the edge of the tile next to it.

    Here’s the code I use to load each tile, I’ve checked all the coordinates it uses to grab each frame are correct…

    Thanks 🙂

    #5947

    Jesse
    Participant

    Using your code, it seems to be working fine here OS X:

    Attachments:
    #5949

    Jesse
    Participant

    Spoke too soon. It displays fine when displaying to even coordinates but it fails when displaying to odd coordinates:

    Attachments:
    #5953

    codifies
    Participant

    sadly missing a Main function so couldn’t test on Linux…

    #5978

    Mark Sibly
    Keymaster

    If you are using filtering, tiles should generally have a 1 pixel border around them as minor math errors in the GPU can mean incorrect texels are occasionally sampled.

    More info here:

    http://gamedev.stackexchange.com/questions/61796/sprite-sheet-textures-picking-up-edges-of-adjacent-texture

    #5980

    peterigz
    Participant

    I see thanks. I tried filter nearest and that almost fixes it, but it glitches when y is 0.5. x doesn’t glitch at all. Not sure if that’s correct behaviour? Be nice if nearest was a solution, otherwise I can just try implementing the border technique as outlined in the link.

    I’ve attached a working example if anyone wants to test.

    Attachments:
    1. tiletest.zip
    #5982

    AdamStrange
    Participant

    If you are using filtering, tiles should generally have a 1 pixel border around them as minor math errors in the GPU can mean incorrect texels are occasionally sampled.

    Rubbish! thats just guff to protect you poor texture coordinates Mark, and you know it! In essence the texture coordinates should always compensate a tiny bit. adding a 1 pixels border is using a hammer to do the same.

    @peterigz – the app works fine here on macOS Sierra

    #5995

    peterigz
    Participant

    I checked back in my Blitzmax version of this code where it works fine but actually Blitzmax loadanimation created each image separately which basically eliminates the problem. So I adjusted my load animation to create separate images instead (which is what I thought was happening anyway until I ran into this issue) and it works perfectly. Looking around the web it does seem like a common issue people face with various hacks to fix. Incidentally this comes close to fixing where you adjust the UpdateTexCoords in the Texture Class like so:

    But it wasn’t quite perfect, the tiles just didn’t quite line up perfectly but the bleeding was eliminated. Either way I’m happy with separate images for tiles which i notice is what Playniax does as well.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.