Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

UV Unwrapping - ARFoundation Meshes/Planes

Discussion in 'World Building' started by PSST_Adam, Mar 4, 2021.

  1. PSST_Adam

    PSST_Adam

    Joined:
    Aug 26, 2020
    Posts:
    15
    Hi,

    I was wondering if anyone could help with an issue we are facing. We want to be able to do the following:
    • On ARPlane objects which are generated by ARFoundation we want to be able to generate the UV's so that they are between 0-1 with no repeating/tiling. We are looking into a ProBuilderMesh to help with this
    • For all meshes generated by ARMeshManager we want to convert them to a ProBuilderMesh so that we can apply UV's to them (as ARKit does not support texture coords).
    The reliance on ARFoundation is not the issue here, it is that the procedural meshes are not suitable for what we need, and we need help to get them to regenerate to conform to the 0-1 range with no repeating / tiling. So far through all tests we have not been able to achieve the results we need, with planes and meshes having very odd UV data.

    Any help on this topic would be appreciated.

    Thanks,
    Adam
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,571
    UVs must coexist with every vertex in an object. How you map them is simply an agreement you make up with yourself to map them between the local spatial position of that vertex to where on the texture you want.

    If you never want to go outside 0 to 1 and never repeat or wrap, you need to choose a direction of mapping (with some heuristic such as triplanar mapping) and calculate the correct 0-1 UVs.

    I have a simple world-to-UV mapper you could easily hack up: it would have to make one pre-pass to determine the largest span in any given axis view, then map all UVs to 0 to 1 instead of minimum to maximum world coordinate.

    This is the main script:

    https://github.com/kurtdekker/makegeo/blob/master/makegeo/Assets/setuvtoworld/SetUVToWorld.cs

    Full package located at that github project, including scenes that use the above.
     
  3. PSST_Adam

    PSST_Adam

    Joined:
    Aug 26, 2020
    Posts:
    15
    This is really helpful, thank you
     
    Kurt-Dekker likes this.