Enable particle lighting

c++11
scrawl 10 years ago
parent 68e322f969
commit 0a411cbd7c

@ -1067,6 +1067,9 @@ namespace MWRender
parentNode = found->second;
}
osg::ref_ptr<osg::Node> node = mResourceSystem->getSceneManager()->createInstance(model, parentNode);
node->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
params.mObjects = PartHolderPtr(new PartHolder(node));
SceneUtil::FindMaxControllerLengthVisitor findMaxLengthVisitor;

@ -6,9 +6,6 @@
#include <osg/Geometry>
#include <osg/Array>
#include <osg/ShapeDrawable>
#include <osg/ComputeBoundsVisitor>
// resource
#include <components/misc/stringops.hpp>
#include <components/misc/resourcehelpers.hpp>
@ -862,7 +859,15 @@ namespace NifOsg
collectMaterialProperties(nifNode, materialProps);
applyMaterialProperties(geode, materialProps, true, animflags);
partsys->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
// Particles don't have normals, so can't be diffuse lit.
osg::Material* mat = static_cast<osg::Material*>(geode->getStateSet()->getAttribute(osg::StateAttribute::MATERIAL));
if (mat)
{
osg::Vec4f diffuse = mat->getDiffuse(osg::Material::FRONT_AND_BACK);
mat->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4f(0,0,0,diffuse.a()));
mat->setColorMode(osg::Material::AMBIENT);
}
partsys->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
// particle system updater (after the emitters and affectors in the scene graph)

Loading…
Cancel
Save