From: Mikko Rasa Date: Sat, 20 Mar 2021 15:33:40 +0000 (+0200) Subject: Support exporting unlit materials X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=532b877ac54969ca186b12b05baa483625e3f5d0;p=libs%2Fgl.git Support exporting unlit materials 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. --- diff --git a/blender/io_mspgl/export_material.py b/blender/io_mspgl/export_material.py index 1df53470..d69389cc 100644 --- a/blender/io_mspgl/export_material.py +++ b/blender/io_mspgl/export_material.py @@ -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) diff --git a/blender/io_mspgl/material.py b/blender/io_mspgl/material.py index d2528605..e97561b7 100644 --- a/blender/io_mspgl/material.py +++ b/blender/io_mspgl/material.py @@ -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)