Search Unity

Vertex Offset splitting meshes.

Discussion in 'Shaders' started by Cactus_on_Fire, Jun 19, 2019.

  1. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Hello.

    It's a decade old problem but is there a way to prevent meshes from splitting apart when using vertex offset?
    My mesh is completely smooth and has unified normals but it splits up the mesh from where the UVs split.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Any seam in the mesh can be a source of split. Be it t-junctions, normals, UVs, or even vertex colors. It all depends on how you’re sourcing and applying the offset. The only 100% sure way of not having splits is to not have seams, which is borderline impossible, especially if you’re using a 2D texture to drive the offset.

    The most common solution I see to this problem is to use a 3D noise function instead of a texture when trying to randomly displace the surface of something. As long as you have smooth normals and no t-junctions (geometry that joins together just by being close, not by having shared vertex positions), that shouldn’t have an splits since the mesh’s position is being used as the noise lookup instead of UVs.

    Another option is to have seamless UVs and maybe bridged geometry. While it might seam like it’d be impossible to have a perfectly seamless UV, it is possible if you use something like a flat projected UV across the entire model, there won’t be any seams in the UV to cause the discontinuities that cause the splits. Going beyond that, since displacement is only per-vertex, you can have some really ugly UVs across the surface as long as they meet up cleanly on the UVs. The idea would be to have a chamfered seam of geometry between UV seams to prevent the split. It’s harder if you’re also looking to have some kind of albedo texture using the same UVs as they’ll look really bad across that bridge. The solution there would be to have multiple overlapping UV sets that you fade between using something like vertex colors, similar to how terrain systems work.
     
  3. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Thanks bgolus. Good to see you again btw :)

    Yeah the problem is that the same vertices shared by different polygons that have different offset values due to being positioned in a different UV space. Since the offset value is based on a heightmap I assume the viable option would be having 2 UV sets solution to avoid offsetting the split UV vertices.

    Kinda knew it didn't have a perfect solution but I had to check.