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:
authorBrecht Van Lommel <brecht@blender.org>2020-09-17 16:26:52 +0300
committerBrecht Van Lommel <brecht@blender.org>2020-09-17 19:55:15 +0300
commitec4ad081e564781230e3a9b31ef48f1f8fb71899 (patch)
tree5468926df074e0475c8530db97e60be47825ae54 /io_scene_obj
parent051770b36de923a34a023ccd598dd315d2428f3a (diff)
Shaders: update OBJ and FBX for for Principled BSDF emission strength
Diffstat (limited to 'io_scene_obj')
-rw-r--r--io_scene_obj/export_obj.py6
-rw-r--r--io_scene_obj/import_obj.py2
2 files changed, 6 insertions, 2 deletions
diff --git a/io_scene_obj/export_obj.py b/io_scene_obj/export_obj.py
index dbd966a8..50cec836 100644
--- a/io_scene_obj/export_obj.py
+++ b/io_scene_obj/export_obj.py
@@ -88,7 +88,9 @@ def write_mtl(scene, filepath, path_mode, copy_set, mtl_dict):
# XXX TODO Find a way to handle tint and diffuse color, in a consistent way with import...
fw('Ks %.6f %.6f %.6f\n' % (mat_wrap.specular, mat_wrap.specular, mat_wrap.specular)) # Specular
# Emission, not in original MTL standard but seems pretty common, see T45766.
- fw('Ke %.6f %.6f %.6f\n' % mat_wrap.emission_color[:3])
+ emission_strength = mat_wrap.emission_strength
+ emission = [emission_strength * c for c in mat_wrap.emission_color[:3]]
+ fw('Ke %.6f %.6f %.6f\n' % tuple(emission))
fw('Ni %.6f\n' % mat_wrap.ior) # Refraction index
fw('d %.6f\n' % mat_wrap.alpha) # Alpha (obj uses 'd' for dissolve)
@@ -117,7 +119,7 @@ def write_mtl(scene, filepath, path_mode, copy_set, mtl_dict):
"map_Bump": "normalmap_texture",
"disp": None, # displacement...
"refl": "metallic_texture",
- "map_Ke": "emission_color_texture",
+ "map_Ke": "emission_color_texture" if emission_strength != 0.0 else None,
}
for key, mat_wrap_key in sorted(image_map.items()):
diff --git a/io_scene_obj/import_obj.py b/io_scene_obj/import_obj.py
index db4efb9a..85db6aec 100644
--- a/io_scene_obj/import_obj.py
+++ b/io_scene_obj/import_obj.py
@@ -195,6 +195,7 @@ def create_materials(filepath, relpath,
elif type == 'Ke':
_generic_tex_set(mat_wrap.emission_color_texture, image, 'UV', map_offset, map_scale)
+ mat_wrap.emission_strength = 1.0
elif type == 'Bump':
bump_mult = map_options.get(b'-bm')
@@ -357,6 +358,7 @@ def create_materials(filepath, relpath,
# We cannot set context_material.emit right now, we need final diffuse color as well for this.
# XXX Unsupported currently
context_mat_wrap.emission_color = _get_colors(line_split)
+ context_mat_wrap.emission_strength = 1.0
elif line_id == b'ns':
# XXX Totally empirical conversion, trying to adapt it
# (from 0.0 - 900.0 OBJ specular exponent range to 1.0 - 0.0 Principled BSDF range)...