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

Question Backporting vertex skinning shader to built in

Discussion in 'Shader Graph' started by snacktime, Feb 22, 2020.

  1. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    I'm doing this more as a temporary thing to allow me to move forward with integrating the new DOTS animation stuff as it's going to be a couple of months at least before we can move to HDRP.

    The node I'm porting is here, it does vertex skinning for skinned meshes.
    https://github.com/Unity-Technologies/ScriptableRenderPipeline/blob/master/com.unity.shadergraph/Editor/Data/Nodes/Vertex Skinning/LinearBlendSkinningNode.cs

    This is a surface shader that implements the core logic.
    https://gist.github.com/gamemachine/2fe6e1f919f6fa6cf5b20eb942ddc0da

    And it works to a point. But it exhibits what looks like timing issues, like HDRP is interpolating the results over time somehow using a mechanism I'm just not aware of.

    What happens visually is with a character comprised of multiple skinned meshes, they all get out of sync in relation to each other. Individual meshes the skinning is fine. The problem worsens the more meshes that are being rendered, and how off individual meshes are and how varies over time also. Which makes me fairly certain it's time related. What I don't know is if it's actually a shader thing, or maybe meshes are batched differently with HDRP and that somehow causes the issue.

    A single character for instance I couldn't see any issues. It gradually gets worse with more.

    Rendering is done via Graphics.DrawMeshInstanced, it's just the unmodified Dots Animation code.
     
  2. ecurtz

    ecurtz

    Joined:
    May 13, 2009
    Posts:
    640
    Are the BoneIndexOffset values the same for all of the meshes? If not they'd each be using their own skinning matrices.
     
  3. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    You know that's probably it, because I also just realized it's rendering via the hybrid renderer, which does not support instanced props for built in.