- raise Exception("Material has no surface node")
- elif surface_node.type!='BSDF_PRINCIPLED':
- raise Exception("Unsupported surface node type "+surface_node.type)
-
- base_color = self.properties["base_color"] = MaterialProperty((0.8, 0.8, 0.8, 1.0))
- metalness = self.properties["metalness"] = MaterialProperty(0.0)
- roughness = self.properties["roughness"] = MaterialProperty(0.5)
- normal = self.properties["normal"] = MaterialProperty(None)
- emission = self.properties["emission"] = MaterialProperty((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"])
+ 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))