Search Unity

  1. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice

Linear Blend Skinning with Hybrid Renderer V2 Not Working

Discussion in 'Animation Previews' started by DK_A5B, Nov 3, 2020.

  1. DK_A5B

    DK_A5B

    Joined:
    Jan 21, 2016
    Posts:
    99
    I'm experimenting with Hybrid Renderer V2 and Mesh Deformations, and I'm having a problem where the object's I'm creating using a Material based on a Shader using "Linear Blend Skinning" becomes invisible after being converted to an entity.

    The project is using Unity 2020.2.0b9, the HDRP (10.0.0-preview.27), Hybrid Renderer (0.10.0-preview.21), and I've added the definition "ENABLE_HYBRID_RENDERER_V2" to the project to enable Hybrid Renderer v2.

    I constructed a VERY simple shader using Shader Graph following the documentation from the Hybrid Renderer package on Mesh Deformations (https://docs.unity3d.com/Packages/com.unity.rendering.hybrid@0.10/manual/mesh_deformations.html) that uses Linear Blend Skinning. Here's a screen shot of the shader design from Shader Graph:

    upload_2020-11-3_14-13-5.png

    I created a simple scene with 3 cubes. Two which use "Convert to Entity (Convert and Destroy)" and one that's just a regular Game Object. The regular game object uses the material based on my simple shader, as does one of the cubes that will be converted to an Entity. The other cube being converted to an Entity was just assigned the DefaultHDMaterial material (that's the gray cube in the screenshots below).

    Here's a screenshot of the Scene and Game windows in the Editor before playing (the 2 red cubes are the ones using my custom shader):

    upload_2020-11-3_14-13-24.png

    When I hit play however, the cube using the material based on my custom shader that gets converted to an Entity becomes "invisible" (you can see the wireframe in the Scene window, but in the Game window it's not there). The cube using my custom material that is a Game Object is still visible (this is the red one), as is the one that uses the DefaultHDMaterial and gets converted to an entity. Here's a screenshot:

    upload_2020-11-3_14-13-57.png

    Here's a screenshot of the properties on the material based on my custom shader:

    upload_2020-11-3_14-14-22.png

    Is there something I'm missing in my setup that explains why this doesn't work?

    I realize that the Hybrid Render v2 is still under very active development and that Mesh Deformations in particular are "highly experimental", so if the answer is that this functionality simply doesn't work right now then that's a fine answer. However, based on the documentation it seems like this should work, and I believe that I followed the documentation correctly, so I wanted to ask the Forums if there was something I was missing.
     
  2. Jebtor

    Jebtor

    Unity Technologies

    Joined:
    Apr 18, 2018
    Posts:
    60
    Hey! Thanks for the detailed description. From what I can tell your material setup is correct. The issue your observe is with the setup of the GameObjects.

    Firstly, you need to make sure you are using SkinnedMeshRenderer, not MeshRenderers. The deformation system only adds the deformation components to SkinnedMeshRenderers during conversion.
    Secondly, you should only use the LinearBlendSkinning material on models that actually do skinning, e.g. have valid skinweights and at least a single bone. Without this the vertices can get multiplied by an incorrect SkinMatrix or by 0. As a result of this all vertices collapse to the origin and become invisible. By the way, the wireframe display is rendering gameobjects and is not correct (listed in known limitations).
    Lastly, to have the mesh deform you will need to write data to the SkinMatrices. Dots Animation allows you to animate the skeleton and write the pose to the SkinMatrices.

    I hope this helps you move forward
     
    Nyanpas likes this.
  3. DK_A5B

    DK_A5B

    Joined:
    Jan 21, 2016
    Posts:
    99
    It does. That's a huge help. Thanks for all of the feedback.
     
    Jebtor likes this.
  4. Jebtor

    Jebtor

    Unity Technologies

    Joined:
    Apr 18, 2018
    Posts:
    60
    Improved documentation (with more detailed steps) on creating a valid setup is making its way public! Thank you for raising this on the forums :)
     
  5. WAYN_Games

    WAYN_Games

    Joined:
    Mar 16, 2019
    Posts:
    619
    hi @Jebtor ,

    Note that the documentation of the package com.unity.rendering.hybrid has a broken link to DOTS Animation Samples.:

    Mesh Deformations
    This page describes the functionality to deform meshes using skinning and blendshapes, similar to what SkinnedMeshRenderer does. Generally, you want to use this in combination with DOTS Animation. Samples of setups and usage of the systems can be found in the DOTS Animation Samples.


    correct link should be
    https://github.com/Unity-Technologi...b/master/UnityAnimationHDRPExamples/README.md
     
unityunity