Search Unity

Question Texture2D rendering differently when triangles are small

Discussion in 'General Graphics' started by nabergh, Jun 9, 2021.

  1. nabergh

    nabergh

    Joined:
    Jun 22, 2019
    Posts:
    7
    I have a mesh whose geometry changes frequently and when a triangle is small, one of the textures used looks different, specifically it's darker for some reason. I had a problem like this with another texture that was solved by setting
    mipChain=false
    in the Texture2D constructor, but that doesn't seem to solve the problem in this case.

    I am using Shader Graph to sample the texture in case that informs someone's answer but I'm not sure if it matters.

    Here's some screenshots with and without the triangle outlines visible. The darker looking triangles seem a bit larger in this screenshot but they are much smaller than the other triangles when you see the full mesh.

    rsz_mesh_bug_no_tris.png rsz_mesh_bug_with_tris.png
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    It’s not that the triangles are small. It’s that the triangles are overlapping. The geometry is pinched and faces are being inverted. My guess is the material’s blend mode is set to Multiply.

    The only way to avoid this when using Shader Graph is don’t generate overlapping geometry. If this is a line made using Unity’s Line Renderer or a trail, the solution is … don’t use those and write your own.:(
     
    nabergh likes this.
  3. nabergh

    nabergh

    Joined:
    Jun 22, 2019
    Posts:
    7
    Thanks for your quick response! I did some exploring and confirmed that it does only happen when the triangles overlap. Fortunately I am generating my own geometry so I can avoid overlapping geometry if necessary. Although it would be nice if I could simply choose which triangle should be shown in places where they overlap, or avoid face inversion some other way if that's what's causing the weird rendering. Do you know if that could be possible?

    I'm also wondering what a material's blend mode is and how I could access/change it even if it doesn't solve my problem here. I didn't see anything related to blending in the scripting reference.