Daz Studio To UE4 (Tutorial) Part 1

From Epic Wiki
Jump to: navigation, search


This is the first part in a series of tutorials about transferring various assets (characters, cloths, animations, morphs etc) from Daz Studio to Unreal Engine.

In this part we'll cover transferring the base character mesh from Daz Studio to unreal Engine, including a single LOD and some basic materials.

Let's get started.

Preparing and exporting the base meshes from Daz

Starting with an empty scene in Daz Studio, add the character you want to export. For this tutorial I'll be using the Michael 7 character.

I'm going to leave the character as is, but it's at this point that you would adjust the base character to your liking.

The aim here is to set the default/base shape of your character. All of the changes you make to the character at this point will be baked into the base mesh for the character. That is, they won't be adjustable via morph targets in Unreal Engine. Those will come later.

Base Michael 7 character

Now I'm going to create a null object called root, which is going to be the root bone for our character.

The reason I do this is in case I want to do root motion animations in Unreal. I've found that if I don't do this then, when the character is exported, it's root bone will be rotated 90° around the X axis and this causes problems in Unreal when trying to implement root motion animations. By parenting the character to a null object, we're ensuring that it's root bone has zero transforms and rotations applied.

Once you've create the null object, parent your character to it so that your character is a child of the root null object. If you've done it correctly, in the Scene explorer you should see your character has become a child of the root null object.

Scene hierarchy

The next thing I like to do at this point is to save the scene to my working folder as we're going to be coming back to it several times throughout the tutorial. I'm going to save the scene as base.duf.

Now we're going to export the base character as an FBX. These are the export settings I use. Make sure that the FBX Morph Export Rules are set to bake everything.

FBX export settings

Next we're going to decapitate the character. Or rather, we're going to hide all of the body parts except for the head.

The reason I do this is because I find it easier when preparing the mesh in 3d Max if I have the head separate, to use as a guide.

Hide each of the characters body parts including the eyes. Leave only the head and the internal mouth parts (teeth, tongue etc).

Characters head without the eyes

At this point I like to save this scene (with only the head) as a separate Daz file so that we can easily return to it later. I'm going to save the scene as head.duf.

Now we're going to export the head as an OBJ because we don't need bones or even textures for this one. These are the OBJ export settings I use:

OBJ export settings

We're going to leave Daz Studio for now, but we'll be coming back to it later.

Preparing the textures

If you go into your working directory you'll see that when we exported the base FBX, Daz Studio kindly gathered all of the diffuse textures used on our character into a folder.

Character textures

However it's likely that the character has other textures which will be useful for setting up the materials inside of Unreal Engine. So, go to your Daz Studio content folder and locate the source directory for your characters textures.

In the case of this character the source textures are located in \Content\Runtime\Textures\DAZ\Characters\Genesis3\Michael7

This character has normal maps, specular maps and subsurface weight maps for the head, torso, arms and legs. We're going to copy all of these into our working directory, where the existing diffuse textures are located.

You should now have all of the textures under your working directory. Something like this:

Character textures

Now that all of the characters textures in the working directory, I like to open them all in Photoshop and re-save them as TGA's into my UE\Textures directory as these will become the final textures we import into unreal Engine.

I also like to rename them along the lines of this naming convention.

When I get to the specular textures, I also like to invert them and re-save them as roughness textures. Simply inverting the specular map to create a roughness map probably isn't the perfect method but I've found that the results are quite good and you can also adjust them further in Photoshop.

Just remember that any changes to make to one of the body parts textures (head, torso, arms, legs) you also need to make to the others. Otherwise you'll get seams between them in Unreal Engine.

When all that is done, you should end up with something like this:

Character textures final

NOTE: as I mentioned in the introduction, I'm aiming for realism and not optimisation however, if you were looking to optimise this is one of the points that you could do so. For example, most of the textures for this character a 4k. You could reduce them to 2k (or even smaller) if you wanted to. You could also pack the textures into a texture atlas but this would require altering the UV's on the character either inside of Daz before exporting or inside of 3d Max. However, I'm not going to bother with that for the purposes of this tutorial.

Now it's time to jump into 3d Max.

Preparing the meshes for export to Unreal Engine

Importing the base mesh

