Home

Awesome

Dual quaternion skinning for Unity

Features

Comparison DQ vs built-in linear

GifDifference
<img src="https://raw.githubusercontent.com/ConstantineRudenko/DQ-skinning-for-Unity/master/Screenshots/before-after.gif" width="400"><img src="https://raw.githubusercontent.com/ConstantineRudenko/DQ-skinning-for-Unity/master/Screenshots/diff.png" width="400">

Bulging compensation demo

<img src="https://raw.githubusercontent.com/ConstantineRudenko/DQ-skinning-for-Unity/master/Screenshots/Leg.gif" width="600">

Unity version

The script was tested with following Unity versions:

How to set up

<img src="https://raw.githubusercontent.com/ConstantineRudenko/DQ-skinning-for-Unity/master/Screenshots/Mesh import settings.png" width="463">
Bones properly alignedBones not aligned
<img src="https://raw.githubusercontent.com/ConstantineRudenko/DQ-skinning-for-Unity/master/Screenshots/bones aligned.png" width="400"><img src="https://raw.githubusercontent.com/ConstantineRudenko/DQ-skinning-for-Unity/master/Screenshots/bones not aligned.png" width="400">
<img src="https://raw.githubusercontent.com/ConstantineRudenko/DQ-skinning-for-Unity/master/Screenshots/Orientation axis.png" width="363">

If bulging is increased instead of decreased, select same axis with different direction (X => Negative X)

Common problems

The script is programmed to automatically detect common setup problems. Check out the editor:

<img src="https://raw.githubusercontent.com/ConstantineRudenko/DQ-skinning-for-Unity/master/Screenshots/Problems.png" width="363">

Warning

You will not see any effect in edit mode.<br> The scipt only works in play mode.<br> If you see no effect in play mode verify that you are using the right shader.

Why do i need SkinnedMeshRenderer?

My scripts uses SkinnedMeshRenderer to extract an array of bones from it. Yep, that's it.<br> The order of bones is unpredictable and does not depend on their hierarchy.<br> Only SkinnedMeshRenderer knows it    ¯\_(ツ)_/¯

After extracting the bone array in Start() my script disables SkinnedMeshRenderer component as it is no longer needed. All the animations are performed by the script. You can verify it in the editor after hitting play button.

How do I use custom shaders?

Alas it's complicated.<br> I added comments to "Standard hacked for DQ skinning" marking the alterations i made to the Standard shader.<br> You can try to do the same with your own shader to make it work with the script.

Feel free to contact me in this thread at unity forum if you need help.

I would also like to hear about your projects that use my script and your experience with it.

Known bugs

Must use cullingMode = AlwaysAnimate in Animator. Otherwise, the mesh is treated as permanently invisible.

You can write a short script that will toggle cullingMode based on visibility to get proper culling.

Performance

During my testing the amount of time spent on actual skinning was negligible compared to the amount of time extracting localToWorldMatrix from every bone in the hierarchy.

As long as you are not creating hundreds of characters with complex rigs (no matter the polycount) there should be no significant performance hit.

If anyone knows how to optimize extracting localToWorldMatrix of the bones please create an issue or message me on unity forum.

Works A LOT faster with IL2CPP, about 30% slower than built-in skinning in worst-case scenario according to my testing.

API

Documentation

Future plans

Discussion

If you have any questions, ideas, bug reports, or just want to discuss the script, you can contact me on unity forum

Bulging compensation method

The bulging compensation method used is described in the paper.

Notes: