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

[SOLVED] Artifacts on edges of non-adjacent UV blocks (tilemap pixel shader)

Discussion in 'Shaders' started by ArConstructor, Jul 8, 2017.

  1. ArConstructor

    ArConstructor

    Joined:
    May 27, 2010
    Posts:
    24
    Hi, I'm trying to make a tilemap shader, but get weird artifacts on the edges of tiles (the picture shows an isometric tile shape, but the artifacts can be seen at any tile shapes, even plain old square grids).

    The calculated tilemap UVs (in the second picture) do not exhibit this glitch, so I suspect something is wrong in the tex2D() call.

    An idea why this is happening / how to fix it?

    hexagonal_0.5_snap.png
    UVs.png
     

    Attached Files:

  2. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,492
    Yes, the interpolation between fragments cannot correctly compute the intermediate value when the jump between fragment is too big. Might only work with point base sampling or pingpong sampling, not random jump in the UV.
     
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    tex2Dgrad() is your friend here, or disabling mip maps if that's an option.
     
  4. ArConstructor

    ArConstructor

    Joined:
    May 27, 2010
    Posts:
    24
    Thanks! Disabling mipmaps works for me.