The first thing to do once you've started 3d Max is to make sure your units are set up correctly.

Set the Display Unit Scale to Metric -> Centimeters and set the System Unit Scale to 1 Unit = 1 Centimeter

3d Max unit scale

Now we need to import our base.fbx mesh into 3d Max.

These are the settings I use for this step:

FBX import settings

Once it's finished you should see you character inside 3d Max, complete with the bones and skinning. I've hidden the bones in this screen shot to make the mesh easier to see.

Character inside max

The next thing I like to do is rename the mesh inside of 3d Max. I'm going to call it MichaelBase. We're going to end up with quite a few meshes inside this scene so it's a good idea to keep things organised.

I also like to un-link the mesh from the bone hierarchy.

As usual, the next thing I do is save the Max scene into my working directory, under the Max folder.

This character comes in at 16,828 polygons. Note that when you export an FBX from Daz Studio it will always be at the base mesh resolution. It's doesn't matter what you set the resolution to inside of Daz, the mesh will always be exported at it's base resolution.

16,828 polygons is quite low for a hero character these days. If you look closely at the ears you can see that there is hardly any geometry and they look quite square in certain places. Also, when the arms are bent down the silhouette around the shoulders isn't very smooth.

We want this character to hold up when the camera is very close to it, so we're going to subdivide it. However, we're also going to keep a copy of the character at this base resolution as this will become our LOD mesh.

We're going to be doing quite a bit to this character inside 3d Max and the order for some of the steps is very important, so pay attention.

Saving the skin data

As our character has been imported with all the skinning intact, we don't want to loose any of the skin data. So before we do anything else we're going to save the skin data so that we can reuse it later.

Under the Utility panel, click the More button and select SkinUtilies. Then, with the characters mesh selected, click on the Extract Skin Data To Mesh button, under the SkinUtilies.

This will create a clone of the character mesh which has all of the skinning vertex weights baked into it. We can hide this for later use.

Skin data extracted

Now that we have saved the skin data we can collapse the modifier stack of our character. We'll be adding the Skin modifier back again later.

Cleaning up the material

By default, this character has 17 materials (which is quite a few for a character) and, whilst we're not too concerned about optimisation in this tutorial, some of those materials aren't at all necessary so we might as well get rid of them. I'm going to reduce the material count to 12, which is still quite high but better then 17. There are many ways in which we could reduce the material count even further but they'll all outside the scope of this tutorial.

Note: What your final materials end up as depends a lot on your character and your requirements so it's really up to you how you set your materials up.

For example most Daz characters have separate materials for the face and the lips. Because I don't plan on this character wearing lipstick, I can safely combine the face and lips into a single material. Even if I did want my character to wear lipstick there are others ways this could be achieved with a single material inside of Unreal Engine, such as using masks etc.

This also provides us with the opportunity to apply proper naming conventions to the materials as well as pointing them to our new textures, which are now in TGA format.

So, open up the characters material in the Material Editor. Then make a new Multi/Sub-Object material. I'm going to give the new material 12 slots. This new material will be our final one. The original material is just for reference.

Then I'm going to create each of the standard sub-materials using the diffuse TGA textures we prepared earlier, until I end up with this:

Character material

A couple of things to note:

  1. The name of each of the sub-materials determines what those materials will be called inside Unreal Engine when we import them, so it's a good idea to give them meaning names which follow the naming conventions.
  2. The M_EyeMoisture material has no diffuse texture. It's just a transparent material.
  3. The material for the eyeballs is there, however we're going to need to change our texture later on.

Now, when I apply the new material to the character.. bad things happen:

Character material applied

This is because the material ids assigned to each of the polygons in the characters mesh don't correctly match up with the slot numbers in our new material. So we're going to fix that now.

The first thing I do here is go into the Element sub-object mode of the Editable Poly (the character mesh) and I detach the parts which make up the eyeballs. There's about 3-4 elements which make up the eyeballs. Make sure you don't attached the eyelashes...just the eyeballs.

Eyeballs detached

Once you've detached the eyeballs you can hide them for now. We're going to be modifying the eyeball geometry later on as the eyeball geometry that comes standard with Daz characters isn't well suited for real-time rendering inside game engines.

