Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Anti-aliasing problem (?) with tiling shader

Discussion in 'Shader Graph' started by spidamoo, Feb 12, 2023.

  1. spidamoo

    spidamoo

    Joined:
    Aug 17, 2019
    Posts:
    2
    Hi there! I hope I'm not asking a stupid question that has an easy solution described in hundreds of posts! I've spend several days now trying to solve this myself and searched online but couldn't find anything quite like this.

    So I'm doing a shader (with URP/Shader graph) where certain properties of the resulting rendering are defined by a low-res texture. The way I want it to look is achieved by doing a no-filtering (point) sampling in the 4 closest points and lerping the result (as opposed to what you normally do where you rely on the default hardware functionality to do interpolation for you during sampling, which in my case I couldn't get to produce a satisfactory result with). It's all well and good but I'm getting some weird artifacts on the borders between pixels of the low-res texture. I've been playing around with different parameters and came to understanding that it has nothing to do with my particular case, it's just something that happens with any kind of tiling for whatever reason. Please help me understand why it happens and how to fix (or work around) it.

    Like I said, I couldn't find anything quite similar to this issue in online forums, the most similar posts suggest that this has to do with anti-aliasing and supposedly I can turn that off somewhere in Unity/URP settings but as far as I can see in my project it is already turned off everywhere (I've checked URP settings, camera settings even though the problem shows both in editor and player, the involved textures settings even though you can see the problem also with no textures at all in a purely procedural shader, all to no avail)

    I've come up with a simple shader graph that demonstrates this issue. The artifacts I'm talking about are the purple lines on the borders of tiles, which I can understand when it's a red-to-blue or blue-to-red sudden change, but they are there even if on the break of a tile it goes red-to-red or blue-to-blue. Screenshot 2023-02-12 112203.png Screenshot 2023-02-12 112210.png
     
  2. spidamoo

    spidamoo

    Joined:
    Aug 17, 2019
    Posts:
    2
    I think I found more related questions and answers online, e. g. https://stackoverflow.com/questions...borders-when-tiling-texture/15792064#15792064

    However I still don't understand how to apply this to my case. I've tried disabling mip-mapping for my textures, tried using `SAMPLE_TEXTURE2D_GRAD`, this does not change anything. Also I don't understand how mip-mapping would apply to a procedural shader and how it can be worked around there.