X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=blender%2Fio_mspgl%2Fexport_material.py;h=c7ca765cb0736c9387c5742b0b9e76a3f0e7c106;hb=c3ebbcb56c1ca9bb3022a7f49aab1da5e09150ba;hp=1df5347098571a3a84d25db46f1df91c3626d229;hpb=401f74574e55fd9e490eaa4f16f1cc97d0603513;p=libs%2Fgl.git diff --git a/blender/io_mspgl/export_material.py b/blender/io_mspgl/export_material.py index 1df53470..c7ca765c 100644 --- a/blender/io_mspgl/export_material.py +++ b/blender/io_mspgl/export_material.py @@ -16,6 +16,12 @@ def create_technique_resource(material, resources): shader += ".shader" st.sub.append(Statement("shader", shader)) + if material.uniforms: + ss = Statement("uniforms") + for u in material.uniforms: + ss.sub.append(Statement("uniform", u.name, *u.values[:u.size])) + st.sub.append(ss) + tech_res.statements.append(st) return tech_res @@ -64,7 +70,7 @@ class MaterialExporter: from .datafile import Resource, Statement mat_res = Resource(material.name+".mat", "material") - if material.type!="pbr": + if material.type!="pbr" and material.type!="unlit": raise Exception("Can't export unknown material type "+material.type) st = Statement(material.type) @@ -73,11 +79,11 @@ class MaterialExporter: if ss: st.sub.append(ss) if self.use_textures: - first_tex = (p.texture for p in material.properties if p.texture).__next__() - if first_tex and not first_tex.default_filter: + textures = [p.texture for p in material.properties if p.texture] + if textures and not textures[0].default_filter: from .export_texture import SamplerExporter sampler_export = SamplerExporter() - st.sub.append(mat_res.create_reference_statement("sampler", resources[sampler_export.get_sampler_name(first_tex)])) + st.sub.append(mat_res.create_reference_statement("sampler", resources[sampler_export.get_sampler_name(textures[0])])) mat_res.statements.append(st) return mat_res @@ -100,19 +106,19 @@ class MaterialExporter: return Statement(prop.keyword, prop.value) -class MaterialMapExporter: +class MaterialAtlasExporter: def __init__(self): pass - def export_technique_resources(self, material_map, resources): + def export_technique_resources(self, material_atlas, resources): from .datafile import Resource, Statement, Token - base_color_name = material_map.name+"_base_color.tex2d" + base_color_name = material_atlas.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)) + base_color_res.statements.append(Statement("storage", Token('SRGB_ALPHA'), *material_atlas.size)) + base_color_res.statements.append(Statement("raw_data", material_atlas.base_color_data)) resources[base_color_name] = base_color_res @@ -125,7 +131,7 @@ class MaterialMapExporter: resources[sampler_name] = sampler_res - mat_name = material_map.name+".mat" + mat_name = material_atlas.name+".mat" if mat_name not in resources: mat_res = Resource(mat_name, "material") st = Statement("pbr") @@ -135,5 +141,5 @@ class MaterialMapExporter: resources[mat_name] = mat_res - def export_technique(self, material_map, *, resources): - return create_technique_resource(material_map, resources) + def export_technique(self, material_atlas, *, resources): + return create_technique_resource(material_atlas, resources)