forked from teamnwah/openmw-tes3coop
fix water shader switching bug
This commit is contained in:
parent
8a1e0e74fd
commit
a7cad65aab
3 changed files with 14 additions and 9 deletions
|
@ -1548,14 +1548,19 @@ void SkyManager::update(float duration)
|
||||||
{
|
{
|
||||||
if (!mEnabled)
|
if (!mEnabled)
|
||||||
{
|
{
|
||||||
|
if (mRainIntensityUniform)
|
||||||
mRainIntensityUniform->set((float) 0.0);
|
mRainIntensityUniform->set((float) 0.0);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mRainIntensityUniform)
|
||||||
|
{
|
||||||
if (mIsStorm || (!hasRain() && !mParticleNode))
|
if (mIsStorm || (!hasRain() && !mParticleNode))
|
||||||
mRainIntensityUniform->set((float) 0.0);
|
mRainIntensityUniform->set((float) 0.0);
|
||||||
else
|
else
|
||||||
mRainIntensityUniform->set((float) mWeatherAlpha);
|
mRainIntensityUniform->set((float) mWeatherAlpha);
|
||||||
|
}
|
||||||
|
|
||||||
if (mIsStorm)
|
if (mIsStorm)
|
||||||
{
|
{
|
||||||
|
|
|
@ -416,13 +416,14 @@ Water::Water(osg::Group *parent, osg::Group* sceneRoot, Resource::ResourceSystem
|
||||||
|
|
||||||
setHeight(mTop);
|
setHeight(mTop);
|
||||||
|
|
||||||
mRainIntensityUniform = NULL;
|
|
||||||
updateWaterMaterial();
|
updateWaterMaterial();
|
||||||
|
|
||||||
|
mRainIntensityUniform = new osg::Uniform("rainIntensity",(float) 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Uniform *Water::getRainIntensityUniform()
|
osg::Uniform *Water::getRainIntensityUniform()
|
||||||
{
|
{
|
||||||
return mRainIntensityUniform;
|
return mRainIntensityUniform.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Water::updateWaterMaterial()
|
void Water::updateWaterMaterial()
|
||||||
|
@ -556,7 +557,6 @@ void Water::createShaderWaterStateSet(osg::Node* node, Reflection* reflection, R
|
||||||
program->addShader(fragmentShader);
|
program->addShader(fragmentShader);
|
||||||
shaderStateset->setAttributeAndModes(program, osg::StateAttribute::ON);
|
shaderStateset->setAttributeAndModes(program, osg::StateAttribute::ON);
|
||||||
|
|
||||||
mRainIntensityUniform = new osg::Uniform("rainIntensity",(float) 0.0);
|
|
||||||
shaderStateset->addUniform(mRainIntensityUniform);
|
shaderStateset->addUniform(mRainIntensityUniform);
|
||||||
|
|
||||||
node->setStateSet(shaderStateset);
|
node->setStateSet(shaderStateset);
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace MWRender
|
||||||
{
|
{
|
||||||
static const int CELL_SIZE = 8192;
|
static const int CELL_SIZE = 8192;
|
||||||
|
|
||||||
osg::Uniform* mRainIntensityUniform;
|
osg::ref_ptr<osg::Uniform> mRainIntensityUniform;
|
||||||
|
|
||||||
osg::ref_ptr<osg::Group> mParent;
|
osg::ref_ptr<osg::Group> mParent;
|
||||||
osg::ref_ptr<osg::Group> mSceneRoot;
|
osg::ref_ptr<osg::Group> mSceneRoot;
|
||||||
|
|
Loading…
Reference in a new issue