]> git.tdb.fi Git - libs/gl.git/commitdiff
Support exporting unlit materials
authorMikko Rasa <tdb@tdb.fi>
Sat, 20 Mar 2021 15:33:40 +0000 (17:33 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 20 Mar 2021 15:33:40 +0000 (17:33 +0200)
These use the emission surface type in Blender.  While that may seem
strange at first, it's actually a good match to how unlit materials
behave in a realtime scene.

blender/io_mspgl/export_material.py
blender/io_mspgl/material.py

index 1df5347098571a3a84d25db46f1df91c3626d229..d69389cc2e024e52a304d1fcb6171bcc5e0ceaa0 100644 (file)
@@ -64,7 +64,7 @@ class MaterialExporter:
                from .datafile import Resource, Statement
                mat_res = Resource(material.name+".mat", "material")
 
-               if material.type!="pbr":
+               if material.type!="pbr" and material.type!="unlit":
                        raise Exception("Can't export unknown material type "+material.type)
 
                st = Statement(material.type)
index d25286055056034a68d936976d18b4755ceb0685..e97561b795f5ffd6ffa5ec915c0e8c15cfc5fe1d 100644 (file)
@@ -92,6 +92,12 @@ class Material:
                        roughness.set_from_input(material.node_tree, surface_node.inputs["Roughness"])
                        normal.set_from_input(material.node_tree, surface_node.inputs["Normal"])
                        emission.set_from_input(material.node_tree, surface_node.inputs["Emission"])
+               elif surface_node.type=='EMISSION':
+                       self.type = "unlit"
+
+                       color = self.create_property("color", "texture", (1.0, 1.0, 1.0, 1.0))
+
+                       color.set_from_input(material.node_tree, surface_node.inputs["Color"])
                else:
                        raise Exception("Unsupported surface node type "+surface_node.type)