Search Unity

Dual quaternion skinning for Unity

Discussion in 'General Graphics' started by mr_madcake, Oct 22, 2017.

  1. Holoboost

    Holoboost

    Joined:
    Jul 6, 2020
    Posts:
    4
    Hi there, this looks really awesome. Does this technique work on mobile (oculus quest), using opengles? Is there any way to run this on unity 2018 LTS?
     
  2. mr_madcake

    mr_madcake

    Joined:
    Jul 17, 2017
    Posts:
    93
    Hi

    I haven't tried but theoretically it should work. Have you encountered some issue with it?
     
  3. Holoboost

    Holoboost

    Joined:
    Jul 6, 2020
    Posts:
    4
    No, but I haven't because I didn't know if it would work on 2018 LTS due to the multi_pragma_compile issue. But now that you mentioned it should, I can give it a shot. Just wondering how much a performance hit it is compared to normal skinning, since we are heavily GPU bound right now,
     
  4. mr_madcake

    mr_madcake

    Joined:
    Jul 17, 2017
    Posts:
    93
    It's hard to give a clear number as it scales differently with different things. From my benchmarks I could not get worse performance drop than 30% compared to built-it skinning in purposefully built worst-case scenario, but it could vary wildly depending on the project.

    Also CPU hit from extracting bone transform matrices affected performance the most, there should be no big issue with GPU.

    If you want good performance I strongly recommend using IL2CPP compiler as is properly optimizes bone transform matrix extraction (I made the benchmarks with IL2CPP). Mono uses some really weird shenanigans that slow down the script A LOT.

    This line in particular is A LOT slower in Mono and in profiler it reportedly calls to String.memcpy() for no apparent reason.

    If you don't need the bulging compensation you can remove this part of the shader for a little extra performance. This will leave you with traditional DQ implementation.
     
    Last edited: Jul 14, 2020
  5. vladibalan

    vladibalan

    Joined:
    Sep 14, 2014
    Posts:
    6
    I have a mesh with 4332 vertices (so vertNumber/textureWidht = 4). If I use GetVertexTextureHeight in Update it is rendered garbled at runtime (I did not investigate yet why a textureHeight of 5 instead of 4 makes it do that).
    upload_2020-7-18_17-17-2.png

    Anyway, i'm posting this in case anybody else has this problem. I've reverted the line in Update to the previous form to solve the issue: this.materialPropertyBlock.SetInt("skinned_tex_height", mf.sharedMesh.vertexCount / textureWidth);
    Observation: there are multiple meshes using DualQuaternionSkinner (different vertex count, all of them worked but this one). Again, I don't know yet why, the only difference is that all the other meshes have a texture height ratio lesser than 4 (0,1,2,3).
    PS: I am using Unity 2019.4.4f1 Personal.
     
  6. sihan66

    sihan66

    Joined:
    Aug 26, 2020
    Posts:
    2
    Get the mesh of DQ blending skinning:
    I have implemented the dqls in my own project. And I want to get the mesh of human model of dqls in obj format. However, I found i get the obj model of lbs. How can i get the mesh of dqls? Thank you.

    ![dqls in unity](https://user-images.githubusercontent.com/58064039/91283618-68203d80-e7bd-11ea-8e36-63409b4b9d02.png)
    ![export lbs in obj](https://user-images.githubusercontent.com/58064039/91283629-6bb3c480-e7bd-11ea-8394-135c43a4dad0.png)
     
  7. sihan66

    sihan66

    Joined:
    Aug 26, 2020
    Posts:
    2
     
  8. mr_madcake

    mr_madcake

    Joined:
    Jul 17, 2017
    Posts:
    93
    Hi.

    I am a bit confused about what are you trying to achieve.

    OBJ format does not support animation, it is a static model. For animated models you would usually use FBX.
    Are you trying to make a static model from a single frame of animation in Unity?

    My script only works in Play mode, so if you are trying to export the model in Edit mode, you would get the model with built-in linear skinning.
     
  9. mr_madcake

    mr_madcake

    Joined:
    Jul 17, 2017
    Posts:
    93
    Could you try this version of the script with the same model?
    I would like to make sure that these issues are not connected.

     
  10. Ldnicon

    Ldnicon

    Joined:
    May 22, 2016
    Posts:
    4
    Any updates on the distortion of meshes?

    I've tried DualQuaternionSkinner.cs on different models, but they all look extremely distorted.
     

    Attached Files:

  11. Cold_Frank

    Cold_Frank

    Joined:
    Dec 15, 2020
    Posts:
    3
    Hey, I am testing different solutions for better skinning and I found something like this: OptimisedCentresOfRotationSkinning

    Could this be useful in improving your solution?

    Cheers!
     
  12. Wothanar

    Wothanar

    Joined:
    Sep 2, 2016
    Posts:
    120
    this dosnt worked to me i used version 2020.1.7 of unity, then this error happens



    line 604 of DualQuaternionSkinner.cs this.mf.sharedMesh.MarkDynamic(); // once or every frame? idk.

    I follow the guide you have on github , but it didn't worked. i set as read enable true the skinned mesh renderer character have Body And Head separated , cant work this way? I'm just don't understand what its causing it. why didn't work ?. can you be more detailed in the instructions?
    and here in my picture

    https://gyazo.com/a09ce30fb5fc1af9b2dcfe1b73448b0b


    it looks like empty in compute shaders and I cant set anything manually, so whats wrong with this? i was so excited about this but now I think I should continue with mesh animator, actually did this gpu instantiate the skinned mesh renderers? as mesh animator does? coz mesh animator its what I'm using now and works fine for GPU instancing Skinned mesh renderers
     
  13. mr_madcake

    mr_madcake

    Joined:
    Jul 17, 2017
    Posts:
    93
    If you still have this issue, you can send me the minimal example project and I will take a look.
     
  14. mr_madcake

    mr_madcake

    Joined:
    Jul 17, 2017
    Posts:
    93
    Optimized CoR indeed provide improved skinning, but AFAIK there's some issues with licensing and I'm not sure I can legally implement and share it other than for education purposes.

    The technique I used is an alternative to optimized CoR that I developed as my master's thesis. Unlike CoR it does not require any precomputations, but the quality is worse (still better than baseline DQ, but not as good as optimized CoR). Initially I implemented DQ in unity just to have it here, but when writing the thesis I decided it would be convenient to use my already working script to demo the new technique.
     
  15. mr_madcake

    mr_madcake

    Joined:
    Jul 17, 2017
    Posts:
    93
    Anyone having their models look completely butchered and distorted by the script can try this version (quoted message). I might have hard-coded some values in the script that some GPUs are not able to work with. If the issue is what I think it is, the quoted version should be compatible with GPUs failing to run the main version.
     
  16. alloystorm

    alloystorm

    Joined:
    Jul 25, 2019
    Posts:
    43
    I've been scratching my head for quite some time trying to figure out why my rigged models exported from Daz3D don't look the same in Unity comparing to Daz. Now I realized this is what I always needed...
    However I imagine it would be difficult to adopt your approach since I use a lot of custom shaders done in ShaderGraph, I guess this is going to be tricky trying to integrating your stuff in my shaders...
     
  17. alloystorm

    alloystorm

    Joined:
    Jul 25, 2019
    Posts:
    43
    CodeKiwi and ObiOneStenobi like this.
unityunity