mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
Water: clipping plane offset
This commit is contained in:
parent
700a0099c3
commit
37c9c12962
2 changed files with 12 additions and 11 deletions
|
@ -142,8 +142,6 @@ class ClipCullNode : public osg::Group
|
||||||
|
|
||||||
osg::Polytope::PlaneList origPlaneList = cv->getProjectionCullingStack().back().getFrustum().getPlaneList();
|
osg::Polytope::PlaneList origPlaneList = cv->getProjectionCullingStack().back().getFrustum().getPlaneList();
|
||||||
|
|
||||||
// TODO: offset plane towards the viewer to fix bleeding at the water shore
|
|
||||||
|
|
||||||
osg::Plane plane = *mCullPlane;
|
osg::Plane plane = *mCullPlane;
|
||||||
plane.transform(*cv->getCurrentRenderStage()->getInitialViewMatrix());
|
plane.transform(*cv->getCurrentRenderStage()->getInitialViewMatrix());
|
||||||
|
|
||||||
|
@ -175,19 +173,22 @@ class ClipCullNode : public osg::Group
|
||||||
{
|
{
|
||||||
osgUtil::CullVisitor* cv = static_cast<osgUtil::CullVisitor*>(nv);
|
osgUtil::CullVisitor* cv = static_cast<osgUtil::CullVisitor*>(nv);
|
||||||
osg::Vec3d eyePoint = cv->getEyePoint();
|
osg::Vec3d eyePoint = cv->getEyePoint();
|
||||||
|
|
||||||
|
osg::RefMatrix* modelViewMatrix = new osg::RefMatrix(*cv->getModelViewMatrix());
|
||||||
|
|
||||||
// flip the below graph if the eye point is above the plane
|
// flip the below graph if the eye point is above the plane
|
||||||
if (mCullPlane->intersect(osg::BoundingSphere(osg::Vec3d(0,0,eyePoint.z()), 0)) > 0)
|
if (mCullPlane->intersect(osg::BoundingSphere(osg::Vec3d(0,0,eyePoint.z()), 0)) > 0)
|
||||||
{
|
{
|
||||||
osg::RefMatrix* modelViewMatrix = new osg::RefMatrix(*cv->getModelViewMatrix());
|
|
||||||
modelViewMatrix->preMultScale(osg::Vec3(1,1,-1));
|
modelViewMatrix->preMultScale(osg::Vec3(1,1,-1));
|
||||||
|
}
|
||||||
|
// move the plane back along its normal a little bit to prevent bleeding at the water shore
|
||||||
|
const float clipFudge = 5;
|
||||||
|
modelViewMatrix->preMultTranslate(mCullPlane->getNormal() * (-clipFudge));
|
||||||
|
|
||||||
cv->pushModelViewMatrix(modelViewMatrix, osg::Transform::RELATIVE_RF);
|
cv->pushModelViewMatrix(modelViewMatrix, osg::Transform::RELATIVE_RF);
|
||||||
traverse(node, nv);
|
traverse(node, nv);
|
||||||
cv->popModelViewMatrix();
|
cv->popModelViewMatrix();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
traverse(node, nv);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const osg::Plane* mCullPlane;
|
const osg::Plane* mCullPlane;
|
||||||
|
|
|
@ -21,8 +21,8 @@ const float WAVE_CHOPPYNESS = 0.05; // wave choppyness
|
||||||
const float WAVE_SCALE = 75.0; // overall wave scale
|
const float WAVE_SCALE = 75.0; // overall wave scale
|
||||||
|
|
||||||
const float BUMP = 0.5; // overall water surface bumpiness
|
const float BUMP = 0.5; // overall water surface bumpiness
|
||||||
const float REFL_BUMP = 0.15; // reflection distortion amount
|
const float REFL_BUMP = 0.10; // reflection distortion amount
|
||||||
const float REFR_BUMP = 0.06; // refraction distortion amount
|
const float REFR_BUMP = 0.07; // refraction distortion amount
|
||||||
|
|
||||||
const float SCATTER_AMOUNT = 0.3; // amount of sunlight scattering
|
const float SCATTER_AMOUNT = 0.3; // amount of sunlight scattering
|
||||||
const vec3 SCATTER_COLOUR = vec3(0.0,1.0,0.95); // colour of sunlight scattering
|
const vec3 SCATTER_COLOUR = vec3(0.0,1.0,0.95); // colour of sunlight scattering
|
||||||
|
|
Loading…
Reference in a new issue