+
+class MaterialMapExporter:
+ def __init__(self):
+ pass
+
+ def export_technique_resources(self, material_map, resources):
+ from .datafile import Resource, Statement, Token
+ base_color_name = material_map.name+"_base_color.tex2d"
+ base_color_res = resources.get(base_color_name)
+ if not base_color_res:
+ base_color_res = Resource(base_color_name, "texture2d")
+
+ base_color_res.statements.append(Statement("storage", Token('SRGB_ALPHA'), *material_map.size))
+ base_color_res.statements.append(Statement("raw_data", material_map.base_color_data))
+
+ resources[base_color_name] = base_color_res
+
+ sampler_name = "nearest.samp"
+ sampler_res = resources.get(sampler_name)
+ if not sampler_res:
+ sampler_res = Resource(sampler_name, "sampler")
+
+ sampler_res.statements.append(Statement("filter", Token('NEAREST')))
+
+ resources[sampler_name] = sampler_res
+
+ mat_name = material_map.name+".mat"
+ if mat_name not in resources:
+ mat_res = Resource(mat_name, "material")
+ st = Statement("pbr")
+ st.sub.append(mat_res.create_reference_statement("base_color_map", base_color_res))
+ st.sub.append(mat_res.create_reference_statement("sampler", sampler_res))
+ mat_res.statements.append(st)
+
+ resources[mat_name] = mat_res
+
+ def export_technique(self, material_map, *, resources):
+ return create_technique_resource(material_map, resources)