[fbx] when enable use tangent space ,it's throw bug. #55022

Closed
opened 2018-05-10 11:10:19 +02:00 by zhanhaiyang · 6 comments

System Information
Operating system and graphics card

Blender Version

blender 2.79 or blender 2.8 both version try.

bug1.png

123.zip
blender file is here
bug2.png
Worked: (optional)

Short description of error
my fbx is use normal object space,and I want to export use tangent space .

**System Information** Operating system and graphics card **Blender Version** blender 2.79 or blender 2.8 both version try. ![bug1.png](https://archive.blender.org/developer/F3325832/bug1.png) [123.zip](https://archive.blender.org/developer/F3325852/123.zip) blender file is here ![bug2.png](https://archive.blender.org/developer/F3325834/bug2.png) Worked: (optional) **Short description of error** my fbx is use normal object space,and I want to export use tangent space .
Author

Added subscriber: @layola2

Added subscriber: @layola2

#55023 was marked as duplicate of this issue

#55023 was marked as duplicate of this issue
Member

Added subscribers: @mont29, @lichtwerk

Added subscribers: @mont29, @lichtwerk
Bastien Montagne was assigned by Philipp Oeser 2018-05-11 11:43:17 +02:00
Member

Can confirm this.

The FBX exporter creates temporary meshes, if materials are linked to objects (not objects data).
If on these temporary meshes the UVLayers are enumerated in python AND while doing this we call mesh.calc_tangents(), then sometimes data gets corrupted.

Not sure yet why this actually happens, but this can be reproduced by selecting the roof in your file [object called tianhua1$_3668e569-c100-43a4-856c-1dc9f4623f6d] and run following python snippet:

import bpy

C = bpy.context
scene = C.scene
ob = C.active_object

tmp_mesh = ob.to_mesh(scene, apply_modifiers=True, settings='RENDER')

use_enumerate = True # will error out after

if use_enumerate:
    for idx, uvlayer in enumerate(tmp_mesh.uv_layers):
        print(uvlayer.name)
        tmp_mesh.calc_tangents(uvlayer.name)
else:
    for i in range(len(tmp_mesh.uv_layers)):
        print(tmp_mesh.uv_layers[i].name)
        tmp_mesh.calc_tangents(tmp_mesh.uv_layers[i].name)

This objects has two UV layers [UVSet1 and lightmap] and those names are valid until we get to the enumaration here .

If we dont use enumaration, things seem to work fine, see D3341.

But since this is kinda weird in my eyes, and I cannot reproduce this on own files, it might as well be related to something that needs changes in underlying code... not sure...
@mont29 : I'm afraid you need to have a look here...

Can confirm this. The FBX exporter creates temporary meshes, if materials are linked to objects (not objects data). If on these temporary meshes the UVLayers are enumerated in python AND while doing this we call mesh.calc_tangents(), then sometimes data gets corrupted. Not sure yet why this actually happens, but this can be reproduced by selecting the roof in your file [object called `tianhua1$_3668e569-c100-43a4-856c-1dc9f4623f6d`] and run following python snippet: ``` import bpy C = bpy.context scene = C.scene ob = C.active_object tmp_mesh = ob.to_mesh(scene, apply_modifiers=True, settings='RENDER') use_enumerate = True # will error out after if use_enumerate: for idx, uvlayer in enumerate(tmp_mesh.uv_layers): print(uvlayer.name) tmp_mesh.calc_tangents(uvlayer.name) else: for i in range(len(tmp_mesh.uv_layers)): print(tmp_mesh.uv_layers[i].name) tmp_mesh.calc_tangents(tmp_mesh.uv_layers[i].name) ``` This objects has two UV layers [`UVSet1` and `lightmap`] and those names are valid until we get to the enumaration [here ](https://developer.blender.org/diffusion/BA/browse/master/io_scene_fbx/export_fbx_bin.py;4b91309b122bcdcddd1854b1137407b2c4f55c7e$1026). If we dont use enumaration, things seem to work fine, see [D3341](https://archive.blender.org/developer/D3341). But since this is kinda weird in my eyes, and I cannot reproduce this on own files, it might as well be related to something that needs changes in underlying code... not sure... @mont29 : I'm afraid you need to have a look here...

This issue was referenced by blender/blender-addons@bea6ca0c4e

This issue was referenced by blender/blender-addons@bea6ca0c4ef8b838ab6d2bc63136b52eb3ffc63c

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
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
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#55022
No description provided.