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: Textures bleed when tiled vertically

Discussion in 'World Building' started by dgoyette, May 28, 2018.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    Sorry for the vague title. A look at this picture should explain the issue I'm dealing with. Look carefully and you'll see what looks like a dotted green line in the purple area, and a dotted purple line in the green area:

    upload_2018-5-27_18-3-18.png

    What I have here are three simple materials which I made to reproduce this test. You can see the Albedo textures for the three materials in the screenshot as well. I have a green material, a purple material, and a half green, half purple material. In this case I created a PB cube, and repeatedly extruded it up one meter at a time to create three 1-meter high bars. The lowest bar gets the green texture, the upper bar gets purple, and the middle bar gets the half-and-half texture.

    upload_2018-5-27_18-7-42.png

    The issue is the middle half-and-half texture. It should transition cleanly, since the top of the texture is purple, and the bottom of the higher texture is purple. But instead it seems that some of the bottom of the texture is getting wrapped to the top, creating the faint line visible in my first screenshot.

    Note: This is using automatic UV unwrapping, and ProGrids to position the edges. The materials are brand new Standard shader materials with just the Albedo textures assigned.

    I tried fixing this by adjusting the Wrap Mode of the textures, and the result is interesting. While none of the wrap modes truly resolves the issue, using "Mirror" does fix it, but it has the side effect of limiting my geometry, as it means the middle section is rendered up-side-down for every other meter. But it's worth noting that using Mirror, and moving all the faces up one meter, results in clean transitions.

    So, any thoughts on what's causing the lines I'm seeing?

    Thanks,

    -Dan
     
  2. se

    se

    Joined:
    May 20, 2013
    Posts:
    46
    I have the same issue and I think it's called mipmap bleeding. I happens when there's a difference between the opposite edges (hence only vertically in your example). On my non-tiling objects I added some padding in the UV map. For tiling level textures I couldn't find a better solution than making sure all textures have very similar edges.
     
  3. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Hmm, that's very interesting, and troubling. I'd have to go with se's answer- could you try turning off MipMaps on the textures, and see what happens?
     
  4. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    I turned off MipMaps on the materials, but it didn't change the behavior.

    The specific use case where this is an issue for me is in trying to create a nice, but rough, transition between two materials. For example:

    upload_2018-5-29_11-54-40.png

    There are three wall materials here: The lower orange portion, the upper grey portion, and the middle "transition" portion. I didn't want a sharp line between the two materials, so the "transition" material has orange on the botton, and grey on the top. The blue lines I drew here show the boundaries of the materials and probuilder faces. So in this case I'm specifically making a material where the top of the material is dramatically different than the bottom. Maybe there's a better way to do this.
     
  5. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Hi! Yep, usually that would be done via a single texture from floor to ceiling, or using just two textures (where the bottom one transitions in a "rough" manor to the upper one, then the upper one is a single style).

    Searching "TF2 Texture" gives a few good examples :)

     
  6. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    552
    Try setting the "JunkXT" texture (middle one) to wrap mode "Clamp," and the two other textures should be "Repeat."
     
  7. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    Here's the original state (I removed a chunk of the wall to make it clear where the three materials are used:

    upload_2018-5-29_18-24-56.png

    Clamping the middle texture turns it completely purple.

    upload_2018-5-29_18-24-39.png

    I attached a repro test scene with this (without including the PB scripts)


    I'll accept that my approach isn't feasible if textures with different top and bottom edges don't work well. I considered the two approaches you've described, but they're both a bit clumsy if I want to have dynamic ceiling height in an area. With just one texture, two adjacent walls of different heights would never line up. With two textures it's more feasible, so I'll give that a try. Thanks.
     

    Attached Files:

  8. se

    se

    Joined:
    May 20, 2013
    Posts:
    46
    Is the face for the middle wall in the 0 to 1 space of the UV map? It would turn completely purple if it is above it.
     
  9. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    You're right that the face is not within 0 and 1, it seems, of the texture. Here's a capture showing the "transition" face, and the other nearby faces, in the UV Editor:

    upload_2018-6-2_8-43-58.png

    If I manually reposition the UV down a unit, so that it overlaps with the texture in the UV Mapper, then clamping horizontally works. (Well, it looks the way it does when using 'repeat', in that it doesn't just show only the top of the texture color.) Is there a way ProBuilder could have automatically handled this to put the UVs in the right place, instead of outside of the material?

    In any case, with this approach I can manually reposition things, and use a per-axis wrapping on the textures to repeat on U and clamp on V. But that doesn't appear to prevent the bleeding.
     
    Last edited: Jun 2, 2018