Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Shader does not support skinning.

Discussion in 'DOTS Animation' started by qubka, Jan 5, 2021.

  1. qubka

    qubka

    Joined:
    Dec 10, 2020
    Posts:
    4
    Hello, I am trying to use prefab to spawn dots entity with it. Mesh looks like that, so I have skinned mesh model there, when I spawn it I am getting : [HDRP/Lit] does not support skinning.

    upload_2021-1-5_21-4-57.png
    Therefore I tried to use shader from RemyUnity/SG-HDRP-Lit: Shadergraph version of the HDRP/Lit shader. (github.com) (Lit_Graph) on the textures, it didn't work. Also, I tried to generate my own shader with that structure, using texture and colour, it also didn't work for my mesh. What I am doing wrong?

    I created a project with HD RP by default, but I am not able to see what in the default shaders. Do I need use them? If yes, how I can do that? Thanks
    upload_2021-1-5_21-9-10.png
    Ps Also found some graph on the forum which I can browse, and it also did work, it make the model invisible. I tried different bone indexes, which one I should use? I test on the RTS_Toon sample model from asset store

     
    Last edited: Jan 6, 2021
  2. paddan

    paddan

    Unity Technologies

    Joined:
    Jun 19, 2019
    Posts:
    13
    Hello,
    I assume you are using hybrid renderer? In that case all you need to do is assign the shader that supports skinning to your material. During conversion the Hybrid Renderer will set the correct indices and pass this information along to your shader, meaning you should not have to assign the Bone Index property a value manually.

    Here you can find more information about the setup:
    https://docs.unity3d.com/Packages/com.unity.rendering.hybrid@0.10/manual/mesh_deformations.html

    Hope this helps
     
  3. deus0

    deus0

    Joined:
    May 12, 2015
    Posts:
    256
    Hi paddan, i'm wondering how to pass the bone transforms (which are entities for me) into the material/shader?
     
  4. Sobirux

    Sobirux

    Joined:
    Apr 2, 2019
    Posts:
    6
    I'm having the same issue. If I add a "Linear Blend Skinning" node to a shader graph and connect the dots as per @paddan 's link suggested, it makes the model go invisible. Any idea how to properly make a shader support skinning?
     
    deus0 likes this.
  5. deus0

    deus0

    Joined:
    May 12, 2015
    Posts:
    256
    Hi Sobirux, after a lot of research I think it's mostly built for the new conversion workflows rather then pure dots. You can import the animation package and then play with the examples, but it will only really work for those workflows. I myself will be writing some custom shaders or nodes, and using compute buffers to upload the bone transforms as this seems like the most optimal solution for my project. The new node's data I believe is inputted through that new animation package.
     
  6. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356

    Conversion is not about converting the old gameobject way to DOTS. It's about creating data in the most efficient format for fast loading and handling the creation of that data at design time instead of runtime. Conversion saves the data as raw pointers, so it can read it back in at runtime as raw pointers. It is emphatically part of a good DOTS workflow even a procedural one.
     
  7. deus0

    deus0

    Joined:
    May 12, 2015
    Posts:
    256
    I had a different impression from unity's various responses on the forum.
     
  8. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
  9. paddan

    paddan

    Unity Technologies

    Joined:
    Jun 19, 2019
    Posts:
    13
    The only thing you should need to do is add one of the two nodes to your shader for it to support skinning in DOTS. What will happen when you put the Skinned Mesh Renderer in a sub scene is that the SkinnedMeshRendererConversion system will add a couple of components that keeps track of the skinning data, and the character will be rendered in bind pose.
    Note that you can't use this shader for non-skinned meshes unless you add some logic to it, since the shader will try to skin anything it is applied to. You also need to save the Shader Graph using the 'Save Asset' button for changes to be applied.

    Another thing to be aware of is that the Linear Blend Skinning Node and Compute Deformation Node only apply the skinning (and Blend Shapes for Compute Deformation Node), they don't do any animation. If you want to use animation you would either need to provide the animated transform data to the SkinMatrix component, or use DOTS Animation package which does this for you.

    I can't really say what goes wrong, I know this can happen if you use a Mesh Renderer instead of a Skinned Mesh Renderer for example. If you follow the steps under Setup in the documentation page it should work.
    Some things to verify is that your shader is assigned to the correct material, that the material is SRP batcher compatible and that you have connected the node outputs.
     
  10. paddan

    paddan

    Unity Technologies

    Joined:
    Jun 19, 2019
    Posts:
    13
    I think you should be able to pipe them to the nodes with the SkinMatrix component, assuming all the spaces are correct. Basically what the code does is find all those entities and put them in a buffer that is read from the skinning.
    I can't really say if it that would be easier than just writing your own systems though :)
     
    deus0 likes this.
  11. deus0

    deus0

    Joined:
    May 12, 2015
    Posts:
    256
    When i first wanted a DOTS animation system. I expected it to have as much flexibility as the hybrid system. But I did mention there was a lot more complexity involved in it. And it's not as light weight. So you are forced to use game objects with it. I'm not sure, maybe many have set their dots projects up differently. I myself like the flexibility of being able to roll out custom solutions with the URP and Hybrid. As for the conversion workflow, it's not something I will use. However I think there is still pure entities tools coming after that, at least from what I read in last years unity posts.

    I had already rolled out my own animation solution using the parallel systems and vertex deformations. Moving this to the GPU i just needed a shader node that I could input the data into and it would do these bone deformations. The skin matrix component looks like what I want, but I have no idea how to insert the bone data (transform matrices) into it. It has 'Value
    Declaration
    public float3x4 Value'
    One matrix here, however that doesn't explain how my bone transform data will be sent to the gpu. I am expecting something like a list of bone transforms I can set on the component.
     
    Last edited: Jan 29, 2021
  12. paddan

    paddan

    Unity Technologies

    Joined:
    Jun 19, 2019
    Posts:
    13
    The SkinMatrix component is an IBufferElementData, which means that an entity has a range of matrices. The deformation-systems look for this specific component and then adds them to one big buffer, which then gets pushed to the GPU. If you want to use the deformation systems you would output your animation result in these matrix-buffers, note that it is the skinned transformations of bones in relation to the bind pose that should be stored in the SkinMatrix component.
    This data will then get pushed to the GPU and picked up by either the Linear Blend Skinning or Compute Deformation node. The shader will then skin each vertex position to the matrices using the weights and indices from the mesh data. If you use the Linear Blend Skinning node you can look at what the shader code does by using the option 'show generated code' in the inspector when selecting the shader graph asset.
     
    jconsole likes this.
  13. DevViktoria

    DevViktoria

    Joined:
    Apr 6, 2021
    Posts:
    94
    I think I have a related issue.
    I wanted to try to display 2 different deformed meshes within the Unity DOTS Animation package without any luck.
    It seems that only one deformation is going to applied to both of the meshes, not two different one.
    I created a short video of the problem:


    I am a beginner to all of this. Can anyone help me how can I solve this problem?
     
  14. Jebtor

    Jebtor

    Unity Technologies

    Joined:
    Apr 18, 2018
    Posts:
    113
    @DevViktoria is Hybrid Renderer v2 enabled in the project? This is required for the compute deformations node. You can enable the Hybrid Renderer v2 in Project Settings > Player > Scripting Define Symbols and add an entry with
     ENABLE_HYBRID_RENDERER_V2
    .
     
  15. DevViktoria

    DevViktoria

    Joined:
    Apr 6, 2021
    Posts:
    94
    I tried and now I got the following error message:
    A Hybrid Renderer V2 batch is using the shader "Shader Graphs/Basic_Compute_Deformation", but the shader is either not compatible with Hybrid Renderer V2, is missing the DOTS_INSTANCING_ON variant, or there is a problem with the DOTS_INSTANCING_ON variant.
    UnityEngine.GUIUtility:processEvent (int,intptr,bool&)

    Edit: This actually breaks the Blendshapes scene in the animation examples as well with the same error message.
     
    Last edited: Nov 19, 2021
  16. NT_Ninetails

    NT_Ninetails

    Joined:
    Jan 21, 2018
    Posts:
    195
    Did you add ENABLE_COMPUTE_DEFORMATIONS to the defines?

    This is what I have in my environment

    upload_2021-11-19_12-42-11.png
     
  17. DevViktoria

    DevViktoria

    Joined:
    Apr 6, 2021
    Posts:
    94
    This is what I have now in the environment:
    upload_2021-11-20_17-19-14.png
     
  18. Jebtor

    Jebtor

    Unity Technologies

    Joined:
    Apr 18, 2018
    Posts:
    113
    Hmm could you try clearing the library? Close the project, delete the library folder in your file explorer - it is in the same directory as the Asset folder. Then open the project again.

    I believe the animation samples for URP aren't setup correctly with Hybrid V2 (which is a requirement for the compute deformations). An example of a correct project setup using Hybrid V2 and URP can be found here.
     
  19. DevViktoria

    DevViktoria

    Joined:
    Apr 6, 2021
    Posts:
    94
    Clearing the library did not helped.
    But I also tried to put the deformed meshes into the Hybrid Examples and there it worked I did not got the error.
    However I tried to create my own shader graph and material to learn how to create these thing and I got errors:
    Code (CSharp):
    1. Shader error in 'Master': syntax error: unexpected token ')' at line 264 (on vulkan)
    2. Shader error in 'Master': undeclared identifier 'UNITY_ACCESS_HYBRID_INSTANCED_PROP' at line 264 (on vulkan)
    See the attached screenshot.
    I don't understand why is this happening. Can someone help me how to solve this?
     

    Attached Files:

  20. Jebtor

    Jebtor

    Unity Technologies

    Joined:
    Apr 18, 2018
    Posts:
    113
    The errors you're seeing are related to the SG preview as I recall. You should be able to ignore those. This should be resolved in a future version. The deformations should work as expected in the Hybrid samples regardless of the error. Please let me know if this is not the case.
     
  21. DevViktoria

    DevViktoria

    Joined:
    Apr 6, 2021
    Posts:
    94
    Yes the deformations are working and the game is rendering just fine :)
     
  22. Jebtor

    Jebtor

    Unity Technologies

    Joined:
    Apr 18, 2018
    Posts:
    113
    Perfect, please ignore those last errors for now. Sorry for the inconvenience. We certain hope to improve the workflow here in the future. To summarize the other issue, the provided project by us with the animation samples is not setup correctly with Hybrid V2 for URP. I have notified the animation team. If you get it running with Hybrid V2 the deformations should work correctly in that project. Hybrid V2 will log a warning every time you enter playmode.
     
  23. DevViktoria

    DevViktoria

    Joined:
    Apr 6, 2021
    Posts:
    94
    Thank you very much. After comparing the setting with the Hybrid samples I figured out what was the problem. I am using Linux and it seems that the Hybrid Renderer V2 is only works with the Vulkan Graphics API
    upload_2021-11-23_12-52-29.png
    After I set this like so my test and the Blendshape example is working correctly with Hybrid V2.
     
    NT_Ninetails and Jebtor like this.