Unity 3D: OBJ-Export and Cinema 4D troubles
And yet again I had to spend a whole day to work out a bug in my Unity3D-to-Cinema4D-Pipeline. Well, after all, I am constantly jumping a whole dimension here (yeah, I did a bad play on product names).
The situation: I use the OBJ Exporter found on the Unity Wiki (ObjExporter) to export each of my levels to OBJ. I then import those OBJ-files in Cinema and bake the shadows for it. The shadowmaps are then used for basic lighting of the levels. Well, this is pretty straightforward up to here.
After doing some asset optimizations last week, the exported OBJ file I wanted to use today for shadow baking was not displayed correctly any more in Cinema. Viewing the OBJ file in a text editor, however, I could not find anything wrong with it. In the past I had to deal with some formatting issues within the OBJ-Export-Script (decimals need to be seperated by ‘.’ and not ‘,’) so I suspected the problem to be that sort of thing again and usually a quick look at the ASCII source of the file made the problem obvious.
After playing around with number formatting for a while, I found out, that Unity creates an empty zero-length array of normals for a mesh if the import settings are set to not import normals and tangents. When exporting a mesh without normals the OBJ-Export-Script does not write any normals for the mesh - which is what causes the problem.
Solution: Basically you need to give the mesh an array of normals before you export it. A simple array of zero-vectors will do.




