import os
def create_technique_resource(material, resources):
- from .datafile import Resource, Statement
+ from .datafile import Resource, Statement, Token
tech_res = Resource(material.name+".tech", "technique")
mat_res = resources[material.name+".mat"]
tech_res.statements.append(st)
else:
- st = Statement("method", "")
+ base_method = "blended" if material.blended else ""
+ st = Statement("method", base_method)
if mat_res:
st.sub.append(tech_res.create_embed_statement("material", mat_res))
+ if material.blended:
+ ss.sub.append(Statement("blend", Token("SRC_ALPHA"), Token("ONE_MINUS_SRC_ALPHA")))
+
if material.render_mode!='CUSTOM':
if material.receive_shadows:
st.sub.append(Statement("receive_shadows", True))
from .datafile import Resource, Statement, Token
scene_res = Resource(scene.name+".scene", "scene")
- if scene.background_set:
+ if scene.background_set or (scene.instances and scene.blended_instances):
scene_res.statements.append(Statement("type", Token("ordered")))
if scene.background_set:
scene_res.statements.append(scene_res.create_reference_statement("scene", resources[scene.background_set.name+".scene"]))
- st = Statement("scene")
- st.sub.append(Statement("type", Token("simple")))
- self.add_instances(scene_res, st.sub, scene.instances, resources)
- scene_res.statements.append(st)
+ if scene.instances:
+ st = Statement("scene")
+ st.sub.append(Statement("type", Token("simple")))
+ self.add_instances(scene_res, st.sub, scene.instances, resources)
+ scene_res.statements.append(st)
+
+ if scene.blended_instances:
+ st = Statement("scene")
+ st.sub.append(Statement("type", Token("zsorted")))
+ self.add_instances(scene_res, st.sub, scene.blended_instances, resources)
+ scene_res.statements.append(st)
else:
- scene_res.statements.append(Statement("type", Token("simple")))
+ scene_type = "zsorted" if scene.blended_instances else "simple"
+ scene_res.statements.append(Statement("type", Token(scene_type)))
self.add_instances(scene_res, scene_res.statements, scene.instances, resources)
+ self.add_instances(scene_res, scene_res.statements, scene.blended_instances, resources)
return scene_res
ss.sub.append(Statement("depth", 1.0))
seq_res.statements.append(ss)
- ss = Statement("step", "", "content")
- ss.sub.append(Statement("depth_test", Token("LEQUAL")))
- ss.sub.append(seq_res.create_reference_statement("lighting", resources[scene.name+".lightn"]))
- ss.sub.append(seq_res.create_reference_statement("scene", resources[scene.name+".scene"]))
- seq_res.statements.append(ss)
+ scene_res = resources[scene.name+".scene"]
+ lighting_res = resources[scene.name+".lightn"]
+
+ any_opaque = False
+ any_blended = False
+ s = scene
+ while s:
+ if s.instances:
+ any_opaque = True
+ if s.blended_instances:
+ any_blended = True
+ s = s.background_set
+
+ if any_opaque:
+ ss = Statement("step", "", "content")
+ ss.sub.append(Statement("depth_test", Token("LEQUAL")))
+ ss.sub.append(seq_res.create_reference_statement("lighting", lighting_res))
+ ss.sub.append(seq_res.create_reference_statement("scene", scene_res))
+ seq_res.statements.append(ss)
+
+ if any_blended:
+ ss = Statement("step", "blended", "content")
+ ss.sub.append(Statement("depth_test", Token("LEQUAL")))
+ ss.sub.append(seq_res.create_reference_statement("lighting", lighting_res))
+ ss.sub.append(seq_res.create_reference_statement("scene", scene_res))
+ seq_res.statements.append(ss)
if scene.use_ao:
ss = Statement("ambient_occlusion")
self.camera = scene.camera
self.prototypes = []
self.instances = []
+ self.blended_instances = []
self.lights = []
self.ambient_light = mathutils.Color((0.0, 0.0, 0.0))
self.exposure = scene.view_settings.exposure
if o.type=='MESH':
clones = [c for c in objects if is_same_object(o, c)]
self.prototypes.append(o)
+ instance_list = self.instances
+ if o.material_slots and o.material_slots[0].material and o.material_slots[0].material.blend_method=='BLEND':
+ instance_list = self.blended_instances
for c in clones:
- self.instances.append(Instance(c, o))
+ instance_list.append(Instance(c, o))
processed.add(c.name)
elif o.type=='LIGHT':
self.lights.append(o)