mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 03:35:27 +00:00
Render the water plane with GL_DEPTH_CLAMP if supported (Fixes #996)
This commit is contained in:
parent
802620a86b
commit
4690ec12cc
@ -13,6 +13,7 @@
|
|||||||
#include <osg/MatrixTransform>
|
#include <osg/MatrixTransform>
|
||||||
#include <osg/FrontFace>
|
#include <osg/FrontFace>
|
||||||
#include <osg/Shader>
|
#include <osg/Shader>
|
||||||
|
#include <osg/GLExtensions>
|
||||||
|
|
||||||
#include <osgDB/ReadFile>
|
#include <osgDB/ReadFile>
|
||||||
|
|
||||||
@ -389,6 +390,24 @@ private:
|
|||||||
osg::ref_ptr<osg::Node> mScene;
|
osg::ref_ptr<osg::Node> mScene;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// DepthClampCallback enables GL_DEPTH_CLAMP for the current draw, if supported.
|
||||||
|
class DepthClampCallback : public osg::Drawable::DrawCallback
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void drawImplementation(osg::RenderInfo& renderInfo,const osg::Drawable* drawable) const
|
||||||
|
{
|
||||||
|
if (!osg::isGLExtensionOrVersionSupported(renderInfo.getState()->getContextID(), "GL_ARB_depth_clamp", 3.3))
|
||||||
|
drawable->drawImplementation(renderInfo);
|
||||||
|
|
||||||
|
glEnable(GL_DEPTH_CLAMP);
|
||||||
|
|
||||||
|
drawable->drawImplementation(renderInfo);
|
||||||
|
|
||||||
|
// restore default
|
||||||
|
glDisable(GL_DEPTH_CLAMP);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Water::Water(osg::Group *parent, osg::Group* sceneRoot, Resource::ResourceSystem *resourceSystem, osgUtil::IncrementalCompileOperation *ico,
|
Water::Water(osg::Group *parent, osg::Group* sceneRoot, Resource::ResourceSystem *resourceSystem, osgUtil::IncrementalCompileOperation *ico,
|
||||||
const MWWorld::Fallback* fallback, const std::string& resourcePath)
|
const MWWorld::Fallback* fallback, const std::string& resourcePath)
|
||||||
: mParent(parent)
|
: mParent(parent)
|
||||||
@ -402,6 +421,7 @@ Water::Water(osg::Group *parent, osg::Group* sceneRoot, Resource::ResourceSystem
|
|||||||
mSimulation.reset(new RippleSimulation(parent, resourceSystem, fallback));
|
mSimulation.reset(new RippleSimulation(parent, resourceSystem, fallback));
|
||||||
|
|
||||||
osg::ref_ptr<osg::Geometry> waterGeom = createWaterGeometry(CELL_SIZE*150, 40, 900);
|
osg::ref_ptr<osg::Geometry> waterGeom = createWaterGeometry(CELL_SIZE*150, 40, 900);
|
||||||
|
waterGeom->setDrawCallback(new DepthClampCallback);
|
||||||
|
|
||||||
mWaterGeode = new osg::Geode;
|
mWaterGeode = new osg::Geode;
|
||||||
mWaterGeode->addDrawable(waterGeom);
|
mWaterGeode->addDrawable(waterGeom);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user