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:
parent
4e0e2fb52f
commit
d40c18234a
@ -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)
|
||||
|
@ -120,6 +120,8 @@ namespace MWRender
|
||||
osg::Node* getReflectionNode();
|
||||
osg::Node* getRefractionNode();
|
||||
|
||||
osg::Vec3d getPosition() const;
|
||||
|
||||
void processChangedSettings(const Settings::CategorySettingVector& settings);
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user