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. Dismiss Notice

Visualize UV seams on mesh in game view

Discussion in 'General Graphics' started by Thibault_potier, Aug 25, 2021.

  1. Thibault_potier

    Thibault_potier

    Joined:
    May 4, 2021
    Posts:
    46
    Hi

    I want to be able to visualise the uv seams of a model, like it is possible in some 3D modeling software. Purpose is to "showcase" the work of an artist: I would like to visualize it on the mesh.

    As I'm not sure how to proceed, does anyone have a shader that does that ? :p Or could you point me a solution to achieve that effect ?

    thanks a lot
     
  2. mabulous

    mabulous

    Joined:
    Jan 4, 2013
    Posts:
    198
    UV seams are located between triangles that share the same position vertices but have different uv-vertices. This information is lost after the mesh is imported, since Unity uses interleaved vertex properties, so only vertices for which all vertex properties (position, uv, normal etc) are shared by multiple triangles will remain being shared. Therefore you won't be able to do that simply in a shader.

    I would probably iterate over all triangles of the mesh, check for each edge whether there is another edge in the mesh that has equivalent uv coordinates on both vertices and if not, add that edge to a list. Afterwards render all these edges using a line renderer.
     
  3. Thibault_potier

    Thibault_potier

    Joined:
    May 4, 2021
    Posts:
    46
    hmmm

    I like the idea, but my meshes are quite complex (huge number of triangles)

    "iterate over all triangles of the mesh / check for each edge whether there is another edge in the mesh that has equivalent uv coordinates on both vertices and if not, add that edge to a list. Afterwards render all these edges using a line renderer."

    that sound costly to calculate all line renderer points position at runtime while model move in scene :/

    Alternatively, would it be realistic to "compute" a texture with UV seams drawn on it, and then use that texture on the mesh material ?
     
  4. mabulous

    mabulous

    Joined:
    Jan 4, 2013
    Posts:
    198
    You need to do that only once, not in every frame
     
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,238
    Note, this has nothing to do with Unity, or rather nothing to do with a decision made by Unity. This is because all GPUS and real time graphics APIs expect mesh data in this format.

    Yes. That is the solution I described in my response to your duplicate thread.