glTF importer: use vertexcolor node instead of attributenode
This commit is contained in:
parent
eb4085f1dc
commit
74a8fb2aa8
|
@ -15,7 +15,7 @@
|
|||
bl_info = {
|
||||
'name': 'glTF 2.0 format',
|
||||
'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
|
||||
"version": (1, 1, 2),
|
||||
"version": (1, 1, 3),
|
||||
'blender': (2, 81, 6),
|
||||
'location': 'File > Import-Export',
|
||||
'description': 'Import-Export as glTF 2.0',
|
||||
|
|
|
@ -60,22 +60,22 @@ class BlenderKHR_materials_pbrSpecularGlossiness():
|
|||
diffuse.inputs[0].default_value = pbrSG['diffuseFactor']
|
||||
|
||||
else:
|
||||
# Create attribute node to get COLOR_0 data
|
||||
attribute_node = node_tree.nodes.new('ShaderNodeAttribute')
|
||||
attribute_node.attribute_name = 'COLOR_0'
|
||||
attribute_node.location = -500, 0
|
||||
# Create vertexcolor node to get COLOR_0 data
|
||||
vertexcolor_node = node_tree.nodes.new('ShaderNodeVertexColor')
|
||||
vertexcolor_node.layer_name = 'COLOR_0'
|
||||
vertexcolor_node.location = -500, 0
|
||||
|
||||
# links
|
||||
node_tree.links.new(diffuse.inputs[0], attribute_node.outputs[0])
|
||||
node_tree.links.new(diffuse.inputs[0], vertexcolor_node.outputs[0])
|
||||
|
||||
elif pbrSG['diffuse_type'] == gltf.TEXTURE_FACTOR:
|
||||
|
||||
# TODO alpha ?
|
||||
if vertex_color:
|
||||
# TODO tree locations
|
||||
# Create attribute / separate / math nodes
|
||||
attribute_node = node_tree.nodes.new('ShaderNodeAttribute')
|
||||
attribute_node.attribute_name = 'COLOR_0'
|
||||
# Create vertexcolor / separate / math nodes
|
||||
vertexcolor_node = node_tree.nodes.new('ShaderNodeVertexColor')
|
||||
vertexcolor_node.layer_name = 'COLOR_0'
|
||||
|
||||
separate_vertex_color = node_tree.nodes.new('ShaderNodeSeparateRGB')
|
||||
math_vc_R = node_tree.nodes.new('ShaderNodeMath')
|
||||
|
@ -141,7 +141,7 @@ class BlenderKHR_materials_pbrSpecularGlossiness():
|
|||
|
||||
# Create links
|
||||
if vertex_color:
|
||||
node_tree.links.new(separate_vertex_color.inputs[0], attribute_node.outputs[0])
|
||||
node_tree.links.new(separate_vertex_color.inputs[0], vertexcolor_node.outputs[0])
|
||||
node_tree.links.new(math_vc_R.inputs[1], separate_vertex_color.outputs[0])
|
||||
node_tree.links.new(math_vc_G.inputs[1], separate_vertex_color.outputs[1])
|
||||
node_tree.links.new(math_vc_B.inputs[1], separate_vertex_color.outputs[2])
|
||||
|
@ -174,10 +174,10 @@ class BlenderKHR_materials_pbrSpecularGlossiness():
|
|||
|
||||
# TODO alpha ?
|
||||
if vertex_color:
|
||||
# Create attribute / separate / math nodes
|
||||
attribute_node = node_tree.nodes.new('ShaderNodeAttribute')
|
||||
attribute_node.attribute_name = 'COLOR_0'
|
||||
attribute_node.location = -2000, 250
|
||||
# Create vertexcolor / separate / math nodes
|
||||
vertexcolor_node = node_tree.nodes.new('ShaderNodeVertexColor')
|
||||
vertexcolor_node.layer_name = 'COLOR_0'
|
||||
vertexcolor_node.location = -2000, 250
|
||||
|
||||
separate_vertex_color = node_tree.nodes.new('ShaderNodeSeparateRGB')
|
||||
separate_vertex_color.location = -1500, 250
|
||||
|
@ -239,7 +239,7 @@ class BlenderKHR_materials_pbrSpecularGlossiness():
|
|||
|
||||
# Create links
|
||||
if vertex_color:
|
||||
node_tree.links.new(separate_vertex_color.inputs[0], attribute_node.outputs[0])
|
||||
node_tree.links.new(separate_vertex_color.inputs[0], vertexcolor_node.outputs[0])
|
||||
|
||||
node_tree.links.new(math_vc_R.inputs[1], separate_vertex_color.outputs[0])
|
||||
node_tree.links.new(math_vc_G.inputs[1], separate_vertex_color.outputs[1])
|
||||
|
|
|
@ -72,9 +72,9 @@ class BlenderPbr():
|
|||
|
||||
else:
|
||||
# Create attribute node to get COLOR_0 data
|
||||
attribute_node = node_tree.nodes.new('ShaderNodeAttribute')
|
||||
attribute_node.attribute_name = 'COLOR_0'
|
||||
attribute_node.location = -500, 0
|
||||
vertexcolor_node = node_tree.nodes.new('ShaderNodeVertexColor')
|
||||
vertexcolor_node.layer_name = 'COLOR_0'
|
||||
vertexcolor_node.location = -500, 0
|
||||
|
||||
if nodetype == "principled":
|
||||
# TODO : currently set metallic & specular in same way
|
||||
|
@ -86,7 +86,7 @@ class BlenderPbr():
|
|||
rgb_node.blend_type = 'MULTIPLY'
|
||||
rgb_node.inputs['Fac'].default_value = 1.0
|
||||
rgb_node.inputs['Color1'].default_value = pypbr.base_color_factor
|
||||
node_tree.links.new(rgb_node.inputs['Color2'], attribute_node.outputs[0])
|
||||
node_tree.links.new(rgb_node.inputs['Color2'], vertexcolor_node.outputs[0])
|
||||
node_tree.links.new(main_node.inputs[0], rgb_node.outputs[0])
|
||||
|
||||
elif pypbr.color_type == gltf.TEXTURE_FACTOR:
|
||||
|
@ -95,8 +95,8 @@ class BlenderPbr():
|
|||
if vertex_color:
|
||||
# TODO tree locations
|
||||
# Create attribute / separate / math nodes
|
||||
attribute_node = node_tree.nodes.new('ShaderNodeAttribute')
|
||||
attribute_node.attribute_name = 'COLOR_0'
|
||||
vertexcolor_node = node_tree.nodes.new('ShaderNodeVertexColor')
|
||||
vertexcolor_node.layer_name = 'COLOR_0'
|
||||
|
||||
vc_mult_node = node_tree.nodes.new('ShaderNodeMixRGB')
|
||||
vc_mult_node.blend_type = 'MULTIPLY'
|
||||
|
@ -148,7 +148,7 @@ class BlenderPbr():
|
|||
|
||||
# Create links
|
||||
if vertex_color:
|
||||
node_tree.links.new(vc_mult_node.inputs[2], attribute_node.outputs[0])
|
||||
node_tree.links.new(vc_mult_node.inputs[2], vertexcolor_node.outputs[0])
|
||||
node_tree.links.new(vc_mult_node.inputs[1], mult_node.outputs[0])
|
||||
node_tree.links.new(main_node.inputs[0], vc_mult_node.outputs[0])
|
||||
|
||||
|
@ -167,9 +167,9 @@ class BlenderPbr():
|
|||
# TODO alpha ?
|
||||
if vertex_color:
|
||||
# Create attribute / separate / math nodes
|
||||
attribute_node = node_tree.nodes.new('ShaderNodeAttribute')
|
||||
attribute_node.attribute_name = 'COLOR_0'
|
||||
attribute_node.location = -2000, 250
|
||||
vertexcolor_node = node_tree.nodes.new('ShaderNodeVertexColor')
|
||||
vertexcolor_node.layer_name = 'COLOR_0'
|
||||
vertexcolor_node.location = -2000, 250
|
||||
|
||||
vc_mult_node = node_tree.nodes.new('ShaderNodeMixRGB')
|
||||
vc_mult_node.blend_type = 'MULTIPLY'
|
||||
|
@ -217,7 +217,7 @@ class BlenderPbr():
|
|||
|
||||
# Create links
|
||||
if vertex_color:
|
||||
node_tree.links.new(vc_mult_node.inputs[2], attribute_node.outputs[0])
|
||||
node_tree.links.new(vc_mult_node.inputs[2], vertexcolor_node.outputs[0])
|
||||
node_tree.links.new(vc_mult_node.inputs[1], text_node.outputs[0])
|
||||
node_tree.links.new(main_node.inputs[0], vc_mult_node.outputs[0])
|
||||
|
||||
|
|
Loading…
Reference in New Issue