|
|
|
@ -52,8 +52,8 @@ namespace
|
|
|
|
|
class GlowUpdater : public SceneUtil::StateSetUpdater
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
GlowUpdater(osg::Vec4f color, const std::vector<osg::ref_ptr<osg::Texture2D> >& textures)
|
|
|
|
|
: mTexUnit(1) // FIXME: might not always be 1
|
|
|
|
|
GlowUpdater(int texUnit, osg::Vec4f color, const std::vector<osg::ref_ptr<osg::Texture2D> >& textures)
|
|
|
|
|
: mTexUnit(texUnit)
|
|
|
|
|
, mColor(color)
|
|
|
|
|
, mTextures(textures)
|
|
|
|
|
{
|
|
|
|
@ -1055,17 +1055,27 @@ namespace MWRender
|
|
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Image> image = mResourceSystem->getImageManager()->getImage(stream.str());
|
|
|
|
|
osg::ref_ptr<osg::Texture2D> tex (new osg::Texture2D(image));
|
|
|
|
|
tex->setName("envMap");
|
|
|
|
|
tex->setWrap(osg::Texture::WRAP_S, osg::Texture2D::REPEAT);
|
|
|
|
|
tex->setWrap(osg::Texture::WRAP_T, osg::Texture2D::REPEAT);
|
|
|
|
|
mResourceSystem->getSceneManager()->applyFilterSettings(tex);
|
|
|
|
|
textures.push_back(tex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
osg::ref_ptr<GlowUpdater> glowupdater (new GlowUpdater(glowColor, textures));
|
|
|
|
|
int texUnit = 1; // FIXME: might not always be 1
|
|
|
|
|
osg::ref_ptr<GlowUpdater> glowupdater (new GlowUpdater(texUnit, glowColor, textures));
|
|
|
|
|
node->addUpdateCallback(glowupdater);
|
|
|
|
|
|
|
|
|
|
// TODO: regenerate shader
|
|
|
|
|
// allowedToModifyStatesets = false
|
|
|
|
|
// set a texture now so that the ShaderVisitor can find it
|
|
|
|
|
osg::ref_ptr<osg::StateSet> writableStateSet = NULL;
|
|
|
|
|
if (!node->getStateSet())
|
|
|
|
|
writableStateSet = node->getOrCreateStateSet();
|
|
|
|
|
else
|
|
|
|
|
writableStateSet = osg::clone(node->getStateSet(), osg::CopyOp::SHALLOW_COPY);
|
|
|
|
|
writableStateSet->setTextureAttributeAndModes(texUnit, textures.front(), osg::StateAttribute::ON);
|
|
|
|
|
writableStateSet->addUniform(new osg::Uniform("envMapColor", glowColor));
|
|
|
|
|
|
|
|
|
|
mResourceSystem->getSceneManager()->recreateShaders(node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: Should not be here
|
|
|
|
|