Monday, May 28, 2012

Tutorial: Unity - Alpha sorting Issue Fix

We recently switched to Unity 3D and since we are using a lot of rigged and animated 3D planes with alpha blend (since any cutout is extremly expensive on the iPhone). I stumbled upon a issue with this being that the planes got sorted really odd but I also found a fix for this. Some people have requested this tutorial on how to fix this and here it is, english isn't my main language so you will have to bare with me.

I'm using Autodesk Maya but this should translate into other 3D softwares as well since all of them have some function to the same thing as I will show you here. I will show you the problem first and then the solution afterwards.



THE PROBLEM

Here is one of our characters and as you can see he is split up into several parts that are mapped on planes. These planes are then placed behind each other in a very tight space (as you can see on down in the right corner). And if you check the Hypergraph Hierarchy all these parts are separated, but this is not wanted in a 3D engine since this will cost more than combining all parts into one mesh.

 
So before exporting I just combine all these meshes into one and export into Unity (I usually export as .mb) and below are the results. Not that great, the head is behind the body and the banjo is behind that with the strings on top. Not that ecstatically pleasing. So now I will show you the steps to fix this.

STEP 1.
So back to Autodesk Maya where we started, with the character in separate meshes. Make sure to delete all history so there isn't any old stuff in there.


STEP 2.
The next step is to triangulate all parts so we are sure the vertexes are ordered correctly. Delete history after you are done.



STEP 3.
Now the last and trickiest part. You will have to combine the parts two at a time from back to fourth. So for instance, I want the feet to be sorted behind everything else so I combine these two first. Then both feet will become one mesh that I will combine with the body. Then the body and feet will become one mesh that I combine with the Banjo.

My order I combined in with this character:
1. fot with fot
2. mesh from step 1 with body
3. mesh from step 2 with banjo
4. mesh from step 3 with banjo strings
5. mesh from step 4 with arm 1
6. mesh from step 5 with arm 2
7. mesh from step 6 with head
8. mesh from step 7 with hatfeather
9. DELETE HISTORY
10. Rename and export mesh



Then I export the mesh into Unity and here are the results! VOILA! No more alpha sort issues, the meshes work perfect if you rig them with bones and animate them as well as with lightmapped shaders etc.


Thursday, January 12, 2012

Holidays are over

So we are full at work again after the holidays. Into the Void is coming together quite nicely, we added a few powerups this week and I started working on the menues.

Our other project have gone through some iterations and is starting to look quite nice, a few more weeks and we might have something to show :)

Back to work..