From c69a311ad83a9c4046a6131118738911d6e620f3 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 19 Jun 2014 04:57:46 +0200 Subject: [PATCH] Disable lighting for particles Fixes magic cast visuals being too dark depending on the environment. --- components/nifogre/material.cpp | 10 +++++++++- components/nifogre/material.hpp | 2 +- components/nifogre/ogrenifloader.cpp | 5 ++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/components/nifogre/material.cpp b/components/nifogre/material.cpp index 3a87e1d52..b1ae83107 100644 --- a/components/nifogre/material.cpp +++ b/components/nifogre/material.cpp @@ -106,7 +106,7 @@ Ogre::String NIFMaterialLoader::getMaterial(const Nif::ShapeData *shapedata, const Nif::NiZBufferProperty *zprop, const Nif::NiSpecularProperty *specprop, const Nif::NiWireframeProperty *wireprop, - bool &needTangents) + bool &needTangents, bool disableLighting) { Ogre::MaterialManager &matMgr = Ogre::MaterialManager::getSingleton(); Ogre::MaterialPtr material = matMgr.getByName(name); @@ -245,6 +245,14 @@ Ogre::String NIFMaterialLoader::getMaterial(const Nif::ShapeData *shapedata, } } + if (disableLighting) + { + ambient = Ogre::Vector3(0.f); + diffuse = Ogre::Vector3(0.f); + specular = Ogre::Vector3(0.f); + emissive = Ogre::Vector3(1.f); + } + { // Generate a hash out of all properties that can affect the material. size_t h = 0; diff --git a/components/nifogre/material.hpp b/components/nifogre/material.hpp index b02c7c236..890255dcc 100644 --- a/components/nifogre/material.hpp +++ b/components/nifogre/material.hpp @@ -49,7 +49,7 @@ public: const Nif::NiZBufferProperty *zprop, const Nif::NiSpecularProperty *specprop, const Nif::NiWireframeProperty *wireprop, - bool &needTangents); + bool &needTangents, bool disableLighting=false); }; } diff --git a/components/nifogre/ogrenifloader.cpp b/components/nifogre/ogrenifloader.cpp index 36d750821..813c1660d 100644 --- a/components/nifogre/ogrenifloader.cpp +++ b/components/nifogre/ogrenifloader.cpp @@ -850,7 +850,10 @@ class NIFObjectLoader partsys->setMaterialName(NIFMaterialLoader::getMaterial(particledata, fullname, group, texprop, matprop, alphaprop, vertprop, zprop, specprop, - wireprop, needTangents)); + wireprop, needTangents, + // MW doesn't light particles, but the MaterialProperty + // used still has lighting, so that must be ignored. + true)); partsys->setCullIndividually(false); partsys->setParticleQuota(particledata->numParticles);