Adding Dual Quaternion support to UnrealEngine4 (Images inside)

1246714

Comments

  •  Hey guy, total newb here :D . Any kind soul who could help me out with installing/ getting this to run? Here is what I have done so far, but while the engine runs and compiles, the mesh still distorts as it would in a un modified engine.

    I have installed 4.20 using UE4 Launcher

    I have downloaded the .zip corresponding with the engine version from github: https://github.com/AlienRenders/UnrealEngine/tree/4.21-mod

    I have unzipped and pasted the files over the install directory for 4.20, replacing existing files.

    Loaded the editor

    Loaded an existing project that contained a gen8 mesh

    Compiled it to test, and it compiles.

        Now, who could help me with this, maybe a video tutorial? or at least some detailed steps?

    PS: My project is BP only and I suck big time at c++.....

  • MacislavMacislav Posts: 126

    @AlienRenders: Sorry for my delayed answer (was away doing some other non-gamedev related stuff in the last few weeks/months)

    I'm using your Dual Quaternion Skinning Version 4.21 and I've tried to reproduce the scaling glitch. Scaling of arms seems to work, but when I try to scale and rotate a bone (mostly face expressions), then there

    are distortions in Unreal Engine (in Blender everything works just fine).

     

    @strezoiualexandru: The newest version now is 4.21. You should use that one. As for building it, there is a tutorial, which explains everything step by step:

    https://docs.unrealengine.com/en-US/GettingStarted/DownloadingUnrealEngine

    https://docs.unrealengine.com/en-us/Programming/Development/BuildingUnrealEngine

  • @strezoiualexandru You have to build the engine with the source. You only need 4.21-mod and get the free msvc2017 compiler. The build instructions are a little wonky though. I think you need to run Setup first. This should download and install prebuilt third party libs. Then run GenerateProjectFiles. Then open the solution and build the release version of the editor.

    @doktorfrank_5ca7a24d86 Face expressions have more bones per vertex than allowed by Unreal engine. By default, it allows 4. If your mesh uses more, then it will automatically use 8 influences per vertex. I do know that G8 models have even more influences than that. So this could be why you're seeing distortions. While I did add support for DQ with 8 bone influences, I haven't tested that part a whole lot. So it's also possible that there's a bug in the shaders for the extra 4 bone influences. I'll take another look at the code to see if there isn't anything obvious.

     

  • I looked at the code again and everything looks good. I did find bugs if you have the 2 bone limit option enabled in your project. The shaders won't compile. But if you don't have that on, it should work. I'll have to make an object with 8 bone influences and test them individually. That'll take some time though.

     

  • AlienRendersAlienRenders Posts: 793
    edited January 2019

    I may have inverted the multiplication of the scale factors. I'll do some more testing in the next couple days.

    edit: You know what... I think I had tried multiplying the scaling factor per row and it didn't look right. So I flipped it. But I may not have realized this was clobbering the offset column.

    Instead of this:

        OutMatrix[0] *= ScaleFactor;
        OutMatrix[1] *= ScaleFactor;
        OutMatrix[2] *= ScaleFactor;

     

    I need to do this:

        OutMatrix[0] *= ScaleFactor.xxxw;
        OutMatrix[1] *= ScaleFactor.yyyw;
        OutMatrix[2] *= ScaleFactor.zzzw;

    You can update GpuSkinVertexFactory.ush and GpuSkinCacheComputeShader.usf yourself or you can wait until I try it out and add a patch.

     

    Post edited by AlienRenders on
  • AlienRendersAlienRenders Posts: 793
    edited January 2019

    I tested it again and the original code is good. I verified (again) that the math was accurate as well. I tried my modification above just to see and it gives the wrong results.

    So I'm not sure where you're getting distortions from.

    edit: Ok, I found the problem. The scaling is supposed to be localized to each bone. But I'm propagating it to child bones. Here's a link to explain the problem.

    http://rodolphe-vaillant.fr/?e=78

    In the image at the top, you can see I'm doing what's on the left. But DAZ is doing what's on the right.

    I'll look into it and try to get a fix soon. Thanks for bringing this up!

     

    Post edited by AlienRenders on
  • I tried adding localized scaling and I don't see any way of making this work. The entire UE4 engine is based around propagating scale because it makes the math so much simpler. You just multiply transforms as you go up the bone chain.

    Now, scaling on the very last bone in a given chain will still work fine the way it is now. So facial expressions should still work with scaling since those are all end point bones. Scaling on the root bone also works fine since DAZ Studio will propagate the root bone's scale. This is what allows you to scale a whole figure for example. But any intermediate bones, like the shin bone, will only allow scaling on that one bone.

    If you scale any intermediate bones, you'll have to bake those in before export.

    Having said all that, you can still create your own expressions in UE4. They'll just be different values than what'd you'd do in DAZ Studio.

    @doktorfrank_5ca7a24d86 What facial bone are you seeing distortions on?

     

  • arrayarray Posts: 10
    edited January 2019

    @alienrenders I know you have the 4.21 mod available (thanks for this!) but just wondering is it possible for me update that with the latest hot fixes? (4.21.2) or would that have to be an altogether new release for you on github?

    In the process of considering if I should go the DQ route in Unreal. Are there any issues you know of? I know one sacrifice is that it's local only, no multiplayer but are there any other compromises? In particular I'm wondering if I could run into any issues with Niagara using the skinned mesh to do all kinds of effects on it.

     

    Thanks!

    Post edited by array on
  • dizzy88dizzy88 Posts: 51

    While playing around with animations, poses etc. I've encountered situations, where I needed to scale some bones, for example for simulating swelling of certain body parts or for an even broader range of facial expressions, but it doesn't work with the Dual Qaternion Version of Unreal Engine. In blender everything looks fine with "preserve volume" checked, but in Unreal Engine there are bad artifacts, if I use scaling.

    Will there be a version of the Dual Quaternion Mod, which allows for scaling of bones?

    Scaling should work. I tested it myself. If it doesn't work, then something else is going on. What version are you using?

    I think scaling doesn't work as you might expect with DQS when using non-uniform scaling.  Uniform seems fine but if you try to scale in just the X axis, or just the YZ axis, the results are wonky.  Maya has the same behavior when using DQS.

    The solution suggested here: http://rodolphe-vaillant.fr/?e=78 was to apply linear first, ignoring everything but the joint scale, then apply the rest via DQS.  But I'm guessing that's probably not a viable solution here...might have to just use morphs to "fake" non-uniform scaling where needed...

  • Hey, i was trying to adding it manually, i get this error on every IF - Section u made

    "is not defined as a preprocessor macro, replacing with '0' "

     

    KS

  • MacislavMacislav Posts: 126
    edited February 2019

    I will create a new MakeHuman character during the next days for doing some tests to tell you where the problem occurs and how it does look like visually. With my current test character even scaling of the end bones is sometimes glitchy. As a last resort there are still shapekeys for achieving a scaling effect.

     

    Post edited by Macislav on
  • MacislavMacislav Posts: 126
    edited February 2019

    I've made a new expression, where one bone (the highlighted one) is scaled and rotated at the same time. (single keyframe animation)

    For being able to apply the expression in blender I've had to set the transform to "Axis Angle".

    Preserve volume is checked. In blender everything looks just fine.

    But in UE it looks glitchy. I'm using your 4.21.1 version of ue. This is just one example.

    blender example.jpg
    1241 x 742 - 167K
    ue example.jpg
    895 x 842 - 162K
    Post edited by Macislav on
  • xermaoxermao Posts: 7
    edited March 2019

    In second picture,the right one is original ue4,the left one is mod version.

    the C region look very good,mod version fix the skining error.

    But in A and B region,the mod version look much worse than original version,anyone can help me?

    (Imagery removed due to nudity. Please review the guidelines here.)

     

     

     

    Post edited by Cris Palomino on
  • @xermao Heels don't have bones anymore in G8F. If that's what you're using, you're missing correction morphs. In fact, most bends have correction morphs. 

    @ianbercovross You can do multiplayer with Unreal. Why would using DQ not allow multiplayer? I don't know what Niagara is. There should be no issues just merging the updates from the main UE branch. I'll update the mod branch this weekend if I have time.

    @doktorfrank_5ca7a24d86 Preserve Volume is a Blender only issue. There should be no need for such an option. DQS does not lose volume by default. Also, Axis Angle is one specific way of defining a rotation (a vector and an angle around that vector). But it has zero impact on how rotations are defined in DQS. Did you make the expression in DAZ Studio? It looks like you made it in blender. If so, I can't help you. If Blender uses "Preserve Volume", then it's blowing up the geometry during rotation for no good reason which is why it's blowing up when imported into UE4. Like I said, I have no idea why that option exists in Blender. For some reason, their quaternion rotations end up shrinking the objects. My code (and DAZ Studio) does not shrink the object when rotating. So Blender likely exports a scaling component to keep the correct size in Blender. But in DAZ Studio and UE4, such scaling is unnecessary. But since it's there, you get the effect that you're getting. That's my best guess anyhow.

    @dizzy88 The problem is not DQS. You get the same issue with linear blending. The issue is simply one of design. DAZ Studio decided to use local scale (except for the root bone which does global scale). DQS doesn't even enter the picture. And yes, I know about the link you used. I posted the exact same link in my comment. I explained the problem in fixing it. The entire UE4 engine is designed around global propagating scale. I tried changing it, but it broke almost everything. Also, it affect both uniform scaling and single axis scaling.

     

  • xermaoxermao Posts: 7

    @AlienRenders

    When I import daz fbx into ue4,the clothes broken if the pose with a big angle.Do you know how to fix it?

  • The pants or the shoes? The pants looks like plain old pokethrough. Not sure what's going on with the shoes. Sorry.

  • xermaoxermao Posts: 7
    edited April 2019

    The pants or the shoes? The pants looks like plain old pokethrough. Not sure what's going on with the shoes. Sorry.

    Any way to fix this pants error?

    Post edited by xermao on
  • Richard HaseltineRichard Haseltine Posts: 101,455

    Select them, Edit>Figure>Geometry>Apply Smoothing Modifier, then in the parameters pane under Mesh Smoothing set the Collision target to the human figure.

  • dizzy88dizzy88 Posts: 51

    @dizzy88 The problem is not DQS. You get the same issue with linear blending. The issue is simply one of design. DAZ Studio decided to use local scale (except for the root bone which does global scale). DQS doesn't even enter the picture. And yes, I know about the link you used. I posted the exact same link in my comment. I explained the problem in fixing it. The entire UE4 engine is designed around global propagating scale. I tried changing it, but it broke almost everything. Also, it affect both uniform scaling and single axis scaling.

    Hmm, if propagation to children is the problem, can't people just scale the children by 1/S when they scale the parent by S?  Could be done in an anim blueprint...

    Anyway, I was talking about this problem: scale on the hip is set to (1.5, 1.0, 1.0), and the only difference between the pictures is that one is linear skinning, the other is DQ:

    imageimage

    Happens in UE4, too...I guess that's just how it works...

    CLS.jpg
    384 x 503 - 24K
    DQS.jpg
    400 x 508 - 30K
  • Select them, Edit>Figure>Geometry>Apply Smoothing Modifier, then in the parameters pane under Mesh Smoothing set the Collision target to the human figure.

    This is Unreal Engine, not DAZ Studio.

    @xermao There is no easy fix. You'll have to create your own morphs. In fact, it's best to not use any smoothing modifier in DAZ Studio before you export to see the effects. Fix it by creating your own morps and then import those into UE4. I don't know if smoothing modifier effects can be exported to obj. If this works, then you could re-import the export to create morphs without having a modeling application.

     

  • xermaoxermao Posts: 7

    Select them, Edit>Figure>Geometry>Apply Smoothing Modifier, then in the parameters pane under Mesh Smoothing set the Collision target to the human figure.

    This is Unreal Engine, not DAZ Studio.

    @xermao There is no easy fix. You'll have to create your own morphs. In fact, it's best to not use any smoothing modifier in DAZ Studio before you export to see the effects. Fix it by creating your own morps and then import those into UE4. I don't know if smoothing modifier effects can be exported to obj. If this works, then you could re-import the export to create morphs without having a modeling application.

     

    When will the 4.22 mod version come in?

  • EllessarrEllessarr Posts: 1,395

    i've started to follo this topich which looks really interesting since i'm using to unreal to make my game and planning to use daz and it's looks like being a little complicated and after reading the thread it's really looks interesting my only problem is if we can have any chance of it being a plugging instead of a mod to be compiled with the engine, could be much more fast if it could be like a plugging which could make things more fast.

  • AlienRendersAlienRenders Posts: 793

    @Ellessarr This has already been asked. It can't be a plugin. Plugins are only for new assets. This is a change in the existing shaders and plugins don't allow for it. If I'm mistaken, please point me to the documentation on how to do this and I'll gladly put it in a plugin.

    @xermao I'll check for any new versions and get the mod going this weekend at the latest (but I'll try to do it Tuesday or Wednesday). Apologies for not seeing the releases sooner. Anyone is free to message me directly when a new release comes out. I have all the steps listed, so it's really for me to do now.

     

  • MacislavMacislav Posts: 126
    edited May 2019

    @AlienRenders: I've found out in the meantime, that there are better ways for doing expressions with MakeHuman in Blender, without having to resort to "tricks" like I was doing back then and now everything works just fine.

     

    But I've found another problem, which could have to do with the Dual Quaternion Version of Unreal Engine. Can you have a look into it please and tell me, if those problems could be caused by the Dual Quaternion Version of UE? (it seems as if the lighting/shadows don't match with the Morph Targets and another problem is a Mesh Distortion in the upper arm, that doesn't occur in blender, but in UE4)

    https://forums.unrealengine.com/development-discussion/animation/1616076-skeletal-mesh-shadow-glitch-in-ue4

    Post edited by Macislav on
  • MacislavMacislav Posts: 126

    The shadow problem went away by changing some settings in the UE4 editor, but the arm distortion still remains.

  • lawwlekluzelawwlekluze Posts: 19

    I'm curios about performance. If I use dual quarternion, how much is it heavier than linear?

  • dizzy88dizzy88 Posts: 51

    Any chance of a 4.22 version? ;)

  • UpL8RenderingUpL8Rendering Posts: 129
    edited May 2019

    It looks like the 4.22 update is live! Thank you AlienRenders

    Post edited by UpL8Rendering on
  • Hey guys, I've been using the dual quat mod for a bit (huge thanks to Alien Renders) and recently started adding some extra joints to my Daz character for jiggle effects. It's been going well except for on the legs I am having some distortions that are only showing up in unreal. The character looks nice and smooth in daz and 3ds max, so I had a feeling it was because of unreals 8 bone per vertex limit. However... I've put it in 3ds max and set the Bone Affect Limit to 8 on the skin modifier just to see what happens and it's still giving me nice smooth legs... so I'm a bit stuck. As far as I can tell I only have 6 joints influencing the skin in that area anyway. I've also tried smoothing the weights some more and it didn't help. Could this be a problem with the dual quat mod?

    Capture4.PNG
    690 x 455 - 80K
    Capture5.PNG
    905 x 852 - 139K
  • MacislavMacislav Posts: 126
    edited June 2019

    I've got the same problem (mesh distortion), but with the upper arms, when raised (see my link from the 7th of may). Limiting the weights to 8 in blender looked just fine and smooth in blender, but not in UE4.

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