]> git.tdb.fi Git - libs/gl.git/commitdiff
Fix the recognition of additive blending in the Blender exporter
authorMikko Rasa <tdb@tdb.fi>
Fri, 11 Mar 2022 10:13:53 +0000 (12:13 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 11 Mar 2022 10:13:53 +0000 (12:13 +0200)
blender/io_mspgl/material.py

index dc6d934bedfdcc5c5e968cbbdf2fd878844d7709..633f030f2ede62bc82c487ec8eb454e2e85b98b4 100644 (file)
@@ -235,18 +235,18 @@ class Material:
 
                from .util import get_linked_node_and_socket
 
 
                from .util import get_linked_node_and_socket
 
-               surface_node, _ = get_linked_node_and_socket(material.node_tree, out_node.inputs["Surface"])
-               if not surface_node:
+               from_node, from_sock = get_linked_node_and_socket(material.node_tree, out_node.inputs["Surface"])
+               if not from_node:
                        if self.render_mode=='BUILTIN':
                                raise Exception("Invalid configuration on material {}: Empty material with builtin rendering".format(self.name))
                        return
 
                        if self.render_mode=='BUILTIN':
                                raise Exception("Invalid configuration on material {}: Empty material with builtin rendering".format(self.name))
                        return
 
-               additive_node, _ = check_additive_blend(material.node_tree, surface_node)
-               if additive_node:
+               surface_node = PropertyNode(material.node_tree, from_node, from_sock)
+               if surface_node.type=='ADDITIVE':
                        self.blend_type = 'ADDITIVE'
                        self.blend_type = 'ADDITIVE'
-                       surface_node = additive_node
+                       from_node = surface_node.input.node
 
 
-               if surface_node.type=='BSDF_PRINCIPLED':
+               if from_node.type=='BSDF_PRINCIPLED':
                        self.type = "pbr"
 
                        base_color = self.create_property("base_color", (0.8, 0.8, 0.8, 1.0))
                        self.type = "pbr"
 
                        base_color = self.create_property("base_color", (0.8, 0.8, 0.8, 1.0))
@@ -255,13 +255,13 @@ class Material:
                        normal = self.create_property("normal_map")
                        emission = self.create_property("emission", (0.0, 0.0, 0.0))
 
                        normal = self.create_property("normal_map")
                        emission = self.create_property("emission", (0.0, 0.0, 0.0))
 
-                       base_color.set_from_input(material.node_tree, surface_node.inputs["Base Color"], surface_node.inputs["Alpha"])
-                       metalness.set_from_input(material.node_tree, surface_node.inputs["Metallic"])
-                       roughness.set_from_input(material.node_tree, surface_node.inputs["Roughness"])
-                       normal.set_from_input(material.node_tree, surface_node.inputs["Normal"])
-                       emission.set_from_input(material.node_tree, surface_node.inputs["Emission"])
-               elif surface_node.type=='EMISSION' or surface_node.type=='MIX_SHADER':
-                       color_input, alpha_input = get_unlit_inputs(material.node_tree, surface_node, self.blend_type=='ADDITIVE')
+                       base_color.set_from_input(material.node_tree, from_node.inputs["Base Color"], from_node.inputs["Alpha"])
+                       metalness.set_from_input(material.node_tree, from_node.inputs["Metallic"])
+                       roughness.set_from_input(material.node_tree, from_node.inputs["Roughness"])
+                       normal.set_from_input(material.node_tree, from_node.inputs["Normal"])
+                       emission.set_from_input(material.node_tree, from_node.inputs["Emission"])
+               elif from_node.type=='EMISSION' or from_node.type=='MIX_SHADER':
+                       color_input, alpha_input = get_unlit_inputs(material.node_tree, from_node, self.blend_type=='ADDITIVE')
                        if not color_input:
                                raise Exception("Unsupported configuration for unlit material {}".format(self.name))
 
                        if not color_input:
                                raise Exception("Unsupported configuration for unlit material {}".format(self.name))
 
@@ -273,7 +273,7 @@ class Material:
                        if self.blend_type=='ADDITIVE' and alpha_input:
                                self.blend_type = 'ADDITIVE_ALPHA'
                else:
                        if self.blend_type=='ADDITIVE' and alpha_input:
                                self.blend_type = 'ADDITIVE_ALPHA'
                else:
-                       raise Exception("Unsupported surface node type {} on material {}".format(surface_node.type, self.name))
+                       raise Exception("Unsupported surface node type {} on material {}".format(from_node.type, self.name))
 
                sampler_settings = None
                for p in self.properties:
 
                sampler_settings = None
                for p in self.properties: