fix water shader switching bug

new-script-api
Miloslav Číž 7 years ago
parent 8a1e0e74fd
commit a7cad65aab

@ -1548,14 +1548,19 @@ void SkyManager::update(float duration)
{
if (!mEnabled)
{
mRainIntensityUniform->set((float) 0.0);
if (mRainIntensityUniform)
mRainIntensityUniform->set((float) 0.0);
return;
}
if (mIsStorm || (!hasRain() && !mParticleNode))
mRainIntensityUniform->set((float) 0.0);
else
mRainIntensityUniform->set((float) mWeatherAlpha);
if (mRainIntensityUniform)
{
if (mIsStorm || (!hasRain() && !mParticleNode))
mRainIntensityUniform->set((float) 0.0);
else
mRainIntensityUniform->set((float) mWeatherAlpha);
}
if (mIsStorm)
{

@ -416,13 +416,14 @@ Water::Water(osg::Group *parent, osg::Group* sceneRoot, Resource::ResourceSystem
setHeight(mTop);
mRainIntensityUniform = NULL;
updateWaterMaterial();
mRainIntensityUniform = new osg::Uniform("rainIntensity",(float) 0.0);
}
osg::Uniform *Water::getRainIntensityUniform()
{
return mRainIntensityUniform;
return mRainIntensityUniform.get();
}
void Water::updateWaterMaterial()
@ -556,7 +557,6 @@ void Water::createShaderWaterStateSet(osg::Node* node, Reflection* reflection, R
program->addShader(fragmentShader);
shaderStateset->setAttributeAndModes(program, osg::StateAttribute::ON);
mRainIntensityUniform = new osg::Uniform("rainIntensity",(float) 0.0);
shaderStateset->addUniform(mRainIntensityUniform);
node->setStateSet(shaderStateset);

@ -51,7 +51,7 @@ namespace MWRender
{
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> mSceneRoot;

Loading…
Cancel
Save