1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2026-01-30 01:38:57 +00:00

Offsets reflection/refraction clip plane based on camera height and FOV

This commit is contained in:
Qlonever 2023-04-11 21:03:28 -04:00 committed by elsid
parent 7628c23750
commit b7ba58c8f2
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625

View file

@ -111,9 +111,11 @@ namespace MWRender
}
// 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);
unsigned int fov = Settings::Manager::getInt("field of view", "Camera");
const float clipFudge = 2.5; // minimum offset of clip plane
const float clipFudgeScale = 1.0; // additional offset of clip plane when standing at shore level with default FOV
float clipOffset = abs(abs((*mCullPlane)[3]) - eyePoint.z()) * (clipFudgeScale * fov / (-7500.0)) - clipFudge;
modelViewMatrix->preMultTranslate(mCullPlane->getNormal() * clipOffset);
cv->pushModelViewMatrix(modelViewMatrix, osg::Transform::RELATIVE_RF);
traverse(node, cv);
cv->popModelViewMatrix();