- image_texture_slots = [s for s in material.texture_slots if s and s.texture.type=='IMAGE']
-
- 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))
- if material.override_material:
- st.sub.append(tech_res.create_reference_statement("material", "surface", mat_res))
- tech_res.statements.append(st)
- else:
- 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)))
+
+ blend_st = None
+ if material.blend_type=='ALPHA':
+ blend_st = Statement("blend", Token("SRC_ALPHA"), Token("ONE_MINUS_SRC_ALPHA"))
+ elif material.blend_type=='ADDITIVE':
+ blend_st = Statement("blend", Token("ONE"), Token("ONE"))
+ elif material.blend_type=='ADDITIVE_ALPHA':
+ blend_st = Statement("blend", Token("SRC_ALPHA"), Token("ONE"))
+
+ if material.render_mode=='CUSTOM':
+ for m in material.render_methods:
+ st = Statement("method", m.tag)
+ if mat_res and m.use_material:
+ st.sub.append(tech_res.create_reference_statement("material", mat_res))
+
+ if m.tag=="blended" and blend_st:
+ st.sub.append(blend_st)
+
+ shader = m.shader
+ if shader.endswith(".glsl"):
+ 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]))