Wednesday, 24 February 2016

Fixing Daz Character Eyes in Unity

So one of the things you may have noticed when you imported your Daz character into Unity is that the eyes do not retain their colour. There's also the matter of the eyelashes, but let's address that in another post.

Anyway, back to the point: what's up with the eyes!

Well the problem is with the way they're exported from Daz as well as how they're imported into Unity. The texture for the eyes contains the texture for everything related to both eyes in the one file, and this is the first part of the problem.
The second part is when the model is actually in Unity. Part of the import process creates a "Materials" folder and uses the textures in the .fbm folder to create the materials.

Let's take a look inside the "Materials" folder:

If you click on the image above you'll see that there are 3 Materials associated with the eyes:


The Cornea material is what's causing us the issue because it is completely blank. What the cornea material is representing is the pupil and the iris, so this part:

Okay, so let's back up a second. I said that there were 3 materials, but don't we just need the cornea? Unfortunately not. The eye is actually split into 2 components:

1. The Sclera (more commonly known as the whites of the eye)
2. The cornea (comprising of the pupil and the iris)

The 2 RyBelle_eyes0x files are just two different eye colours, blue and the green for my character. But they are making up the Sclera portion of the eye even though the base texture contains all portions of the eye (including the tear ducts, etc.). So how do we fix this? Well, it's quite easy really. Let's start with the Sclera.

Go into the .fbm folder for your model and open up the eye texture you want (blue or green) with your favourite image editing software (I'm using PhotoShop as part of a Creative Cloud subscription). Select one of the Sclera and crop the image so it looks something like this:

Now clean it up so we only have the part we want:

Okay, so now that looks like something we want. Save the file with a different name (so that you keep the original just in case) and it should save into the textures folder.

Now go back into Unity and check inside the textures folder (the one ending .fbm) and make sure the Sclera is there:

Now the file is there it should have imported as a texture, but let's check. Click on the new image (I called min Sclera) and look in the Inspector and the Texture Type should be Texture. If not, click in the drop-down list and select Texture and click Done.

Now let's go into the Materials folder. The easiest way to tell which RyBelle_ material is being applied is to click on one and then go over to the inspector and change the color next to Albedo in the Main Maps section:

I changed the colour to Red to make it obvious. If I've changed the colour on the correct material, then I'll see this:

Now I know that I have the correct material selected I revert the colour change (Ctrl + Z or just use the colour picker to select white again) and click on the circle next to Albedo in the Inspector:

and select your Sclera texture by double-clicking it.

You may notice a slight colour change in the eyes now.

Okay, now let's finish. Go back to the original texture that contained all the parts of the eyes and select the cornea (pupil & iris), just like we did earlier for the Sclera, so you end up with the following:

Save it as a new file and make sure it shows as a texture in Unity once you're done (again, just as we did earlier).

Now go into the Material folder and select the Cornea material and select your new cornea texture. Now it looks like we're getting somewhere:

But where are the pupils? Well, that's because of the wrapping of the texture in the material, so it's a really easy fix. Select the Cornea material again, then change the Tiling X & Y values in the Main Maps section and change them from 1 to 10. 

I also adjusted the "Smoothness" and "Metallic" sliders to get a better effect and now the eyes look like this:

They actually look like eyes now! You can also play around with the "Eyes Reflection" material if you're not 100% happy, but this is the end result:

I guess all that's left is to address those pesky eyelashes, but I'll tackle that at another time and another blog post.

No comments:

Post a Comment