+ else:
+ base_method = "blended" if material.blend_type!='NONE' else ""
+ st = Statement("method", base_method)
+ if mat_res:
+ st.sub.append(tech_res.create_embed_statement("material", mat_res))
+
+ if blend_st:
+ st.sub.append(blend_st)
+ if material.receive_shadows:
+ st.sub.append(Statement("receive_shadows", True))
+ if material.image_based_lighting:
+ st.sub.append(Statement("image_based_lighting", True))
+ if material.face_cull=='BACK':
+ st.sub.append(Statement("face_cull", Token("CULL_BACK")))
+
+ tech_res.statements.append(st)
+
+ if material.cast_shadows:
+ tech_res.statements.append(create_shadow_method(tech_res, material, resources, ""));
+ tech_res.statements.append(create_shadow_method(tech_res, material, resources, "_thsm"));
+
+ return tech_res
+
+class MaterialExporter:
+ def export_technique_resources(self, ctx, material, resources):
+ from .export_texture import SamplerExporter, TextureExporter
+ texture_export = TextureExporter()
+ sampler_export = SamplerExporter()
+
+ from .material import Material
+ if type(material)!=Material:
+ material = Material(material)
+
+ textured_props = [p for p in material.properties if p.texture]
+
+ ctx.set_slices(len(textured_props)+1)
+ for p in textured_props:
+ ctx.next_slice(p.texture.image)
+
+ tex_name = texture_export.get_texture_name(p.texture, p.tex_channels)
+ if tex_name not in resources:
+ resources[tex_name] = texture_export.export_texture(p.texture, p.tex_channels)
+
+ samp_name = sampler_export.get_sampler_name(p.texture)
+ if samp_name not in resources:
+ resources[samp_name] = sampler_export.export_sampler(p.texture)
+
+ ctx.next_slice(material)
+ mat_name = material.name+".mat"
+ if mat_name not in resources:
+ if material.type:
+ resources[mat_name] = self.export_material(material, resources)