1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +00:00

Double buffering the water's node position uniform

This commit is contained in:
Mads Buvik Sandvei 2021-08-14 17:41:58 +00:00 committed by AnyOldName3
parent 4e0e2fb52f
commit d40c18234a
2 changed files with 9 additions and 5 deletions

View File

@ -544,6 +544,11 @@ osg::Node* Water::getRefractionNode()
return mRefraction;
}
osg::Vec3d Water::getPosition() const
{
return mWaterNode->getPosition();
}
void Water::createSimpleWaterStateSet(osg::Node* node, float alpha)
{
osg::ref_ptr<osg::StateSet> stateset = SceneUtil::createSimpleWaterStateSet(alpha, MWRender::RenderBin_Water);
@ -620,6 +625,7 @@ public:
depth->setWriteMask(false);
stateset->setAttributeAndModes(depth, osg::StateAttribute::ON);
}
stateset->addUniform(new osg::Uniform("nodePosition", osg::Vec3f(mWater->getPosition())));
}
void apply(osg::StateSet* stateset, osg::NodeVisitor* nv) override
@ -632,6 +638,7 @@ public:
stateset->setTextureAttributeAndModes(2, mRefraction->getColorTexture(cv), osg::StateAttribute::ON);
stateset->setTextureAttributeAndModes(3, mRefraction->getDepthTexture(cv), osg::StateAttribute::ON);
}
stateset->getUniform("nodePosition")->set(osg::Vec3f(mWater->getPosition()));
}
private:
@ -728,11 +735,6 @@ void Water::changeCell(const MWWorld::CellStore* store)
}
if(mInterior != wasInterior && mReflection)
mReflection->setInterior(mInterior);
// create a new StateSet to prevent threading issues
osg::ref_ptr<osg::StateSet> nodeStateSet (new osg::StateSet);
nodeStateSet->addUniform(new osg::Uniform("nodePosition", osg::Vec3f(mWaterNode->getPosition())));
mWaterNode->setStateSet(nodeStateSet);
}
void Water::setHeight(const float height)

View File

@ -120,6 +120,8 @@ namespace MWRender
osg::Node* getReflectionNode();
osg::Node* getRefractionNode();
osg::Vec3d getPosition() const;
void processChangedSettings(const Settings::CategorySettingVector& settings);
};