Now it's just matter of going into the Polygon sub-object mode of the Editable Poly (the character mesh) and selecting polygons by material ids and setting their new material id's to match our new material... this is where having the original source material can come in handy. Don't forget to do the inside of the mouth and the teeth!

When you've done that your character should be looking like it's old self again..albeit without any eyeballs.

Re-textured character

At this point it's probably a good idea to save your scene (save often) if you haven't already so that you don't have to repeat that process.

Subdividing the character

Now we're going to create a copy of our character. Make sure you create a copy and not an instance. I'm going to call this new copy MichaelHigh as it's going to be the hi-res subdivided version of our character.

Now apply a Turbosmooth modifier to this new character mesh so subdivide the model.

The hi-res version of our character now has around 130,000 polygons which is a lot but is still on par with some of the new AAA games such as Ryse. Sure our character is currently naked, but when we do add some clothes it isn't going to be additional geometry necessarily, because we'll be replacing the bodies geometry where it gets covered up by the clothes.

Having said that, this is one of those points where you could optimise the hi-res mesh if you wanted to. One way to do this would be to remove edge loops where the additional geometry wasn't required in order for the silhouette to hold up. For example, areas which don't bend much, if at all, such as the shins. However there are some rules you would need to keep in mind to ensure the skin data can be reapplied correctly and that's all outside the scope of this tutorial for now.

Speaking of the skin data, we need to repeat this process with our base skin data as well.

So, create a copy of the base skin data mesh (I called it SkinData_MichaelHigh) and apply a Turbosmooth modifier to it as well.

You can collapse the modifier stack for both the hi-res character mesh and the hi-res skin data mesh at this point by adding an Edit Poly modifier to each of them and collapsing the stacks.

At this point, if you've been following along, you should have a base and hi-res version of the character mesh AND a base and hi-res version of the skin data mesh.

Mesh versions

