From 532b877ac54969ca186b12b05baa483625e3f5d0 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 20 Mar 2021 17:33:40 +0200 Subject: [PATCH] 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. --- blender/io_mspgl/export_material.py | 2 +- blender/io_mspgl/material.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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) -- 2.43.0