[Bf-extensions-cvs] [74a8fb2a] master: glTF importer: use vertexcolor node instead of attributenode

Julien Duroure noreply at git.blender.org
Sat Nov 9 10:56:57 CET 2019


Commit: 74a8fb2aa8f983a573cd35be1c883c8701c88093
Author: Julien Duroure
Date:   Sat Nov 9 10:56:01 2019 +0100
Branches: master
https://developer.blender.org/rBA74a8fb2aa8f983a573cd35be1c883c8701c88093

glTF importer: use vertexcolor node instead of attributenode

===================================================================

M	io_scene_gltf2/__init__.py
M	io_scene_gltf2/blender/imp/gltf2_blender_KHR_materials_pbrSpecularGlossiness.py
M	io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py

===================================================================

diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 6155a811..afc266a2 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -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',
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_KHR_materials_pbrSpecularGlossiness.py b/io_scene_gltf2/blender/imp/gltf2_blender_KHR_materials_pbrSpecularGlossiness.py
index 95427ccd..387db56f 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_KHR_materials_pbrSpecularGlossiness.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_KHR_materials_pbrSpecularGlossiness.py
@@ -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])
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py b/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py
index af529090..081d8356 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py
@@ -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])



More information about the Bf-extensions-cvs mailing list