mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-26 23:10:24 +00:00
Glowupdater fix when using shaders
This commit is contained in:
parent
9b2cb2fb8c
commit
4b9aff7a03
2 changed files with 38 additions and 38 deletions
|
@ -1182,8 +1182,8 @@ namespace MWRender
|
||||||
int mLowestUnusedTexUnit;
|
int mLowestUnusedTexUnit;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Animation::addSpellCastGlow(const ESM::MagicEffect *effect){
|
void Animation::addSpellCastGlow(const ESM::MagicEffect *effect)
|
||||||
|
{
|
||||||
osg::Vec4f glowColor(1,1,1,1);
|
osg::Vec4f glowColor(1,1,1,1);
|
||||||
glowColor.x() = effect->mData.mRed / 255.f;
|
glowColor.x() = effect->mData.mRed / 255.f;
|
||||||
glowColor.y() = effect->mData.mGreen / 255.f;
|
glowColor.y() = effect->mData.mGreen / 255.f;
|
||||||
|
@ -1197,6 +1197,20 @@ namespace MWRender
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation::addGlow(osg::ref_ptr<osg::Node> node, osg::Vec4f glowColor, float glowDuration)
|
void Animation::addGlow(osg::ref_ptr<osg::Node> node, osg::Vec4f glowColor, float glowDuration)
|
||||||
|
{
|
||||||
|
if (mGlowUpdater && mGlowUpdater->isDone())
|
||||||
|
node->removeUpdateCallback(mGlowUpdater);
|
||||||
|
|
||||||
|
FindLowestUnusedTexUnitVisitor findLowestUnusedTexUnitVisitor;
|
||||||
|
node->accept(findLowestUnusedTexUnitVisitor);
|
||||||
|
int texUnit = findLowestUnusedTexUnitVisitor.mLowestUnusedTexUnit;
|
||||||
|
|
||||||
|
if (mGlowUpdater && mGlowUpdater->isPermanentGlowUpdater())
|
||||||
|
{
|
||||||
|
mGlowUpdater->setColor(glowColor);
|
||||||
|
mGlowUpdater->setDuration(glowDuration);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
std::vector<osg::ref_ptr<osg::Texture2D> > textures;
|
std::vector<osg::ref_ptr<osg::Texture2D> > textures;
|
||||||
for (int i=0; i<32; ++i)
|
for (int i=0; i<32; ++i)
|
||||||
|
@ -1217,24 +1231,10 @@ namespace MWRender
|
||||||
textures.push_back(tex);
|
textures.push_back(tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mGlowUpdater && mGlowUpdater->isDone())
|
|
||||||
node->removeUpdateCallback(mGlowUpdater);
|
|
||||||
|
|
||||||
FindLowestUnusedTexUnitVisitor findLowestUnusedTexUnitVisitor;
|
|
||||||
node->accept(findLowestUnusedTexUnitVisitor);
|
|
||||||
int texUnit = findLowestUnusedTexUnitVisitor.mLowestUnusedTexUnit;
|
|
||||||
|
|
||||||
if (mGlowUpdater && mGlowUpdater->isPermanentGlowUpdater())
|
|
||||||
{
|
|
||||||
mGlowUpdater->setColor(glowColor);
|
|
||||||
mGlowUpdater->setDuration(glowDuration);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
osg::ref_ptr<GlowUpdater> glowUpdater = new GlowUpdater(texUnit, glowColor, textures, node, glowDuration, mResourceSystem);
|
osg::ref_ptr<GlowUpdater> glowUpdater = new GlowUpdater(texUnit, glowColor, textures, node, glowDuration, mResourceSystem);
|
||||||
mGlowUpdater = glowUpdater;
|
mGlowUpdater = glowUpdater;
|
||||||
node->addUpdateCallback(glowUpdater);
|
node->addUpdateCallback(glowUpdater);
|
||||||
}
|
|
||||||
|
|
||||||
// set a texture now so that the ShaderVisitor can find it
|
// set a texture now so that the ShaderVisitor can find it
|
||||||
osg::ref_ptr<osg::StateSet> writableStateSet = NULL;
|
osg::ref_ptr<osg::StateSet> writableStateSet = NULL;
|
||||||
|
@ -1247,9 +1247,9 @@ namespace MWRender
|
||||||
}
|
}
|
||||||
writableStateSet->setTextureAttributeAndModes(texUnit, textures.front(), osg::StateAttribute::ON);
|
writableStateSet->setTextureAttributeAndModes(texUnit, textures.front(), osg::StateAttribute::ON);
|
||||||
writableStateSet->addUniform(new osg::Uniform("envMapColor", glowColor));
|
writableStateSet->addUniform(new osg::Uniform("envMapColor", glowColor));
|
||||||
|
|
||||||
mResourceSystem->getSceneManager()->recreateShaders(node);
|
mResourceSystem->getSceneManager()->recreateShaders(node);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Should not be here
|
// TODO: Should not be here
|
||||||
osg::Vec4f Animation::getEnchantmentColor(const MWWorld::ConstPtr& item) const
|
osg::Vec4f Animation::getEnchantmentColor(const MWWorld::ConstPtr& item) const
|
||||||
|
|
Loading…
Reference in a new issue