Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Tilemap Flickering

Discussion in '2D' started by SFvdB, Jul 2, 2020.

  1. SFvdB

    SFvdB

    Joined:
    Mar 10, 2014
    Posts:
    28
    Hello, I am creating a couple of tilemaps stacked on top of each other (in the end I'd like to have about 100).

    But regardless of that, when reaching a certain size of tiles (at least 100x100 tiles) this weird flickering effect happens when I move the camera. Which is a regular camera with the Perfect Pixel component attached – but disabling it doesn't solve it.

    These weird artifacts move and jump around. Basically your'e looking at the combined side of a group (chunk?) of tiles, although the tilemap ought to look solid and Z as Y is not used.

    It's not possible to set the tilemap to individual sorting, because it implodes the framerate.

    I'd love to use tilemaps of at least 100x100 size and I believe – from reading other posts – this ought to be possible. But how to fix this flickering?

    The tiles are set once, when the map is rendered, using SetTile – because it ought to be possible to have variety on the tiles. The top (grass) layer is a different sprite than the brown dirt sprites, so the effect is less noticeable there. Individual tiles may be changed later but nothing like editing has been implemented yet.

    (I recorded a screen capture to show the effect. It disappears when you zoom in, however it can show up again while moving regardless of camera distance or Pixel Perfect settings. I will post this asap).

    Unity 2019.4.2f1
    macOSX 10.14.6

    Here's a screenshot for now: That 'cliff' isn't really there, but an artefact, showing the sides of the used sprite.

     
  2. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,503
    Is the screenshot of multiple tilemaps? If so, are you giving the different tilemaps TilemapRenderer a different Order or Sorting Layer? It may be that you have tilemaps stacked on top of one another at the same position with same order/layer. As a result, you have what could be z-fighting between the different chunks. Though, that would be surprising because Tilemaps are supposed to - all else equal - render in their hierarchy order, iirc.

    If what is viewed is a single tilemap, that's very strange and looks like a bug.

    Another thing to keep in mind - though seems unrelated to your problem here - is that chunked tilemaps sprites must all be from the same texture / spritesheet / SpriteAtlas to work properly. If not, it can create similar artifacts. But it looks like you have only one sprite here, so that's unlikely the source.
     
    SFvdB likes this.
  3. SFvdB

    SFvdB

    Joined:
    Mar 10, 2014
    Posts:
    28
    It is a single tilemap, though there are other tilemaps below. If there was any z-fighting I think it would move differently and be more clearly defined, as the lower tilemaps each have a color offset. I made a video to record the phenomenon. Although I will check the individual positions, just to make sure.

    Yes, I am using a SpriteAtlas because I ran into problems without one, before.

    Here's the video recording the weird glitch:
     
  4. SFvdB

    SFvdB

    Joined:
    Mar 10, 2014
    Posts:
    28
    Changing the z-positions of each tilemap did not make a difference. The glitches still occur on each one. I've also tried changing the Transparancy Sort Axis from 0,0,-0.26 to, for instance, 0,1,-0.26 but nothing changed.
     
  5. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,503
    Hmm. It may be a bug. "Help >> Report A Bug..." within Unity so it's a priority for the devs.

    Outside that, I don't have good ideas. I might try fiddling more with the Transparency Sort Axis, or maybe messing around with Manual Chunking parameters, but that's a shot in the dark.
     
    SFvdB likes this.
  6. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    This seems like a bug. If you could report a bug using this project using the Unity Bug Reporter and post the case number here, that would be helpful! Thanks!
     
    SFvdB likes this.
  7. SFvdB

    SFvdB

    Joined:
    Mar 10, 2014
    Posts:
    28
    I'll try that, and I'll report it as well. Cheers!
     
    xjjon likes this.
  8. xjjon

    xjjon

    Joined:
    Apr 15, 2016
    Posts:
    610
    I have this issue too, I reduced it by using a different z axis for the transform of the tile maps.

    I have 3 tile map

    tilemapA[sort level 0] (transform: 0,0,0)
    tilemapB[sort level 1] (transform: 0,0,0.0001)
    tilemapC[sort level 2] (transform: 0,0,0.0002)

    This reduced the amount of artifacts and flickering. However there is still some when the camera moves. I'm not sure if it's due to the camera (not pixel perfect) or not, but it seems to be an issue with the tilemap renderer. This is cause it only flickers on the "higher" tile maps.

    i.e. tilemapA NEVER flickers or has artifacts, tileB or tileC are the only ones that flicker (they are "on top" of A)

    All the tiles used are from the same .png / tilesheet / sprite sheet
     
  9. xjjon

    xjjon

    Joined:
    Apr 15, 2016
    Posts:
    610
    Can you post the link to the bug if it is accepted, I will add my tests to it too to help reproduce it
     
    SFvdB likes this.
  10. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    If you could post the bug case number here, that would help!

    Could you share a video of the issue you are seeing, and screenshots of the TilemapRenderers you are using? If that is not possible, reporting a bug with your project can be helpful as well!
     
  11. SFvdB

    SFvdB

    Joined:
    Mar 10, 2014
    Posts:
    28
    Last edited: Jul 9, 2020
  12. xjjon

    xjjon

    Joined:
    Apr 15, 2016
    Posts:
    610
    Uploaded a gif. The checkerboard is basically the base tile map lowest in layers.
    The red/black tiles are 'decoration' tile placed over it. As the player move (camera moves) and you can see the flickering

    https://imgur.com/a/bQRAsUt (GIF)

    flickering.png
     
  13. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Thanks! I will check this out!

    The flickering seems like a bug also. If you can do the same and file a bug with your project using the Unity Bug Reporter, that will be helpful!
     
  14. xjjon

    xjjon

    Joined:
    Apr 15, 2016
    Posts:
    610
    Sure, I will try to create a project to reproduce it. Currently I only see it on certain android phone (samsung galaxy s9 s10). No issues on iPhone or low end android
     
  15. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Great, thanks! That would be interesting to check out!

    This has been fixed and hopefully coming to you soon!
     
  16. xjjon

    xjjon

    Joined:
    Apr 15, 2016
    Posts:
    610
    Thanks I have filed a bug report, ( pm'd you bug id)

    https://imgur.com/a/nrGRbvN (GIF) to show what the project reproduces

    Some notes from the bug, take away being: Seems to be related to the camera? If you change the x rotation on camera from -25 to 0 it will stop flickering.

    ```
    Tilemap flickering on camera [Galaxy s9+, galaxy S10+]

    1. What happened

    Tilemap flickers when camera moves. Does not happen on all devices (currently reproduced with Samsung Galaxy S9+ and S10+)

    2. How we can reproduce it using the example you attached

    Attached scene is setup to reproduce (just press play)

    Seems to be related to the camera. If you change the x rotation on camera from -25 to 0 it will stop flickering.

    * the flickering tiles are layered
    * does not flicker in editor or iPhone (tested)
    ```
     
  17. xjjon

    xjjon

    Joined:
    Apr 15, 2016
    Posts:
    610
  18. xjjon

    xjjon

    Joined:
    Apr 15, 2016
    Posts:
    610
    Hi this issue has been marked as 'by design' but it should be a bug as it is not fixed.

    https://issuetracker.unity3d.com/is...-an-orthographic-camera-on-adreno-640-devices

    The note says to use z offset : however

    Using z offset to fix this is not really a "feature".

    If your camera is not top down then you will the tilemaps are not layered correctly.

    Think a 2.5D game where the tilemap is used for the floor while there are 3D entities and props
     
  19. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Sorry, this is more of a workaround to the issue since it only reproduces on particular mobile devices.