"Bake Axis Conversion" defaults to models looking backwards

Hi, before anything I want to say that we have been experimenting with the new “Bake Axis Conversion” feature and it looks pretty convenient so far.

That being said we noticed that - apart from fixing the model rotation - this option is adding an extra 180 degrees on the y axis on our meshes and rigs.

Here is what I mean:

Without “Bake Axis Conversion” checked the mesh is imported 90 off on the X axis and this is compensated by adding a -90 degrees rotation on the game object transform. Nothing new here.

With “Bake Axis Conversion” is checked the mesh is imported in the correct direction but the prefab is generated with an extra 180 degrees on the Y axis which is causing the model to be added to the scene looking backwards.

This is not so bad for static mesh models imported with simplified hierarchy because this extra rotation is only added to the root prefab game object. But this extra rotation is also added to the root of rig hierarchies as well so for animated objects the extra rotation happens on any children transform that contains meshes and rig armatures, like so:

Fortunately, we can work around this by zeroing both Y rotations on our model instances and prefabs.

I’m not sure if this is the intended behavior but it sounds more like a bug than a design decision given it will be source for a lot of confusion. Anyway if this is by design please let us know so I can automate the rotation zeroing on our part.

One last thing, the fbx files shown here were exported on blender 2.83 with ‘-Y Forward’ and ‘Z Up’ axis. I’m including all .fbx and .blend with the thread.

5969417–640508–suzane.7z (182 KB)

Hello, is this the intended behavior for the Bake Axis Conversion feature?

Hi Garrafote, I noticed the same behaviour and it seems to come from the fact that Unity uses a left-handed coordinate system, but Blender uses a right-handed one. It may also be possible that Blender does not correctly specify the coordinate system inside the fbx file. I would need to consult the fbx spec and the exporter code to verify this.

So after looking at the fbx exporter in Blender, I did come to the conclusion that Unity does everything correctly and this is a misunderstanding about the coordinate system in Blender.

The coordinate system in Blender is defined as right-handed with +Y forward and +Z up. This information is correctly written to the fbx file and Unity also handles the import correctly. The problem comes from the fact that Blender defines looking from the -Y axis as the “front view”. Suzanne is also oriented to look in the -Y direction and every Blender file I know of is always built with the assumption that a model is looking forward in the -Y direction. But during export it is assumed that the +Y direction corresponds to forward (the way the coordinate system is defined). Blender applies the 180° rotation from +Y to -Y to all root objects, therefore you get a 180° rotation when exporting with -Y Forward and Z Up.

I think the correct approach to this would be a patch to Blenders fbx exporter to not apply the rotation to, but only write the axis settings to the fbx file. But I imagine this will be difficult to actually get accepted because it breaks existing asset pipelines.

I have attached a fbx file that I exported with a hacked exporter that correctly assumes the forward direction to be -Y. It imports in Unity the way you might expect.

6000380–645995–suzanne.zip (43.2 KB)

I will see if I can submit a patch to Blender by next week.

1 Like

Thanks a lot!

Actually, my workflow includes exporting all my fbx from a custom unity extension that calls a blender background process so I believe that I could include a similar hack on my export script.

Can you show me the changes you made in the exporter?

Edit:

That would be great! Perhaps having it as an option so it doesn’t break existing asset pipelines will make it more likely to be accepted.

Sorry for the late reply, I submitted a patch but forgot to update the post here. You can see the changes here. Blender Archive - developer.blender.org

The only required change is so set the global matrix in the exporter to the identity matrix.

3 Likes

Just as a quick comment, to mention what works for us… (based on @mordecai154 's answer) and as a reference:

Modern Blender export plug-ins have @mordecai154 's patch) so that’s just about getting a late’ish one.

Create object in Blender
Export with this (so coordinates being Blender’s, “Use Space Transform” unticked)
9092218--1259479--upload_2023-6-20_14-45-27.png

And then on Unity’s .fbx import properties
9092218--1259482--upload_2023-6-20_14-47-17.png
(and of course, “apply”)

Then dragging into unity will give you an object with no unwanted rotations (you can still rotate the object and that will be preserved, but it won’t be due to a space-coordinate conversion thing)

(Kudos to the always awesome @ for digging into Python and figuring the settings to get the export right!)

Hope it helps somebody!

2 Likes