Speed up FBX export of normals/tangents/bitangents with numpy #104449
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#104449
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "Mysteryem/blender-addons:fbx_numpy_normals_tangents_bitangents_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?
Use buffers matching the C types of the data in foreach_get to avoid having to iterate and cast every single element in the C foreach_getset function.
Replace nors_transformed_gen mesh transform helper with numpy version nors_transformed.
This patch can slightly change the exported normals/tangent/bitangents when geom_mat_no is set by skipping a cast from double to single precision before casting as float64 (usually double precision):
The original code would multiply mathutils.Matrix (single precision) and mathutils.Vector (single precision) together, which casts the Matrix elements to double precision, performs the multiplication, and then casts the result back to single precision. These single precision multiplied vectors would then be cast to float64 to be exported.
The new code performs the same cast of the matrix to double precision, but skips the step of casting back to single precision, instead casting directly to float64.
Even if the new code were to cast back to single precision float and then to float64 like the original code, there does tend to be a small difference in the result, presumably due to precision error.
In most cases, however, it seems that there is no change because geom_mat_no is usually an identity matrix, so both the original and new code end up at the same result.
For subdivided default cubes with 1538 to 1572864 vertices:
~5-8 times faster (geom_mat_no is None and tangents are exported)
~8-11 times faster (geom_mat_no is set and tangents are exported)
~13-16 times faster (geom_mat_no is None and no tangents are exported)
~18-21 times faster (geom_mat_no is set and no tangents are exported)
mathutils column vector multiplication for reference, note the use of double precision math:
This patch depends on
#104447
I wasn't sure if I should include its commit in this PR, I have included it for now.
fa121d0bd1
to202540d3d7
202540d3d7
tob1fa311570