From a8119f386391a8637c87fc61c5371515d89229be Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Sun, 23 Jul 2023 23:35:52 +0300 Subject: [PATCH] Fix vertex color emissive lighting mode handling --- components/nifosg/nifloader.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 015e90f702..4a024132ce 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -2345,7 +2345,7 @@ namespace NifOsg auto setBin_Traversal = [](osg::StateSet* ss) { ss->setRenderBinDetails(2, "TraversalOrderBin"); }; auto setBin_Inherit = [](osg::StateSet* ss) { ss->setRenderBinToInherit(); }; - int lightmode = 1; + auto lightmode = Nif::NiVertexColorProperty::LightMode::LightMode_EmiAmbDif; float emissiveMult = 1.f; float specStrength = 1.f; @@ -2401,7 +2401,8 @@ namespace NifOsg } case Nif::NiVertexColorProperty::VertexMode::VertMode_SrcAmbDif: { - switch (vertprop->mLightingMode) + lightmode = vertprop->mLightingMode; + switch (lightmode) { case Nif::NiVertexColorProperty::LightMode::LightMode_Emissive: { @@ -2524,7 +2525,7 @@ namespace NifOsg if (mVersion <= Nif::NIFFile::VER_MW || !specEnabled) mat->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4f(0.f, 0.f, 0.f, 0.f)); - if (lightmode == 0) + if (lightmode == Nif::NiVertexColorProperty::LightMode::LightMode_Emissive) { osg::Vec4f diffuse = mat->getDiffuse(osg::Material::FRONT_AND_BACK); diffuse = osg::Vec4f(0, 0, 0, diffuse.a());