X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=blender%2Fio_mspgl%2Fexport_scene.py;h=00f91c1a4afcd6c5e5687066bc397c98baea628f;hb=77b358049bc1ef38ea013175a485cecd71a173c9;hp=162a1882b5e8d135168600da6e0bd2550fd00f21;hpb=9b371e56adc1d6be89f2d30881c3759a0d5f8eca;p=libs%2Fgl.git diff --git a/blender/io_mspgl/export_scene.py b/blender/io_mspgl/export_scene.py index 162a1882..00f91c1a 100644 --- a/blender/io_mspgl/export_scene.py +++ b/blender/io_mspgl/export_scene.py @@ -122,12 +122,11 @@ class SceneExporter: if scene.use_hdr: seq_res.statements.append(Statement("hdr", True)) - ss = Statement("clear") - ss.sub.append(Statement("color", 0.0, 0.0, 0.0, 0.0)) - ss.sub.append(Statement("depth", 1.0)) - seq_res.statements.append(ss) + self.add_clear(seq_res.statements, (0.0, 0.0, 0.0, 0.0), 1.0) scene_res = resources[scene.name+".scene"] + seq_res.statements.append(seq_res.create_reference_statement("renderable", "content", scene_res)) + lighting_res = resources[scene.name+".lightn"] any_opaque = False @@ -140,37 +139,57 @@ class SceneExporter: 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) + main_tags = [] + if any_opaque: + main_tags.append("") 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) + + self.add_content_steps(seq_res, "content", lighting_res, main_tags) if scene.use_ao: - ss = Statement("ambient_occlusion") + ss = Statement("postprocessor") + ss.sub.append(Statement("type", Token("ambient_occlusion"))) ss.sub.append(Statement("occlusion_radius", scene.ao_distance)) ss.sub.append(Statement("samples", scene.ao_samples)) seq_res.statements.append(ss) if scene.use_hdr: - seq_res.statements.append(Statement("bloom")) - ss = Statement("colorcurve") + ss = Statement("postprocessor") + ss.sub.append(Statement("type", Token("bloom"))) + seq_res.statements.append(ss) + + ss = Statement("postprocessor") + ss.sub.append(Statement("type", Token("colorcurve"))) ss.sub.append(Statement("exposure_adjust", scene.exposure)) ss.sub.append(Statement("srgb")) seq_res.statements.append(ss) else: # Add a colorcurve with linear response to convert into sRGB color space - ss = Statement("colorcurve") + ss = Statement("postprocessor") + ss.sub.append(Statement("type", Token("colorcurve"))) ss.sub.append(Statement("brightness_response", 1.0)) ss.sub.append(Statement("srgb")) seq_res.statements.append(ss) return seq_res + + def add_clear(self, statements, color, depth): + from .datafile import Statement + + st = Statement("clear") + if color is not None: + st.sub.append(Statement("color", *color)) + if depth is not None: + st.sub.append(Statement("depth", depth)) + statements.append(st) + + def add_content_steps(self, seq_res, renderable, lighting, tags): + from .datafile import Statement, Token + + for t in tags: + st = Statement("step", t, renderable) + st.sub.append(Statement("depth_test", Token("LEQUAL"))) + if lighting: + st.sub.append(seq_res.create_reference_statement("lighting", lighting)) + seq_res.statements.append(st)