Difference between revisions of "Documentation:Saving models for Unity and how to import them there"

From MakeHuman Community Wiki
Jump to: navigation, search
Line 13: Line 13:
 
Let's start with modeling a toon. We will here select some clothes/hair pieces with transparent areas so that we can see that we get those things right inside unity.  
 
Let's start with modeling a toon. We will here select some clothes/hair pieces with transparent areas so that we can see that we get those things right inside unity.  
  
[[File:01_export_mh_1.png|400px]]
+
[[File:01_export_mh_1.png|400px|link={{filepath:01_export_mh_1.png}}]]
  
 
An important step is selecting an appropriate rig. Unless you know what you are doing, you will most likely want to use the game rig one here (there are cases where the other ones may be appropriate).
 
An important step is selecting an appropriate rig. Unless you know what you are doing, you will most likely want to use the game rig one here (there are cases where the other ones may be appropriate).
  
[[File:02_export_mh_2.PNG|400px]]
+
[[File:02_export_mh_2.PNG|400px|link={{filepath:02_export_mh_2.PNG}}]]
  
 
You are now ready to export. You will want to use FBX, and the default settings are fine.  
 
You are now ready to export. You will want to use FBX, and the default settings are fine.  
  
[[File:03_export_mh_3.png|400px]]
+
[[File:03_export_mh_3.png|400px|link={{filepath:03_export_mh_3.png}}]]
  
 
However, before exporting, click the three-dots-button and browse to your Assets folder, so that the toon is exported there:
 
However, before exporting, click the three-dots-button and browse to your Assets folder, so that the toon is exported there:
  
[[File:04_export_mh_4.png|400px]]
+
[[File:04_export_mh_4.png|400px|link={{filepath:04_export_mh_4.png}}]]
  
 
You can now click export, and the toon will be exported to Unity.  
 
You can now click export, and the toon will be exported to Unity.  
Line 31: Line 31:
 
In Unity you will now see that the toon is available. By exporting directly to the Assets directory, you also got "materials" and "textures" autocreated. Otherwise you would have had to configure these manually.
 
In Unity you will now see that the toon is available. By exporting directly to the Assets directory, you also got "materials" and "textures" autocreated. Otherwise you would have had to configure these manually.
  
[[File:05_import_unity.png|400px]]
+
[[File:05_import_unity.png|400px|link={{filepath:05_import_unity.png}}]]
  
 
== Fixing materials ==
 
== Fixing materials ==
 +
 +
If we now drag the toon into the scene, and move around the camera a bit so we can see it in the game view, we can see that it looks a bit odd.
 +
 +
[[File:06_unity_transparency_fail.png|400px|link={{filepath:06_unity_transparency_fail.png}}]]
 +
 +
The reason for this is that Unity fails to take into account that textures may have an alpha channel (or maybe thinks that the user needs to know what he's doing before enabling such). We will thus need to fix
 +
the materials. For each material that has a transparent component, you will need to set the material type to "legacy shaders" -> "transparent" -> "diffuse". If the piece has a normalmap too, you will instead want
 +
"legacy shaders" -> "transparent" -> "bumped diffuse".
 +
 +
[[File:07_fix_material.png|400px|link={{filepath:07_fix_material.png}}]]
 +
 +
Do this for each material that should have a transparent component. In all likelihood you will want to do it for all materials except the skin (which would look odd if it was transparent).
 +
 +
Having done this, the toon should now look more pleasing.
 +
 +
[[File:08_transparency_fixed.png|400px|link={{filepath:08_transparency_fixed.png}}]]

Revision as of 09:40, 25 November 2016

Getting toons to work in Unity may seem a bit intimidating at first, but in practice it only requires relatively few mouse clicks.

Preparations

If you don't have a unity project already, create one. Things will be a lot easier for you if you export directly to the Assets directory, so before exporting from MH the Assets directory should exist.

For this documentation, let's create a new empty Unity project:

00 create unity project.png

Exporting from MakeHuman

Let's start with modeling a toon. We will here select some clothes/hair pieces with transparent areas so that we can see that we get those things right inside unity.

01 export mh 1.png

An important step is selecting an appropriate rig. Unless you know what you are doing, you will most likely want to use the game rig one here (there are cases where the other ones may be appropriate).

02 export mh 2.PNG

You are now ready to export. You will want to use FBX, and the default settings are fine.

03 export mh 3.png

However, before exporting, click the three-dots-button and browse to your Assets folder, so that the toon is exported there:

04 export mh 4.png

You can now click export, and the toon will be exported to Unity.

In Unity you will now see that the toon is available. By exporting directly to the Assets directory, you also got "materials" and "textures" autocreated. Otherwise you would have had to configure these manually.

05 import unity.png

Fixing materials

If we now drag the toon into the scene, and move around the camera a bit so we can see it in the game view, we can see that it looks a bit odd.

06 unity transparency fail.png

The reason for this is that Unity fails to take into account that textures may have an alpha channel (or maybe thinks that the user needs to know what he's doing before enabling such). We will thus need to fix the materials. For each material that has a transparent component, you will need to set the material type to "legacy shaders" -> "transparent" -> "diffuse". If the piece has a normalmap too, you will instead want "legacy shaders" -> "transparent" -> "bumped diffuse".

07 fix material.png

Do this for each material that should have a transparent component. In all likelihood you will want to do it for all materials except the skin (which would look odd if it was transparent).

Having done this, the toon should now look more pleasing.

08 transparency fixed.png