[Bf-extensions-cvs] [ee0fbc9e] master: Fix T65065: FBX import principled alpha 0.

Bastien Montagne noreply at git.blender.org
Fri May 24 14:32:32 CEST 2019


Commit: ee0fbc9e059a1594792b9d229bf5063ccd107fb6
Author: Bastien Montagne
Date:   Fri May 24 14:31:07 2019 +0200
Branches: master
https://developer.blender.org/rBAee0fbc9e059a1594792b9d229bf5063ccd107fb6

Fix T65065: FBX import principled alpha 0.

3DSMax can produce pure white `TransparentColor` with (default, from
template) `TransparencyFactor` of 0.0... Looks like we are supposed to
use `Opacity` then... sigh...

===================================================================

M	io_scene_fbx/__init__.py
M	io_scene_fbx/import_fbx.py

===================================================================

diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index f7f9c4e3..7f22d141 100644
--- a/io_scene_fbx/__init__.py
+++ b/io_scene_fbx/__init__.py
@@ -21,7 +21,7 @@
 bl_info = {
     "name": "FBX format",
     "author": "Campbell Barton, Bastien Montagne, Jens Restemeier",
-    "version": (4, 14, 9),
+    "version": (4, 14, 10),
     "blender": (2, 80, 0),
     "location": "File > Import-Export",
     "description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions",
diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py
index c24c2ae3..624ea2f7 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -1336,6 +1336,7 @@ def blen_read_material(fbx_tmpl, fbx_obj, settings):
 
     fbx_props = (elem_find_first(fbx_obj, b'Properties70'),
                  elem_find_first(fbx_tmpl, b'Properties70', fbx_elem_nil))
+    fbx_props_no_template = (fbx_props[0], fbx_elem_nil)
 
     ma_wrap = node_shader_utils.PrincipledBSDFWrapper(ma, is_readonly=False, use_nodes=True)
     ma_wrap.base_color = elem_props_get_color_rgb(fbx_props, b'DiffuseColor', const_color_white)
@@ -1354,9 +1355,14 @@ def blen_read_material(fbx_tmpl, fbx_obj, settings):
     #       alpha = 1 - TransparentColor.r
     #
     # Until further info, let's assume this is correct way to do, hence the following code for TransparentColor.
+    # However, there are some cases (from 3DSMax, see T65065), where we do have TransparencyFactor only defined
+    # in the template to 0.0, and then materials defining TransparentColor to pure white (1.0, 1.0, 1.0),
+    # and setting alpha value in Opacity... try to cope with that too. :((((
     alpha = 1.0 - elem_props_get_number(fbx_props, b'TransparencyFactor', 0.0)
     if (alpha == 1.0 or alpha == 0.0):
-        alpha = 1.0 - elem_props_get_color_rgb(fbx_props, b'TransparentColor', const_color_black)[0]
+        alpha = elem_props_get_number(fbx_props_no_template, b'Opacity', None)
+        if alpha is None:
+            alpha = 1.0 - elem_props_get_color_rgb(fbx_props, b'TransparentColor', const_color_black)[0]
     ma_wrap.alpha = alpha
     ma_wrap.metallic = elem_props_get_number(fbx_props, b'ReflectionFactor', 0.0)
     # We have no metallic (a.k.a. reflection) color...



More information about the Bf-extensions-cvs mailing list