Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Computing Normals and Tangents without a Mesh Object

Discussion in 'Graphics Dev Blitz Day 2023 - Q&A' started by DreamingImLatios, May 25, 2023.

  1. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,143
    I'd like to generate meshes both in Burst-compiled jobs and in compute shaders and render them using DrawMeshIndirect and similar. Ideally, it would be nice to generate normals and tangents using the same mesh algorithms that are built into Unity, but these seem to be hidden on the C++ side.

    How might I go about this?
     
  2. Jebtor

    Jebtor

    Unity Technologies

    Joined:
    Apr 18, 2018
    Posts:
    112
    Currently, you can call Mesh.RecalculateNormals and Mesh.RecalculateTangents. Admittedly, these calls are quite high-level and include automatic behavior. By the sound of it lower level access would be preferred (purely for perf reasons?). Or alternatively, enough information on the algorithms to write your own implementation - is this understanding correct?
     
  3. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,143
    Yes and yes. As the title suggests, I want to recreate the same behavior without a Mesh object, because I may have hundreds of these virtual meshes at a time and juggling Mesh objects like that would absolutely ruin performance.
     
    Jebtor likes this.