+ if material.type:
+ resources[mat_name] = self.export_material(material, resources)
+ else:
+ resources[mat_name] = None
+
+ if material.cast_shadows and material.alpha_cutoff>0.0:
+ for detail in ("", "_thsm"):
+ shader_name = "occluder{}_masked.shader".format(detail)
+ if shader_name not in resources:
+ resources[shader_name] = self.export_shader(shader_name, "occluder{}.glsl".format(detail), {"use_alpha_cutoff":True}, resources)
+
+ def export_technique(self, material, resources):
+ from .material import Material
+ if type(material)!=Material:
+ material = Material(material)
+
+ return create_technique_resource(material, resources)
+
+ def export_material(self, material, resources):
+ from .datafile import Resource, Statement, Token
+ mat_res = Resource(material.name+".mat", "material")
+
+ if material.type!="pbr" and material.type!="unlit":
+ raise Exception("Can't export material {} of unknown type {}".format(material.name, material.type))
+
+ mat_res.statements.append(Statement("type", Token(material.type)));
+ for p in material.properties:
+ st = self.create_property_statement(mat_res, p, resources)
+ if st:
+ mat_res.statements.append(st)
+ textures = [p.texture for p in material.properties if p.texture]
+ if textures:
+ from .export_texture import SamplerExporter
+ sampler_export = SamplerExporter()
+ mat_res.statements.append(mat_res.create_reference_statement("sampler", resources[sampler_export.get_sampler_name(textures[0])]))
+ if material.alpha_cutoff>0.0:
+ mat_res.statements.append(Statement("alpha_cutoff", material.alpha_cutoff))