Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2019-05-24 15:31:07 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-05-24 15:32:28 +0300
commitee0fbc9e059a1594792b9d229bf5063ccd107fb6 (patch)
tree7a0fc4e76ba442e911832d98c995a8fe68fe41b6 /io_scene_fbx
parent2e41fe16c593346c9fa35028125aed5f1e3793d7 (diff)
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...
Diffstat (limited to 'io_scene_fbx')
-rw-r--r--io_scene_fbx/__init__.py2
-rw-r--r--io_scene_fbx/import_fbx.py8
2 files changed, 8 insertions, 2 deletions
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...