From: Mikko Rasa Date: Sat, 16 Oct 2021 08:21:38 +0000 (+0300) Subject: Wrap material before passing it to create_technique_resource X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=2680cc0bf251db566753dbe9bf947ba6a4b083d2;p=libs%2Fgl.git Wrap material before passing it to create_technique_resource --- diff --git a/blender/io_mspgl/export_material.py b/blender/io_mspgl/export_material.py index 792ab290..7e8f6066 100644 --- a/blender/io_mspgl/export_material.py +++ b/blender/io_mspgl/export_material.py @@ -1,7 +1,6 @@ import os def create_technique_resource(material, resources): - # This operates on a Blender material, not a custom object from .datafile import Resource, Statement tech_res = Resource(material.name+".tech", "technique") @@ -38,7 +37,7 @@ def create_technique_resource(material, resources): tech_res.statements.append(st) - if material.shadow_method!='NONE': + if material.cast_shadows: st = Statement("method", "shadow") st.sub.append(Statement("shader", "occluder.glsl.shader")) tech_res.statements.append(st) @@ -56,7 +55,8 @@ class MaterialExporter: sampler_export = SamplerExporter() from .material import Material - material = Material(material) + if type(material)!=Material: + material = Material(material) for p in material.properties: if p.texture: @@ -76,6 +76,10 @@ class MaterialExporter: resources[mat_name] = None def export_technique(self, material, resources): + from .material import Material + if type(material)!=Material: + material = Material(material) + return create_technique_resource(material, resources) def export_material(self, material, resources): diff --git a/blender/io_mspgl/export_object.py b/blender/io_mspgl/export_object.py index 040f5302..a8f55e92 100644 --- a/blender/io_mspgl/export_object.py +++ b/blender/io_mspgl/export_object.py @@ -66,6 +66,7 @@ class ObjectExporter: if material.render_mode!='EXTERNAL': tech_name = material.name+".tech" if tech_name not in resources: + material = Material(material) material_export.export_technique_resources(material, resources) resources[tech_name] = material_export.export_technique(material, resources) elif "stub.tech" not in resources: diff --git a/blender/io_mspgl/material.py b/blender/io_mspgl/material.py index 167751c3..73f33d5c 100644 --- a/blender/io_mspgl/material.py +++ b/blender/io_mspgl/material.py @@ -121,6 +121,7 @@ class Material: self.render_mode = material.render_mode self.technique = material.technique self.render_methods = material.render_methods[:] + self.uniforms = material.uniforms[:] self.receive_shadows = material.receive_shadows self.cast_shadows = (material.shadow_method!='NONE') self.image_based_lighting = material.image_based_lighting