Adding Dual Quaternion support to UnrealEngine4 (Images inside)

18910111214»

Comments

  • Any Chance you will be able to get a 5.4-mod going? I had tried to cherry-pick your work from ue5-dqs as well as previous branches but was unsuccessful. I would be fine using 5.5 except i am unable to build plugins for that version currenty.

  • AlienRendersAlienRenders Posts: 802

    Sorry for the late reply. I will try to get everything up to date as soon as I can. I think 5.4 just needs to cherry pick an older revision from ue5-dqs but I may have force merged that. I'll check if I still have an older build.

     

     

  • nabenabe Posts: 2
    edited March 2025

    While researching Dual Quaternions, I found this topic.
    Will it become available in UE5.4 or UE5.5 in the future?

    I'm currently using UE5.4, and as I wrote in the last post at the URL below, I'm using a deformer called "DG_DualQuatDefoermerDemo," but I'm having difficulty with production because morph targets can't be used.
    https://forums.unrealengine.com/t/dual-quaternion-support/144831/28

    It would be great if there was a DQ deformer that could easily use morphs...

    Post edited by nabe on
  • Visual SculptVisual Sculpt Posts: 5
    edited March 2025

    Dual Quaternion Skinning has been available in Unreal Engine through the Deformer since it was introduced in the 5.1 Content Examples project. Not long after it was added to the David Vodhanel's updated fork of DazToUnreal. I posted a tutorial recently going over basic export, import, and fixes for using DazToUnreal that includes how to enable it on a character. I have used it with morphs and haven't had issues.
    https://www.daz3d.com/forums/discussion/725206/daztounreal-for-ue-5-5-tutorials

    Originally, if I remember right, there were 3 versions of the DQS Deformer. First that was just base mesh, second that included morphs, and a 3rd that was supposed to project for clothes but was very buggy. The current Content Examples project seems to have kept just the 2nd version.

    Post edited by Visual Sculpt on
  • nabenabe Posts: 2
    edited March 2025

    I downloaded UE54win.zip from the URL below and moved "DTU_DQS_Deformer" to my project, and it worked properly!
    Thank you very much!

    https://github.com/daz3d/DazToUnreal/releases

    However, when I changed the Morph Target values, the normals became strange and weird shadows appeared. So I combined "DTU_DQS_Deformer" and "DG_TEST." Since I did this intuitively without proper knowledge, other problems might arise, but the normals are now working correctly.

    スクリーンショット 2025-03-30 024326.png
    968 x 733 - 179K
    Post edited by nabe on
  • Visual Sculpt said:

    Dual Quaternion Skinning has been available in Unreal Engine through the Deformer since it was introduced in the 5.1 Content Examples project.

    If it works for you, great! It's just unfortunate that it's so badly implemented (slow). For every vertex, it converts all the LS matrices to DualQuaternions and then applies the weights. So if you have 100 bones and 100k vertices, you have 10 million conversions. In my branch, it converts it once (100 conversions) and sends it to the video card. So 100 conversions vs. 10 million. Now, there is the conversion back for the result, but that part is the same for both. It's been a while since I've checked the code in those graphs. Hopefully, if you have limited bone influences, it'll only convert 8 matrices per vertex. But that's still 800,000 vs 100.

    I'll try to create a good branch for 5.5 soon. I'm just working on something else right now and don't need DQS atm. The problem is getting the deformer graphs installed. You'll have to manually copy them since UE has a separate script for downloading and installing engine content.

  • nabenabe Posts: 2

    AlienRenders said:

    The bad news is that it would be extremely inefficient. What the "Skeleton" node does right now is execute a shader that reads all the bone matrices that affect ONE vertex (at a time). It outputs all these matrices as Bone Matrix output. It merges them all together according to the bone weights and outputs it as "Weighted Bone Matrix". We can't use this weighted bone matrix as the whole point of using DQS is to have different method of computing the final transform. So I *could* convert each set of bone matrices that affects the vertex. But this would be executed on every vertex. Converting LS matrix to DQS isn't the fastest thing in the world. Doing it over and over on the same matrices would be extremely slow. As a stopgap measure, maybe it would be ok. Dunno.

    Just to give a better example of what I mean by inefficient. Say there are 100 bones. And 100K vertices. And you decide to use 8 bone influences per vertex. With the DQS branch, it converts the 100 bone matrices to DQS before sending it to the shaders. Now, it does convert it back, so that's once per vertex. That's 100,100 conversions. I tried avoiding converting back since it just needs to multiply with the vertex position, but I didn't want to mess with the existing shader code.

    With the deformer, there would be 800K conversions. These conversions are not simple. And it gets worse for unlimited bone influences.

    Looking back at past logs, I see you mentioned this two years ago as well...

    I had read it before, but after testing it myself, I finally understand the issue.
    When moving simple objects like individual characters, it looks good and works fine, but when placing multiple characters, the performance drops significantly.

    Thank you for your advice. And thank you for planning to create a 5.5 branch.
    I can't help with development work, but I'll patiently wait for your updates.

  • Visual SculptVisual Sculpt Posts: 5
    edited April 2025

    nabe said:

    I downloaded UE54win.zip from the URL below and moved "DTU_DQS_Deformer" to my project, and it worked properly!
    Thank you very much!

    https://github.com/daz3d/DazToUnreal/releases

    However, when I changed the Morph Target values, the normals became strange and weird shadows appeared. So I combined "DTU_DQS_Deformer" and "DG_TEST." Since I did this intuitively without proper knowledge, other problems might arise, but the normals are now working correctly.

    I don't recommend that version, it is very outdated. The fork by David Vodhanel, the original author of the plugin, is updated regularly and the last was just 3 weeks ago. The mainline version from Daz is over a year and a half old and missing a lot that David has done since.

    Link to David's fork: https://github.com/David-Vodhanel/DazToUnreal

    Follow the tutorial I linked earlier to install it correctly. You don't need to edit anything, just enable the Deformer on the character and it works. There is no performance hit if you are on the newest versions of Unreal, the Deformer has gone through major updates in recent versions. It may take time to process the first time you apply the Deformer, because it is making all the calculations, but once done and cached it is good to go. It does not do all the calculations on the fly as suggested.

     

    AlienRenders said:

    If it works for you, great! It's just unfortunate that it's so badly implemented (slow). For every vertex, it converts all the LS matrices to DualQuaternions and then applies the weights. So if you have 100 bones and 100k vertices, you have 10 million conversions. In my branch, it converts it once (100 conversions) and sends it to the video card. So 100 conversions vs. 10 million. Now, there is the conversion back for the result, but that part is the same for both. It's been a while since I've checked the code in those graphs. Hopefully, if you have limited bone influences, it'll only convert 8 matrices per vertex. But that's still 800,000 vs 100.

    I'll try to create a good branch for 5.5 soon. I'm just working on something else right now and don't need DQS atm. The problem is getting the deformer graphs installed. You'll have to manually copy them since UE has a separate script for downloading and installing engine content.

    What you say may have been the case in 5.1 when it was Experimental, but have you tested it in recent versions? Deformer works great now and shows no performance impact. In fact it reduces my frame times by 1ms when applying DQS.

    I made a fresh example to demonstrate. It has Kat, Laura, and Ty for G9 all subdivided at level 2 when exported from Daz. Unlimited Bone Influences enabled. Using the MetaHuman Lighting project on the Portrait_RT level. VT used to keep original texture quality with everything still default 4k. You can see enabling the DQS_Deformer somehow improves performance here. You can tell when it's disabled by the pointed deformity between the legs and flattened glutes during the jump landing. Then when enabled those issues are gone and it matches how it looks in Daz using the same animation.

    Here is a raw screen recording with DQS Deformer off then on:

    As you can see, I'm also running on older mid-range hardware as shown at the end- i5-9600k + RTX 2070. It would run even better if I wasn't screen recording.

    And did you ever submit a pull request for your branch so Epic could included it in the engine? If you've got good code changes Epic will incorporate it, there is plenty of code attributed to users. If you did, it may have been implemented and could be why it runs better now.

     

    Post edited by Visual Sculpt on
  • AlienRendersAlienRenders Posts: 802
    edited April 13

    Just wanted to give an update. There's been some changes to add support for nanite to skeletal meshes a while back. My pull request has still not been looked at in over 3 years. And I can confirm the existing deformers are extremely slow. The main branch still has bugs in their dual quarternion code. That means the results are buggy both in C++ and in the deformers (their library nodes are buggy as well).

    I've updated my pull request and I'll be doing some tests to ensure it works. I'll be updating my ue5-dqs branch today or tomorrow. Once it's up, it should be easy to cherry pick into your own project if you build from source.

    Something I noticed is they refactored the code that stores the bone transforms uniforms (data sent to the GPU). It makes the conversion code easier to update, but it makes it much more difficult to send the flag indicating what skinning format to use down to those functions. It would really simplify my pull request if I just had compiler setting to make all skeletal meshes use DQ. I feel that may be a bit much for most people. Next best thing is a project setting that turns on DQ for the entire project. Would a global option be good or do people need to mix and match? I'm strongly leaning toward a project setting that enables DQ for all skeletal meshes. Epic will refuse pull requests if they have to maintain too many changes and the existing code seems to change a lot. A project setting would reduce the number of files affected by 70%. There aren't many changes in those files, but the fact that there are many files affected is the problem. This would isolate most of the changes to a few files.

    Sorry for not spending more time on this. I've been working on my game and other stuff. So I've been a bit busy.

    edit: A lot has changed in the codebase for UE5.8. I've decided that you just need to change one preprocessor define and build the engine and all skeletal meshes will use Dual Quaternion Skinning. You'll still need a deformer graph. These will be provided with the deformer plugin if Epic approves my pull request. They updated the skeletal mesh node in the graphs. I've added a new one for DQS. The reason I'm doing it with one preprocessor define is that it greatly simplifies the pull request. There's very little to maintain. Storing the bone transform uniforms never needs to be touched anymore. That means all that's left are extra deformer nodes and those are mostly independent.

    edit2: I've updated my pull request. To improve the chances of it getting accepted, I've stripped it down to the basics. There's one preprocessor define you change in a header file. Build the source and all skeletal meshes will use DQS. They changes some of the nodes in the deformer graphs and I've provided the updated one for DQS in the ue5-graphs branch under Engine/Plugins/Animation/DeformerGraph/Content/Deformers. So if you're merging changes to your own branch, you'll have to manually copy these graphs over to the same folder.

    edit3: I'm going to scale down my pull request even more. My pull request will now only include the core codebase changes that can't be put into a plugin. The rest will go into a plugin that I'll make available on my github account. So the deformer graphs and nodes will go into a separate plugin. This will greatly increase the chances of my changes being approved.

    Post edited by AlienRenders on
  • AlienRendersAlienRenders Posts: 802
    edited April 14

    I created a new branch with Dual Quaternion Skinning already enabled project wide. It also includes DazToUnreal plugin. You will need to enable DazToUnreal and DQSPlugin plugins in the editor.

    My github

    https://github.com/AlienRenders/UnrealEngine

    The branch is 5.7-dqs

    You still need to add a deformer on each skeletal mesh. I've provided 4 of them in the DQSPlugin plugin folder. In content browser settings, you'll need to enable engine and plugin content. Then go to Plugins/DQSPlugin and there are deformers there you can use.

    This was a crazy amount of work to reduce it and split it up this way. I'm hoping to be able to add a project setting for the default deformer. But that'll have to wait for another day.

    There was aready a project setting for the default deformer, but it wasn't actually used. I did in fact made it work on the skeletal mesh component.

    ---

    If you're new to building from source, you can follow these steps. Note that this will download about 50GB or more all together I think.

    1. Download and install Visual Studio Community 2022. Select Desktop dev w/ C++ , .NET desktop dev, Game dev w/ C++, latest Windows 11 SDK (even if you're on Windows 10).

    2. Install git for windows (and optionally TortoiseGit if you're gonna use git yourself).

    3. Open console prompt.

    If you have a github account, type:

    git clone https://github.com/AlienRenders/UnrealEngine.git

    git checkout 5.7-dqs

    OR

    just go to the link above (at the very top). Select the 5.7-dqs branch. Then there's a green dropdown button that says "Code". Click on that and there'll be a button to download the zip. Unzip it on your drive somewhere.

    5. Open a console prompt and change directory until you're inside the UnrealEngine folder. Type the following (note Setup will download like 30GB of third party libs and content):

    Setup

    GenerateProjectFiles

    6. Open the .sln file with visual studio. Make sure the project type is set to Development Editor. Build UE5. You can launch with Debug/Start Without Debugging menu.

     

    Post edited by AlienRenders on
Sign In or Register to comment.