From 3abb36b4c4629266ef1a935f44bdce406c83d828 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 5 Oct 2020 19:13:06 -0400 Subject: [PATCH] Partially revert the emissive stuff. --- korman/exporter/material.py | 26 +++++++++++++------------- korman/exporter/mesh.py | 9 +++++++-- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/korman/exporter/material.py b/korman/exporter/material.py index 9bdc221..d2a2ba9 100644 --- a/korman/exporter/material.py +++ b/korman/exporter/material.py @@ -147,16 +147,6 @@ class MaterialConverter: "transformCtl": self._export_layer_transform_animation, } - def calc_material_ambient(self, bo, bm) -> hsColorRGBA: - emit_scale = bm.emit * 0.5 - if emit_scale > 0.0: - return hsColorRGBA(bm.diffuse_color.r * emit_scale, - bm.diffuse_color.g * emit_scale, - bm.diffuse_color.b * emit_scale, - 1.0) - else: - return utils.color(bpy.context.scene.world.ambient_color) - def _can_export_texslot(self, slot): if slot is None or not slot.use: return False @@ -1176,15 +1166,25 @@ class MaterialConverter: def get_bump_layer(self, bo): return self._bump_mats.get(bo, None) + def get_material_ambient(self, bo, bm) -> hsColorRGBA: + emit_scale = bm.emit * 0.5 + if emit_scale > 0.0: + return hsColorRGBA(bm.diffuse_color.r * emit_scale, + bm.diffuse_color.g * emit_scale, + bm.diffuse_color.b * emit_scale, + 1.0) + else: + return utils.color(bpy.context.scene.world.ambient_color) + def get_material_preshade(self, bo, bm, color=None) -> hsColorRGBA: - if bo.plasma_modifiers.lighting.rt_lights or bm.emit: + if bo.plasma_modifiers.lighting.rt_lights: return hsColorRGBA.kBlack if color is None: color = bm.diffuse_color return utils.color(color) def get_material_runtime(self, bo, bm, color=None) -> hsColorRGBA: - if bm.emit: + if not bo.plasma_modifiers.lighting.rt_lights: return hsColorRGBA.kBlack if color is None: color = bm.diffuse_color @@ -1235,7 +1235,7 @@ class MaterialConverter: state.shadeFlags |= hsGMatState.kShadeEmissive # Colors - layer.ambient = self.calc_material_ambient(bo, bm) + layer.ambient = self.get_material_ambient(bo, bm) layer.preshade = self.get_material_preshade(bo, bm) layer.runtime = self.get_material_runtime(bo, bm) layer.specular = utils.color(bm.specular_color) diff --git a/korman/exporter/mesh.py b/korman/exporter/mesh.py index 1f1dc7d..03625ba 100644 --- a/korman/exporter/mesh.py +++ b/korman/exporter/mesh.py @@ -279,8 +279,13 @@ class MeshConverter(_MeshManager): # TODO: if this is an avatar, we can't be non-preshaded. if check_layer_shading_animation(base_layer): return False - if material_idx is not None and mesh.materials[material_idx].emit: - return False + + # Reject emissive and shadeless because the kLiteMaterial equation has lots of options + # that are taken away by VtxNonPreshaded that are useful here. + if material_idx is not None: + bm = mesh.materials[material_idx] + if bm.emit or bm.use_shadeless: + return False mods = bo.plasma_modifiers if mods.lighting.rt_lights: