FBX Import: Fix pre-, post- and geometric rotations #104561
No reviewers
Labels
No Label
Interest
Animation & Rigging
Interest
Blender Cloud
Interest
Collada
Interest
Core
Interest
Documentation
Interest
Eevee & Viewport
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
Import and Export
Interest
Modeling
Interest
Modifiers
Interest
Nodes & Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds, Tests & Devices
Interest
Python API
Interest
Rendering & Cycles
Interest
Sculpt, Paint & Texture
Interest
Translations
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Meta
Good First Issue
Meta
Papercut
Module
Add-ons (BF-Blender)
Module
Add-ons (Community)
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#104561
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "Mysteryem/blender-addons:fbx_fix_pre_post_rotations_pr"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The pre-, post- and geometric rotations were using the rotation order of
the transform, but it's only the rotation that uses the rotation order
of the transform.
The post-rotation used in calculating the WorldTransform was being used
as-is, this seems to have been an error in the FBX 2011 documentation
because since FBX 2012, the documentation has specified that the inverse
of post-rotation is used and there is no mention of this change in the
FBX 2012 changes. Additionally, given files in FBX 2011 format, the
post-rotation works the same as in FBX 2012 and newer.
The pre-, post- and geometric rotations have been changed to always use
XYZ order.
The post-rotation is now inverted when calculating each WorldTransform.
Fixes the import of .fbx that have non-zero post-rotation.
Fixes the import of .fbx that have pre-/post-/geometric rotation and
have non-XYZ rotation order.
Cases where the "Use Pre/Post Rotation" option of the FBX Importer had
to be disabled to get a working import are likely to now work with the
option enabled.
Fixes #45176: Incorrect rotation of imported Cameras and Lights
The recent claim to having fixed #45176 in #104500 had me wondering what the actual problem with imported camera rotations was. Some other open-source FBX importers have had and fixed similar issues. It appears that there were two issues at play, I've tried to explain them here.
post-rotation inversion
Initially I figured out that post-rotation needed to be inverted by setting up an .fbx with post-rotation on a camera on all three axes (.fbx files in reported issues tend to have only a single non-zero axis) and importing it into Unity and then manually brute-forcing the rotation order and sign of components in Blender's FBX importer until Blender matched.
Later, I found that since FBX 2012, the documentation actually specifies that the inverse of the post-rotation is used. There was no mention of post-rotation changing in the FBX 2012 change notes and it just so happened that the ecp020_shotcam1_2011_v001.fbx attached in #45176 was a 2011 format FBX, so I could inspect its post-rotation and convert it to a newer FBX format using FBX Converter 2013. By observing that both the original 2011 version and the converted 2013 version had identical post-rotation, both displayed the same in the FBX Viewer in FBX Converter and both imported correctly into Blender when using the inverse of post-rotation, I deduced that the FBX 2011 documentation must have been incorrect as opposed to the FBX format having changed in this regard in FBX 2012.
ufbx inverts post-rotation:
70d5526256/ufbx.c (L19152)
assimp inverts post-rotation:
b1afa41047/code/AssetLib/FBX/FBXConverter.cpp (L820)
I also found a thread on the autodesk forums from 2010 where the user managed to figure out that post-rotation needed to be inverted, despite it not being in the documentation: https://forums.autodesk.com/t5/fbx-forum/maya-quot-rotate-axis-quot-vs-fbx-quot-postrotation-quot/td-p/4168814?profile.language=en
pre-/post-/geometric rotation order
The FBX documentation only actually specifies that the
R
rotation matrix takes into account the rotation order of the transform, it seems to have been a mistake to also apply the rotation order to the other rotation matrices.The example code under "Pivot Management" at https://download.autodesk.com/us/fbx/20112/FBX_SDK_HELP/SDKRef/a00209.html actually has a comment that states "// Rotation order don't affect post rotation, so just use the default
XYZ
order", so that at least makes it clear that post-rotation is not affected by rotation order.assimp had the same issue of not having pre-/post-rotation in
XYZ
order:9444935ce8
ufbx also uses
XYZ
order for pre-/post-rotation:70d5526256/ufbx.c (L19165)
Geometric rotation I couldn't tell whether to use 'XYZ' or the rotation order of the transform so figured it out myself by modifying the
Road_signs_v1.FBX
from #104558 so that the first sign Model had a geometric rotation of(-90, -20, 15)
and so that all the models in the file hadZXY
rotation order. By opening the modified .fbx in Unity and FBX Review, I could see that geometric rotation had to also always beXYZ
otherwise blender would import the rotation of the modified first sign Model incorrectly.Tested files now importing with expected rotation with this patch
The FBX Viewer in FBX Converter 2013 is very useful for showing the expected import where users have not provided screenshots in the issues though it tends to crash opening manually modified .fbx files and can't open some newer .fbx files since it's only designed to support up to FBX 2013. FBX Review is also useful for the same purpose and is much more recent and resilient to manually modified and broken .fbx files, but it's very basic and doesn't show cameras or lights as objects in the scene which makes it less useful since a lot of the reports are about camera rotations specifically.
I found that a lot of the imported .fbx import really tiny with default settings, so you may need to zoom in or scale up imported Objects to see them better in Blender.
Shift X
andShift Y
of the camera in the import, so to get parity with other software, both shift values may need to be set to zero.Use Pre/Post rotations
was disabled in the importer (this is a common step to find in older tutorials for importing from DAZ Studio to Blender). With this patch, disablingUse Pre/Post rotations
appears to now be unnecessary, though I was unable to find an older animated DAZ3D FBX to determine if animations would also work. Newer versions of DAZ Studio appear to not use pre- and post-rotations in their FBX exports anymore, so theUse Pre/Post rotations
option of the importer is irrelevant for newer DAZ3D produced .fbx files.(-90, -20, 15)
and so that all the objects haveZXY
rotation order.465bda6e98
tof858f9528e
I updated the "Computing transformation matrices" link to the current FBX SDK documentation and removed the links to older versions of the documentation.
The link for reference: https://help.autodesk.com/view/FBX/2020/ENU/?guid=FBX_Developer_Help_nodes_and_scene_graph_fbx_nodes_computing_transformation_matrix_html
Uuuuh nice finding, thanks a lot! And great explanations once again. :D