[Bf-extensions-cvs] [521ce78a] master: glTF importer: fix default emissive factor default
Julien Duroure
noreply at git.blender.org
Wed Jan 2 23:09:07 CET 2019
Commit: 521ce78a7293a1d0d91969973d5c758a9f8c9b93
Author: Julien Duroure
Date: Wed Jan 2 23:07:50 2019 +0100
Branches: master
https://developer.blender.org/rBA521ce78a7293a1d0d91969973d5c758a9f8c9b93
glTF importer: fix default emissive factor default
* Emissive factor default is 0.0 / 0.0 / 0.0
* Enhancement: change 3 maths node by a MixRGBNode (multiply mode)
===================================================================
M io_scene_gltf2/blender/imp/gltf2_blender_map_emissive.py
===================================================================
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_map_emissive.py b/io_scene_gltf2/blender/imp/gltf2_blender_map_emissive.py
index c3d0cb22..22af5ccb 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_map_emissive.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_map_emissive.py
@@ -40,7 +40,8 @@ class BlenderEmissiveMap():
# check if there is some emssive_factor on material
if pymaterial.emissive_factor is None:
- pymaterial.emissive_factor = [1.0, 1.0, 1.0]
+ # Default in glTF specification is 0/0/0 --> No emission
+ pymaterial.emissive_factor = [0.0, 0.0, 0.0]
# retrieve principled node and output node
principled = get_preoutput_node_output(node_tree)
@@ -50,10 +51,16 @@ class BlenderEmissiveMap():
emit = node_tree.nodes.new('ShaderNodeEmission')
emit.location = 0, 1000
if pymaterial.emissive_factor != [1.0, 1.0, 1.0]:
- separate = node_tree.nodes.new('ShaderNodeSeparateRGB')
- separate.location = -750, 1000
- combine = node_tree.nodes.new('ShaderNodeCombineRGB')
- combine.location = -250, 1000
+ mult_node = node_tree.nodes.new('ShaderNodeMixRGB')
+ mult_node.blend_type = 'MULTIPLY'
+ mult_node.inputs['Fac'].default_value = 1.0
+ mult_node.location = -500, 1000
+ mult_node.inputs['Color2'].default_value = [
+ pymaterial.emissive_factor[0],
+ pymaterial.emissive_factor[1],
+ pymaterial.emissive_factor[2],
+ 1.0,
+ ]
mapping = node_tree.nodes.new('ShaderNodeMapping')
mapping.location = -1500, 1000
uvmap = node_tree.nodes.new('ShaderNodeUVMap')
@@ -72,34 +79,12 @@ class BlenderEmissiveMap():
add = node_tree.nodes.new('ShaderNodeAddShader')
add.location = 500, 500
- if pymaterial.emissive_factor != [1.0, 1.0, 1.0]:
- math_R = node_tree.nodes.new('ShaderNodeMath')
- math_R.location = -500, 1500
- math_R.operation = 'MULTIPLY'
- math_R.inputs[1].default_value = pymaterial.emissive_factor[0]
-
- math_G = node_tree.nodes.new('ShaderNodeMath')
- math_G.location = -500, 1250
- math_G.operation = 'MULTIPLY'
- math_G.inputs[1].default_value = pymaterial.emissive_factor[1]
-
- math_B = node_tree.nodes.new('ShaderNodeMath')
- math_B.location = -500, 1000
- math_B.operation = 'MULTIPLY'
- math_B.inputs[1].default_value = pymaterial.emissive_factor[2]
-
# create links
node_tree.links.new(mapping.inputs[0], uvmap.outputs[0])
node_tree.links.new(text.inputs[0], mapping.outputs[0])
if pymaterial.emissive_factor != [1.0, 1.0, 1.0]:
- node_tree.links.new(separate.inputs[0], text.outputs[0])
- node_tree.links.new(math_R.inputs[0], separate.outputs[0])
- node_tree.links.new(math_G.inputs[0], separate.outputs[1])
- node_tree.links.new(math_B.inputs[0], separate.outputs[2])
- node_tree.links.new(combine.inputs[0], math_R.outputs[0])
- node_tree.links.new(combine.inputs[1], math_G.outputs[0])
- node_tree.links.new(combine.inputs[2], math_B.outputs[0])
- node_tree.links.new(emit.inputs[0], combine.outputs[0])
+ node_tree.links.new(mult_node.inputs[1], text.outputs[0])
+ node_tree.links.new(emit.inputs[0], mult_node.outputs[0])
else:
node_tree.links.new(emit.inputs[0], text.outputs[0])
More information about the Bf-extensions-cvs
mailing list