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:20:16 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-10-10 18:20:16 +0300
commitdb2c65d9e7885809a9ac6ab09fa2585e6b35d353 (patch)
tree6c9844bb5ced862350dff6984ad20d4e411cd1f0 /io_scene_obj/import_obj.py
parentc4f78f14931be95e7f3bb31169579206369cc569 (diff)
Fix T70666: OBJ IO: Add support for new Emission option of Principled BSDF.
Diffstat (limited to 'io_scene_obj/import_obj.py')
-rw-r--r--io_scene_obj/import_obj.py25
1 files changed, 7 insertions, 18 deletions
diff --git a/io_scene_obj/import_obj.py b/io_scene_obj/import_obj.py
index f90528f9..4d640d44 100644
--- a/io_scene_obj/import_obj.py
+++ b/io_scene_obj/import_obj.py
@@ -187,8 +187,7 @@ def create_materials(filepath, relpath,
_generic_tex_set(mat_wrap.specular_texture, image, 'UV', map_offset, map_scale)
elif type == 'Ke':
- # XXX Not supported?
- print("WARNING, currently unsupported emit texture, skipped.")
+ _generic_tex_set(mat_wrap.emission_color_texture, image, 'UV', map_offset, map_scale)
elif type == 'Bump':
bump_mult = map_options.get(b'-bm')
@@ -218,7 +217,7 @@ def create_materials(filepath, relpath,
else:
raise Exception("invalid type %r" % type)
- def finalize_material(context_material, context_material_vars, spec_colors, emit_colors,
+ def finalize_material(context_material, context_material_vars, spec_colors,
do_highlight, do_reflection, do_transparency, do_glass):
# Finalize previous mat, if any.
if context_material:
@@ -237,14 +236,6 @@ def create_materials(filepath, relpath,
if "roughness" not in context_material_vars:
context_mat_wrap.roughness = 0.0
-
- emit_value = sum(emit_colors) / 3.0
- if emit_value > 1e-6:
- print("WARNING, emit value unsupported by Principled BSDF shader, skipped.")
- # We have to adapt it to diffuse color too...
- emit_value /= sum(tuple(context_material.diffuse_color)[:3]) / 3.0
- # ~ context_material.emit = emit_value
-
# FIXME, how else to use this?
if do_highlight:
if "specular" not in context_material_vars:
@@ -303,7 +294,6 @@ def create_materials(filepath, relpath,
do_transparency = False
do_glass = False
spec_colors = [0.0, 0.0, 0.0]
- emit_colors = [0.0, 0.0, 0.0]
# print('\t\tloading mtl: %e' % mtlpath)
context_material = None
@@ -319,7 +309,7 @@ def create_materials(filepath, relpath,
if line_id == b'newmtl':
# Finalize previous mat, if any.
- finalize_material(context_material, context_material_vars, spec_colors, emit_colors,
+ finalize_material(context_material, context_material_vars, spec_colors,
do_highlight, do_reflection, do_transparency, do_glass)
context_material_name = line_value(line_split)
@@ -328,8 +318,7 @@ def create_materials(filepath, relpath,
context_mat_wrap = nodal_material_wrap_map[context_material]
context_material_vars.clear()
- spec_colors = [0.0, 0.0, 0.0]
- emit_colors[:] = [0.0, 0.0, 0.0]
+ spec_colors[:] = [0.0, 0.0, 0.0]
do_highlight = False
do_reflection = False
do_transparency = False
@@ -352,8 +341,8 @@ def create_materials(filepath, relpath,
elif line_id == b'ke':
# We cannot set context_material.emit right now, we need final diffuse color as well for this.
# XXX Unsupported currently
- emit_colors[:] = [
- float_func(line_split[1]), float_func(line_split[2]), float_func(line_split[3])]
+ col = (float_func(line_split[1]), float_func(line_split[2]), float_func(line_split[3]))
+ context_mat_wrap.emission_color = col
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)...
@@ -469,7 +458,7 @@ def create_materials(filepath, relpath,
print("WARNING: %r:%r (ignored)" % (filepath, line))
# Finalize last mat, if any.
- finalize_material(context_material, context_material_vars, spec_colors, emit_colors,
+ finalize_material(context_material, context_material_vars, spec_colors,
do_highlight, do_reflection, do_transparency, do_glass)
mtl.close()