mat_res = resources[material.name+".mat"]
st = Statement("pass", "")
- st.sub.append(tech_res.create_embed_statement("material", mat_res))
+ if mat_res:
+ st.sub.append(tech_res.create_embed_statement("material", mat_res))
if material.render_mode=='CUSTOM':
st.sub.append(Statement("shader", material.shader))
mat_name = material.name+".mat"
if mat_name not in resources:
- resources[mat_name] = self.export_material(material, resources=resources)
+ if material.type:
+ resources[mat_name] = self.export_material(material, resources=resources)
+ else:
+ resources[mat_name] = None
def export_technique(self, material, *, resources):
return create_technique_resource(material, resources)
from .datafile import Resource, Statement
mat_res = Resource(material.name+".mat", "material")
- st = Statement("pbr")
+ if material.type!="pbr":
+ raise Exception("Can't export unknown material type "+material.type)
+
+ st = Statement(material.type)
for kw, p in material.properties.items():
ss = self.create_property_statement(mat_res, p, kw, resources)
if ss:
class Material:
def __init__(self, material):
self.name = material.name
+ self.type = None
self.properties = {}
self.render_mode = material.render_mode
surface_node, _ = get_linked_node_and_socket(material.node_tree, out_node.inputs["Surface"])
if not surface_node:
- raise Exception("Material has no surface node")
+ if self.render_mode=='BUILTIN':
+ raise Exception("Empty material can't use builtin rendering mode")
+ return
elif surface_node.type!='BSDF_PRINCIPLED':
raise Exception("Unsupported surface node type "+surface_node.type)
+ self.type = "pbr"
+
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)