- raise Exception("Material has no surface node")
- elif surface_node.type!='BSDF_PRINCIPLED':
- raise Exception("Unsupported surface node type "+surface_node.type)
-
- self.base_color.set_from_input(material.node_tree, surface_node.inputs["Base Color"], surface_node.inputs["Alpha"])
- self.metalness.set_from_input(material.node_tree, surface_node.inputs["Metallic"])
- self.roughness.set_from_input(material.node_tree, surface_node.inputs["Roughness"])
- self.normal.set_from_input(material.node_tree, surface_node.inputs["Normal"])
- self.emission.set_from_input(material.node_tree, surface_node.inputs["Emission"])
-
- self.properties = (self.base_color, self.metalness, self.roughness, self.normal, self.emission)
+ if self.render_mode=='BUILTIN':
+ raise Exception("Invalid configuration on material {}: Empty material with builtin rendering".format(self.name))
+ return
+ elif surface_node.type=='BSDF_PRINCIPLED':
+ self.type = "pbr"
+
+ base_color = self.create_property("base_color", (0.8, 0.8, 0.8, 1.0))
+ metalness = self.create_property("metalness", 0.0)
+ roughness = self.create_property("roughness", 0.5)
+ 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':
+ self.type = "unlit"
+
+ color = self.create_property("color", "texture", (1.0, 1.0, 1.0, 1.0))
+
+ color.set_from_input(material.node_tree, surface_node.inputs["Color"])
+ else:
+ raise Exception("Unsupported surface node type {} on material {}".format(surface_node.type, self.name))