]> git.tdb.fi Git - libs/gl.git/commitdiff
Wrap material before passing it to create_technique_resource
authorMikko Rasa <tdb@tdb.fi>
Sat, 16 Oct 2021 08:21:38 +0000 (11:21 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 16 Oct 2021 10:41:09 +0000 (13:41 +0300)
blender/io_mspgl/export_material.py
blender/io_mspgl/export_object.py
blender/io_mspgl/material.py

index 792ab2903576ba4a10518fef480c06cb5cc49ac9..7e8f60660b4563eddc2e04f4f93ae2b3ff635e41 100644 (file)
@@ -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):
index 040f5302f060536c708c0bb9a0300a3c12444317..a8f55e92c34834a01ac0f17115b44b2d1343fd31 100644 (file)
@@ -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:
index 167751c34208e2b185bb0bdf382eaa559ef2c03c..73f33d5c29a669eccdb235e0823dea95a1086209 100644 (file)
@@ -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