if self.textures=='INLINE':
for s in material.texture_slots:
- if s and s.texture.type=='IMAGE':
+ if s and s.texture.type=='IMAGE' and s.texture.image:
tex_name = s.texture.name+".tex2d"
if tex_name not in resources:
resources[tex_name] = texture_export.export_texture(s.texture)
tech_res = Resource(material.name+".tech")
mat_res = resources[material.name+".mat"]
- image_texture_slots = [s for s in material.texture_slots if s and s.texture.type=='IMAGE']
+ textures = {}
+ if self.textures!='NONE':
+ image_texture_slots = [s for s in material.texture_slots if s and s.texture.type=='IMAGE' and s.texture.image]
+ for s in image_texture_slots:
+ if s.use_map_color_diffuse:
+ textures["diffuse_map"] = s.texture
+ elif s.use_map_normal:
+ textures["normal_map"] = s.texture
if material.technique:
if not obj.inherit_tech:
return []
st = Statement("inherit", material.technique)
- for slot in image_texture_slots:
- name = image_name(slot.texture.image)
- if slot.use_map_color_diffuse:
- st.sub.append(Statement("texture", "diffuse_map", name))
- elif slot.use_map_normal:
- st.sub.append(Statement("texture", "normal_map", name))
+ for s, t in textures.items():
+ st.sub.append(Statement("texture", s, image_name(t.image)))
if material.override_material:
st.sub.append(tech_res.create_reference_statement("material", "surface", mat_res))
tech_res.statements.append(st)
st = Statement("pass", "")
st.sub.append(tech_res.create_embed_statement("material", mat_res))
- if self.textures!='NONE':
- diffuse_tex = None
- for slot in image_texture_slots:
- if slot.use_map_color_diffuse:
- diffuse_tex = slot.texture
- break
-
- if diffuse_tex:
- ss = Statement("texunit", 0)
- if self.textures=='INLINE':
- tex_res = resources[slot.texture.name+".tex2d"]
- ss.sub.append(tech_res.create_embed_statement("texture2d", tex_res))
- elif tex.image:
- ss.sub.append(Statement("texture", image_name(tex.image)))
- st.sub.append(ss)
+ if "diffuse_map" in textures:
+ diffuse_tex = textures["diffuse_map"]
+ ss = Statement("texunit", 0)
+ if self.textures=='INLINE':
+ ss.sub.append(tech_res.create_embed_statement("texture2d", resources[diffuse_tex.name+".tex2d"]))
+ else:
+ ss.sub.append(Statement("texture", image_name(diffuse_tex.image)))
+ st.sub.append(ss)
tech_res.statements.append(st)