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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Feature Request Jobified BlendShapes

Discussion in 'Entity Component System' started by joshcamas, Aug 23, 2022.

  1. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,268
    The new Mesh API is fantastic, super fast and efficient, especially once you deal with pure vertex streams. Great stuff!

    However, there is a single odd missing component: Blend Shapes. They are incredibly slow, so making the data job friendly (or at the very least better API's) would be super helpful - there are dozens of ways to get/set vertex streams and data, but only extremely simple ways to manipulate Blend Shapes, and manipulating them often means a massive amount of garbage...

    Here are my thoughts:

    1) AddBlendShapeFrame() can be INCREDIBLY slow. I think this function in particular would be especially useful in terms of thread safe / jobification.
    2) GetBlendShapeFrameVertices() requires the input arrays deltaVert, deltaIndices, deltaTangents to be the exact length of the mesh. This is restrictive and VERY bad for garbage!
    3) It would also be nice if I could get/set the verts, indices, and tangents separately, instead of requiring to get / set all of it at once. In my project I don't care about indices and tangents, but I don't have the flexibility to not manage that data. This means triple the garbage and data copying...
     
    Last edited: Aug 23, 2022
    JesOb and kenamis like this.
  2. kenamis

    kenamis

    Joined:
    Feb 5, 2015
    Posts:
    386
    100% agree.
    Also, it would be awesome to be able to use the new skinned mesh renderer vertex buffer when it's been initialized with the mesh data in object space for the frame, be able to manipulate the buffer, and THEN the skinning be applied.

    As far as I can tell, any modifications to the vertex buffer before the skinning gets squashed, and then you have to operate in the skinned space. Doesn't make it ideal for custom blendshapes in object space.
     
    joshcamas likes this.
  3. franco9595

    franco9595

    Joined:
    Mar 7, 2019
    Posts:
    1
    I saw that Unity 2022 now exists https://docs.unity.cn/2022.2/Documentation/ScriptReference/Mesh.GetBlendShapeBuffer.html

    I gave it a go and it seemed to me that it can only change data of blendshapes that are already created. The biggest bottleneck from mesh creation now is adding blendshapes, and that's what I wanted to address, but I couldn't manage to create a blendshape by using that API, which makes sense because it only change the GPU side of the mesh.

    AddBlendShapeFrame is super slow for high fidelity meshes, and it can only run in the main thread, so it means a big frame drop for a long period of time, not good :(.
     
    Andresmonte, joshcamas and kenamis like this.