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-10-10 18:19:20 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-10-10 18:19:20 +0300
commitc4f78f14931be95e7f3bb31169579206369cc569 (patch)
tree11c4cf74c3203be0a2858be95d15187a4252cc3b
parent3a0cc9946f6ce63213fec53876b4fbaed76d8311 (diff)
Fix T70666: FBX IO: Add support for new emission option of Principled BSDF.
-rw-r--r--io_scene_fbx/__init__.py2
-rw-r--r--io_scene_fbx/export_fbx_bin.py8
-rw-r--r--io_scene_fbx/import_fbx.py7
3 files changed, 12 insertions, 5 deletions
diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index 9257056c..bb0f8ae1 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, 19, 0),
+ "version": (4, 20, 0),
"blender": (2, 81, 6),
"location": "File > Import-Export",
"description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions",
diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py
index d1ba96bb..970fc721 100644
--- a/io_scene_fbx/export_fbx_bin.py
+++ b/io_scene_fbx/export_fbx_bin.py
@@ -1307,9 +1307,9 @@ def fbx_data_material_elements(root, ma, scene_data):
elem_props_template_set(tmpl, props, "p_color", b"DiffuseColor", ma_wrap.base_color)
# Not in Principled BSDF, so assuming always 1
elem_props_template_set(tmpl, props, "p_number", b"DiffuseFactor", 1.0)
- # Not in Principled BSDF, so assuming always 0
- elem_props_template_set(tmpl, props, "p_color", b"EmissiveColor", ma_wrap.base_color)
- elem_props_template_set(tmpl, props, "p_number", b"EmissiveFactor", 0.0)
+ # Principled BSDF only has an emissive color, so we assume factor to be always 1.0.
+ elem_props_template_set(tmpl, props, "p_color", b"EmissiveColor", ma_wrap.emission_color)
+ elem_props_template_set(tmpl, props, "p_number", b"EmissiveFactor", 1.0)
# Not in Principled BSDF, so assuming always 0
elem_props_template_set(tmpl, props, "p_color", b"AmbientColor", ambient_color)
elem_props_template_set(tmpl, props, "p_number", b"AmbientFactor", 0.0)
@@ -1809,7 +1809,7 @@ PRINCIPLED_TEXTURE_SOCKETS_TO_FBX = (
("alpha_texture", b"TransparencyFactor"), # Will be inverted in fact, not much we can do really...
# ("base_color_texture", b"TransparentColor"), # Uses diffuse color in Blender!
# ("emit", "emit", b"EmissiveFactor"),
- # ("diffuse", "diffuse", b"EmissiveColor"), # Uses diffuse color in Blender!
+ ("emission_color_texture", b"EmissiveColor"),
# ("ambient", "ambient", b"AmbientFactor"),
# ("", "", b"AmbientColor"), # World stuff in Blender, for now ignore...
("normalmap_texture", b"NormalMap"),
diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py
index 9b8fbad1..93b01b9f 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -1427,6 +1427,10 @@ def blen_read_material(fbx_tmpl, fbx_obj, settings):
# elem_props_get_color_rgb(fbx_props, b'ReflectionColor', const_color_white)
# (x / 7.142) is only a guess, cycles usable range is (0.0 -> 0.5)
ma_wrap.normalmap_strength = elem_props_get_number(fbx_props, b'BumpFactor', 2.5) / 7.142
+ # For emission color we can take into account the factor, but only for default values, not in case of texture.
+ emission_factor = elem_props_get_number(fbx_props, b'EmissiveFactor', 1.0)
+ ma_wrap.emission_color = [c * emission_factor
+ for c in elem_props_get_color_rgb(fbx_props, b'EmissiveColor', const_color_black)]
nodal_material_wrap_map[ma] = ma_wrap
@@ -3111,6 +3115,9 @@ def load(operator, context, filepath="",
elif lnk_type == b'Bump':
# TODO displacement...
"""
+ elif lnk_type in {b'EmissiveColor'}:
+ ma_wrap.emission_color_texture.image = image
+ texture_mapping_set(fbx_lnk, ma_wrap.emission_color_texture)
else:
print("WARNING: material link %r ignored" % lnk_type)