Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Resolved ARKit face UV Unwrap

Discussion in 'AR' started by MdevM, Aug 18, 2021.

  1. MdevM

    MdevM

    Joined:
    Sep 28, 2017
    Posts:
    43
    Hi,

    I have been trying for the past few days to find a solution to texturing the ARKit face mesh that gets generated at run time.

    The problem is, this face mesh gets generated at runtime and has no UV's, I've been trying to learn how UV's are generated, and kind of figured out how to set up UV's at runtime for simple objects like planes and cubes but I can't seem to crack the egg for the face mesh, nothing I do or find on the internet is working.

    Please help and let me know if you have / can think of a solution.

    Regards and thanks in advance!
     
  2. MdevM

    MdevM

    Joined:
    Sep 28, 2017
    Posts:
    43
    What I found is, the face is actually unwrapped, but the UV's are outside the texture bounds for some reason, does anyone know how I can move/arrange the UV's into the texture bounds during runtime? Here is a photo showing how the face uvs look once the arkkit face is generated.
     

    Attached Files:

  3. MdevM

    MdevM

    Joined:
    Sep 28, 2017
    Posts:
    43
    Figured it out with this code here.

    Code (CSharp):
    1.  
    2.             float xOffset = 0.0f;
    3.             float yOffset = 1.0f;
    4.  
    5.        
    6.             Vector2[] uvs = new Vector2[TargetMesh.vertices.Length];
    7.             uvs = TargetMesh.uv;
    8.  
    9.             for (int i = 0; i < uvs.Length; i++)
    10.             {
    11.                 uvs[i] = new Vector2(uvs[i].x + xOffset, uvs[i].y + yOffset);
    12.             }
    13.  
    I hope it helps someone!