st.sub.append(tech_res.create_embed_statement("material", mat_res))
if material.render_mode=='CUSTOM':
- st.sub.append(Statement("shader", material.shader))
+ shader = material.shader
+ if shader.endswith(".glsl"):
+ shader += ".shader"
+ st.sub.append(Statement("shader", shader))
tech_res.statements.append(st)
material = Material(material)
if self.use_textures:
- for p in material.properties.values():
+ for p in material.properties:
if p.texture:
tex_name = p.texture.image.name+".tex2d"
if tex_name not in resources:
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)
- for kw, p in material.properties.items():
- ss = self.create_property_statement(mat_res, p, kw, resources)
+ for p in material.properties:
+ ss = self.create_property_statement(mat_res, p, resources)
if ss:
st.sub.append(ss)
if self.use_textures:
- first_tex = (p.texture for p in material.properties.values() if p.texture).__next__()
+ first_tex = (p.texture for p in material.properties if p.texture).__next__()
if first_tex and not first_tex.default_filter:
from .export_texture import SamplerExporter
sampler_export = SamplerExporter()
return mat_res
- def create_property_statement(self, mat_res, prop, keyword, resources):
+ def create_property_statement(self, mat_res, prop, resources):
from .datafile import Statement
if self.use_textures and prop.texture:
tex_res = resources[prop.texture.image.name+".tex2d"]
from .util import basename
fn = basename(prop.texture.image.filepath)
if prop.texture.default_filter and fn:
- return Statement(keyword+"_map", fn)
+ return Statement(prop.tex_keyword, fn)
else:
- return mat_res.create_reference_statement(keyword+"_map", tex_res)
- elif prop.value is None:
+ return mat_res.create_reference_statement(prop.tex_keyword, tex_res)
+ elif not prop.keyword:
return
elif type(prop.value)==tuple:
- return Statement(keyword, *prop.value)
+ return Statement(prop.keyword, *prop.value)
else:
- return Statement(keyword, prop.value)
+ return Statement(prop.keyword, prop.value)
class MaterialMapExporter: