Blender -> Unity TressFX Import


I recently added a new importer to the TressFX project. This new importer can get used to import blender hair particles into TressFX Unity.
In this article i will explain how to create the hair particles in blender and import them into unity.

First, open up your blender (I’m using version 2.76).
Add a new particle system to any object in the scene (I’m using the cube that’s always added on a new scene).
Your scene should now look like this:


I will leave the hair now just as it is, since i’m not very familar with blender and it’s all we need in order to demonstrate the import workflow 😛

The next step is converting the hairs into an actual mesh we can export, in order to do so we need to add a modifier, which can be done at the modifier tab:


Press the “Convert” button to convert your particle system into a mesh. Now your scene should contain a new object:


Now, remove all unnecessary things from your scene (the light, camera and the cube) and export the hair mesh as Wavefront OBJ file:


Now, we are almost done.
In order to import this hair into unity now we need to customize the TressFX import settings a bit. To do so, open up the TressFX Window (Window > TressFX).
First, you need to tick normalize vertex count in order to normalize the hair strands to 16 vertices per strand (this is only needed in order to use simulation).
The follow hair max radius around guidance hairs is ways too high for this kind of hair aswell. It controls the radius around the hairs you import where additional hairs are added to make the hair more dense. I used 0.025 here:


Now right click in the project explorer, select “Create > TressFX > Hair from OBJ” and let unity import the obj file.
After that you are done importing the hair mesh into unity. Yay 🙂

Now, creating an example scene is pretty straightforward.
Create a new gameobject and add the TressFXRender and TressFXSimulation script to the gameobject.
Assign the “Shadow Shader” and “Hair Material” to the TressFXRender (The shader is located in Assets/TressFX/Shaders/TressFXShadow.shader, the material must use the shader “TressFX/Surface”).
Now, assign the “Simulation Shader” of the TressFXSimulation component and the “Hair Data” of the TressFX Behaviour.
Finally it should look like this:


The last step now is setting up the simulation parameters for the hair, click the hair asset and configure them as you like.
Here is my example config:


Press “Save”, and you’re done 🙂
If you hit the start button, it should get rendered like this now:


That’s it 🙂

Have a nice day!

13 thoughts on “Blender -> Unity TressFX Import

  1. Hi KennuX,

    I am really grateful for the work you have done, and after running the test scene, it really looks promising as well. I guess this should work for the project I am working on.
    I just have one problem during the import of the asset, I tried following the steps you have explained in the post, but when I try import the Obj to Unity and and try create the asset file for hair, I get the exception. I do not know what to do also the asset file that is created is empy with no data on it.

    The exceptions are as follows:
    ArgumentException: C:/Users/Hemal/Desktop/Unity Content/AMD/TressFXUnity-master/Assets/ is a directory
    System.IO.File.Copy (System.String sourceFileName, System.String destFileName, Boolean overwrite) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/File.cs:109)
    System.IO.File.Copy (System.String sourceFileName, System.String destFileName) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/File.cs:86)
    TressFXLib.Hair.PrepareSimulationParamatersAssetConverter (Int32 followHairs, Single maxRadiusAround, System.String assetConverterExePath) (at Assets/TressFX/TressFXLib/Hair.cs:463)
    TressFX.TressFXHairEditorExt.CreateAssetOBJ () (at Assets/TressFX/EditorExtension/Editor/TressFXHairEditorExt.cs:212)

    And get the Null Reference Exception
    NullReferenceException: Object reference not set to an instance of an object
    TressFX.TressFXHairEditor.OnInspectorGUI () (at Assets/TressFX/EditorExtension/Editor/TressFXHairEditor.cs:27)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1231)

    • Hey, this looks like a problem with the asset conversion.
      Please make sure nothing blocks the execution of the “Assetconverter.exe” and the path in the editor preferences is set correctly.

  2. Hey KennuX,

    Thanks for the answer, I guess I kept the assetconverter and obj in different folder, I guess that’s why it was not working.

    One more question, have you used maya for creating a tfx, and if yes did you created a custom exporter for that?

  3. Hi Kennux I have a problem while importing the asset the log :
    NullreferenceException: Object reference not set to an instance of an object
    TressFX.TressFXHairEditor.OnInspectorGUI() (at Assets/TressFXEditorExtension/Editor/TressFXHairEditor.cs:27)

    NullReferenceException: Object
    System.Diagnostics.Process.Start_common(System.Diagnostics.ProcessStartInfo startInfo,System.Diagnostics.Process process)

    I have tried to set the asset converter in TressFX/assetconverter.exe and placed the obj onside TressFX folder but I get those logs and import failed. any help thanks 🙂

  4. Hair is pretty big, many Unity Units in size. My project’s are always in a scale of 1 Unity Unity == 1 Meter.

    • TressFX uses 1 meter = 100 units. But there is a way to work around this.
      Import your hair in normal scale 1.0 and then scale down the renderer. The reason why TressFX uses this very big size is the floating point precision with 32bit floats.

      If the hair stretches maybe your simulation parameters on the hair asset arent configured correctly?
      Try to copy the parameters of the example hair and see if that solves the problem.

  5. When character is running with TressFX hair, the hair scretches behind. Enabling Collision makes hair stand up around one place, there are no colliders there and there colliders are not set.

  6. Oh, wait, it seems that it’s blender fault. Well, I can’t really tell. But it’s failing somewhere becouse it reimported the correct stuff to blender once.

  7. Hey, I trying to use your open with Unity5.5b1
    Got this shader error

    Shader error in ‘TressFX/HairShadowShader’: invalid subscript ‘ndotl’ at Assets/TressFX/Shaders/TressFX.cginc(52) (on d3d11)

    Compiling Vertex program with SHADOWS_DEPTH

    Is it out of date or something. The hair seem translucence with this error.

Leave a Comment