From 84bd8cf4443f719d13fb5fa7008aba851d91a5c0 Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Tue, 26 Dec 2017 22:35:59 -0800 Subject: [PATCH] Handle shadeless & emit material flags --- korman/exporter/material.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/korman/exporter/material.py b/korman/exporter/material.py index b3757b9..040c341 100644 --- a/korman/exporter/material.py +++ b/korman/exporter/material.py @@ -733,6 +733,9 @@ class MaterialConverter: state.shadeFlags |= hsGMatState.kShadeNoFog # Dead in CWE state.shadeFlags |= hsGMatState.kShadeReallyNoFog + if bm.use_shadeless: + state.shadeFlags |= hsGMatState.kShadeWhite + # Colors layer.ambient = utils.color(bpy.context.scene.world.ambient_color) layer.preshade = utils.color(bm.diffuse_color) @@ -742,6 +745,15 @@ class MaterialConverter: layer.specularPower = min(100.0, float(bm.specular_hardness)) layer.LODBias = -1.0 # Seems to be the Plasma default + if bm.emit > 0.0: + # Use the diffuse colour as the emit, scaled by the emit amount + # (maximum 2.0, so we'll also scale that by 0.5) + emit_scale = bm.emit * 0.5 + layer.ambient = hsColorRGBA(bm.diffuse_color.r * emit_scale, + bm.diffuse_color.g * emit_scale, + bm.diffuse_color.b * emit_scale, + 1.0) + @property def _report(self): return self._exporter().report