Note: There is one problem with Turbosmoothing the character mesh (there's more than one problem I'm sure but this is one I've spotted before) and that is that the teeth become a bit too rounded and the gaps between them a bit too large.

Rounded teeth

As you don't generally see a characters teeth very often I'm not going to bother fixing them in this tutorial, however if you wanted to fix them it would be fairly easy. You'd just need to adjust the geometry to have better edge loops in place before apply the Turbosmooth. Unlike most of the rest of the body, the teeth don't bend or distort in any way. So the problems you might run into with other parts of the body when re-applying the skin data, can be easily corrected for rigid parts of the body like teeth, once the skin modifier is re-applied. The top row of teeth will be 100% weighted to the top jaw bone and the bottom row of teeth will be 100% weighted to the lower jaw bone.

Separating the head

Now we're going to separate the head from the rest of the body on both our base and hi-res character meshes.

This next step is super important!!

If you don't do this then you will get ugly seams between the head and body.

What we need to do is set all of the vertex normals on our character mesh to be explicit and then we need to be careful that we don't do anything that will cause 3d Max to lose those explicit vertex normals.

To do this, select your base character mesh and then add an Edit Normals modifier. Then go into the Normal sub-object mode of the Edit Normals modifier and press CTRL + A on your keyboard to select all of the vertex normals.

With all of the normals selected, click on the Make Explicit button of the Edit Normals modifier. When you exit out of the sub-object mode you should see that all of the normals are now green, instead of blue.

Explicit normals

Now collapse the modifier stack.

Then repeat this same process on your hi-res mesh.

Now we want to separate the head along the same edge loop that separated it inside of Daz Studio. I can never remember exactly where that edge loop is, which is why we exported the head separately, as an OBJ, from Daz Studio.

So, now it's time to import that head OBJ. We're only going to use it as a guide and will delete it when we're finished with it.

Once you've imported the head guide you should see something like this:

Head guide

Here you can see the head guide on top of our base character mesh and we can now easily see where the edge loop we need to separate the head from is.

This next step is super important!!

You might be tempted to just select all of the polygons that make up the head portion of our base character and detach them. DONT!! If you do that you will break the explicit normals that we set up previously and will have visible seams between the head and the body.

In order to not break the explicit normals, we can really only delete polygons. This means that we're going to have to create 2 new copies of our base character mesh as we'll keep the original as a backup.

With one of the copies we're going to delete the polygons which make up the head, leaving only the body. With the other copy we're going to invert that, so that we're deleting the polygons which make up the body, leaving only the head.

If it all goes well, you should now have separate head and body meshes for your base character, with no visible shading seams between them.

Separated head and body

Now repeat the process with your hi-res character mesh.

The content of your scene should now be looking something like this:

Scene outline

Modelling and texturing the eyes


If you've been following along you'll remember that we detached the characters eyeballs at the start and haven't really done anything about them since.

I wanted to use the new eye shader in UE 4.11 however the docs for the new shader haven't been released yet. So everything in this section is really guesswork, coupled with a few bits of information that were provided in one of the Paragon videos.

The standard eyes for Daz characters are comprised of several separate elements such as the cornea, pupil, sclera.

Daz eyeballs

In the Paragon video it was mentioned that the new shader only requires a single piece of geometry for the entire eyeball and that the cornea (the transparent bump at the front of the eye) is modeled into the geometry. So that's what we're going to to.. roughly.

The way I do it is to delete one of the eyeballs entirely (we're only going to model and and then mirror it for the other), I then delete all geometry except for the outer most layer, leaving something like this:

Daz eyeball single geometry piece

Then I modify the eyeball geometry so that the cornea bulge is a bit more prominent. Something like this:

Eyeball with cornea bulge

Now, we also need to change our eye texture so that the eyeball and iris parts are combined into a single eye texture. I do this in Photoshop. Something like this:

New eye texture

Once our new eye texture is applied to our new eyeball, we'll need to adjust the UV's so that the they are centered in the 0,1 space until we end up with this:

New eye base

Then we simply mirror (as a copy) the eye to create the other one, and then attach them together. These will be the eyes for our base resolution character mesh:

Base eyes

Now we can create a copy of the eyes, apply a Turbosmooth modifier to it and collapse the stack. This will become the eyes for our hi-res character mesh.

Now we're just about ready to starting bringing everything into unreal engine, but before we do that we need to re-apply our skin data.

Re-applying the skin data

Adding the skin data back to the character meshes is easy. Let's start with our complete base character mesh.

Select the mesh and add a Skin modifier to it, then add all of the bones to the skin modifier.

Once you've done that, select both the base character mesh and the base characters SkinData mesh.

Under the Skin Utilities, click on the Import Skin Data From Mesh button. In the dialog box that appears, click on the Match By Name button and then click on the OK button to apply the skin data.

You have now applied the skin data back onto the base character mesh. Now do the same for the base characters separate body and head meshes.

Now repeat the process for the hi-res meshes only this time make sure you're apply the hi-res skin data, not the base skin data.

Once you're done you should now have all of the base and hi-res meshes skinned. Now we just need to do the eyes.

Skinning the eyes

Because we've modified the geometry of the eyes we're not going to be importing the skin data. Instead we're going to be doing a tiny bit of manual skinning.

Let's start with the base resolution eyes. Select them and add a Skin modifier to them, then add all the bones to the Skin modifier, same as before.

Now go into the Envelope sub-object of the Skin modifier and make sure Vertices is checked under the Select panel. Select all of the vertices of the right eyeball and then select the rEye bone in the list of bones in the Skin modifier.

With the vertices of the right eyeball and the rEye bone selected, type 1 into the Abs. Effect field under the Weight Properties panel of the Skin modifier.

The right eyeball should change to be shaded red. This is indicating that the vertices of the right eyeball are 100% weighted to the rEye bone, which is exactly what we want.

Eyeball skinning

Now repeat the process with the left eyeball vertices and the lEye bone.

Once you've finished this, repeat the same process for the hi-res version of the eyes.

Creating the LOD groups

I'm not going to go into much detail for this step because the process is well documented here.

Just create LOD groups for each of the base and hi-res parts of our character. That is, the complete character meshes, the body and head meshes and the eye meshes. You should end up with 4 LOD groups.

LOD groups

We've now finished preparing the character for export to Unreal Engine, so lets start exporting.

Exporting to Unreal Engine

Let's start with the complete character (we'll do the separate head and body parts next).

Unhide the LOD group for the complete character meshes and the eye meshes, also make sure the bones are visible.

Ready for export

Now select everything visible in the scene (CTRL + A) and then select Export -> Export Selected from the Max menu.

Obviously, we're going to be exporting as an FBX. These are the settings I use for this step:

Export settings

Note: The name of the FBX file you export to will be the name which appears in unreal engine so, as usual, use a good naming convention. For this file I called it SK_Michael and I placed it under the UE folder of my working directory for this character.

Now, hide your complete character LOD group and unhide the characters head LOD group, so that you have both the head and eye LOD groups visible, along with the bone.

Now export these using the same process and FBX export settings as before. I called this file SK_MichaelHead.

Now, hide both the head and eye LOD groups and unhide the body LOD group. Now export using the same process and FBX export settings. I called this file SK_MichaelBody.

If you've gotten this far...well done!!

We've now finished with Max for the time being and can begin to import our character into Unreal Engine.

Remember to save you Max scene as we'll be coming back to it later on, but for now, it's on to Unreal Engine.

Importing into Unreal Engine

I'm going to be using Unreal Engine 4.11 Preview 6 for this section.

Create a new project. I'm just going to use the blank template.

How you organise your content is up to you, but I like to create a folder called Characters and within that I create a folder for each of my characters.

Under each character folder I create a Textures and a Materials folder.. but again, you can organise it how you like.

Unreal folder structure

Now I'm going to import the complete character, into the Michael folder and these are the import settings I use:

FBX import settings

The reason I like to import the entire character, even though we're going to be using the separate head and body meshes soon, is so that I can use the whole character for animation previews. It also ensures Unreal creates all of the materials and the complete physics asset as well.

Imported assets

You can see that the character has been imported, all the materials have been created and all of the diffuse textures have been imported.

If you open up the skeletal mesh for the character you can see that it has the single LOD we created.

Skeletal mesh

You can adjust the screen size that the LOD kicks in. I set mine to 0.8. You can test the LOD by using the LOD Coloration view mode.

LOD coloration

Now we're going to import our head and body meshes but this time we're going to change the import settings:

FBX import settings

There are 2 important differences with these settings when compared to the previous import settings:

  1. We're telling Unreal to use the existing Skeleton that was created when we did the first import.
  2. We're telling Unreal to use the existing Physics Asset that was created when we did the first import.

Once that's done you should have your head and body meshes imported, each with a single LOD level. Whatever you set the LOD screen size to, make sure it's the same for both the head and the body so that they transition at the same time.

This next part is optional, but I like to move the textures into the Textures folder and the materials into the Materials folder. I'll leave everything else under the Michael folder.

Next we're going to import the rest of our textures. That is, the normal maps, roughness and sub surface maps.

Once you've imported the other textures, open the normal maps inside of Unreal and tick the Flip Green Channel option, and then save them. Note: I'm not 100% sure if this is correct for Daz Studio normal maps, but I think the normals look a bit better if I do this. It's up to you.

Now let's build a basic skin material.

Creating a basic skin material

Under the Materials folder, create a new Subsurface Profile. Leave it's settings as the default for now.

Now create a new Material that will be our master skin material for our character. I just called it M_MichaelSkin.

Open the material and change the Shading Model to Subsurface Profile and select the profile we created in the previous step.

Now drag the 4 face textures for your character into the material. That is, the base color texture, the normal texture, the roughness texture and the subsurface texture.

Convert the 4 texture samplers to parameters and give them meaningful names.

For a very basic skin material I just used the following setup:

Simple skin material

You can adjust the specular and the roughness multiplier to your liking, depending on how wet you want the skin to look.

You can make your skin material as complicated as you like. For example you could use material parameter collections to control the overall wetness, or dirtiness of the skin etc. I'm just going to leave it like this for now.

Now we're going to create 4 material instances based on our master skin material. One for the face, torso, arms and legs.

Under the torso, arms and legs instances, replace the textures with their corresponding textures.

Now open up your character meshes and replace the face, torso, arms and leg materials with the new Material Instances we just created.

Now I like to create a simple scene to test the skin under different lighting conditions.

I create an empty scene with a simple/black ground plane, a single directional light and a single skylight with an HDRI attached. All the lights are set to movable as I prefer to use dynamic lighting for this. I generally disable auto exposure when adjusting skin materials and I test the skin shading under different lighting conditions to see how it holds up.

Test scene