Merge branch 'openmw-48-stereo-fixes' into 'openmw-48'

Openmw 48 stereo fixes

See merge request OpenMW/openmw!2815
backport_gl_clamp_removal
psi29a 1 year ago
commit fb3a80bebd

@ -560,7 +560,7 @@ OSG_ARCHIVE="OSGoS-3.6.5-dd803bc-msvc${OSG_MSVC_YEAR}-win${BITS}"
OSG_ARCHIVE_REPO_URL="https://gitlab.com/OpenMW/openmw-deps/-/raw/main"
if ! [ -z $OSG_MULTIVIEW_BUILD ]; then
OSG_ARCHIVE_NAME="OSG-3.6-multiview"
OSG_ARCHIVE="OSG-3.6-multiview-ee297dce0-msvc${OSG_MSVC_YEAR}-win${BITS}"
OSG_ARCHIVE="OSG-3.6-multiview-d2ee5aa8-msvc${OSG_MSVC_YEAR}-win${BITS}"
OSG_ARCHIVE_REPO_URL="https://gitlab.com/madsbuvi/openmw-deps/-/raw/openmw-vr-ovr_multiview"
fi

@ -47,7 +47,7 @@ namespace MWRender
auto& sm = Stereo::Manager::instance();
auto view = sm.getEye(cv);
int index = view == Stereo::Eye::Right ? 1 : 0;
auto projectionMatrix = sm.computeEyeViewOffset(index) * sm.computeEyeProjection(index, true);
auto projectionMatrix = sm.computeEyeProjection(index, true);
postProcessor->getStateUpdater()->setProjectionMatrix(projectionMatrix);
}

@ -118,14 +118,14 @@ namespace MWRender
{
auto* uProjectionMatrix = stateset->getUniform("projectionMatrix");
if (uProjectionMatrix)
uProjectionMatrix->set(Stereo::Manager::instance().computeEyeViewOffset(0) * Stereo::Manager::instance().computeEyeProjection(0, SceneUtil::AutoDepth::isReversed()));
uProjectionMatrix->set(Stereo::Manager::instance().computeEyeProjection(0, SceneUtil::AutoDepth::isReversed()));
}
void applyRight(osg::StateSet* stateset, osgUtil::CullVisitor* nv) override
{
auto* uProjectionMatrix = stateset->getUniform("projectionMatrix");
if (uProjectionMatrix)
uProjectionMatrix->set(Stereo::Manager::instance().computeEyeViewOffset(1) * Stereo::Manager::instance().computeEyeProjection(1, SceneUtil::AutoDepth::isReversed()));
uProjectionMatrix->set(Stereo::Manager::instance().computeEyeProjection(1, SceneUtil::AutoDepth::isReversed()));
}
void setProjectionMatrix(const osg::Matrixf& projectionMatrix)

@ -629,7 +629,7 @@ namespace MWRender
for (int view : {0, 1})
{
auto projectionMatrix = sm.computeEyeProjection(view, true);
auto projectionMatrix = sm.computeEyeProjection(view, SceneUtil::AutoDepth::isReversed());
auto viewOffsetMatrix = sm.computeEyeViewOffset(view);
for (int col : {0, 1, 2})
viewOffsetMatrix(3, col) = 0;
@ -644,23 +644,15 @@ namespace MWRender
{
auto& sm = Stereo::Manager::instance();
auto* projectionMatrixUniform = stateset->getUniform("projectionMatrix");
auto projectionMatrix = sm.computeEyeProjection(0, true);
auto viewOffsetMatrix = sm.computeEyeViewOffset(0);
for (int col : {0, 1, 2})
viewOffsetMatrix(3, col) = 0;
projectionMatrixUniform->set(viewOffsetMatrix * projectionMatrix);
auto projectionMatrix = sm.computeEyeProjection(0, SceneUtil::AutoDepth::isReversed());
projectionMatrixUniform->set(projectionMatrix);
}
void applyRight(osg::StateSet* stateset, osgUtil::CullVisitor* /*cv*/) override
{
auto& sm = Stereo::Manager::instance();
auto* projectionMatrixUniform = stateset->getUniform("projectionMatrix");
auto projectionMatrix = sm.computeEyeProjection(1, true);
auto viewOffsetMatrix = sm.computeEyeViewOffset(1);
for (int col : {0, 1, 2})
viewOffsetMatrix(3, col) = 0;
projectionMatrixUniform->set(viewOffsetMatrix * projectionMatrix);
auto projectionMatrix = sm.computeEyeProjection(1, SceneUtil::AutoDepth::isReversed());
projectionMatrixUniform->set(projectionMatrix);
}
private:

@ -71,14 +71,14 @@ namespace Stereo
{
auto* uProjectionMatrix = stateset->getUniform("projectionMatrix");
if (uProjectionMatrix)
uProjectionMatrix->set(mManager->computeEyeViewOffset(0) * mManager->computeEyeProjection(0, SceneUtil::AutoDepth::isReversed()));
uProjectionMatrix->set(mManager->computeEyeProjection(0, SceneUtil::AutoDepth::isReversed()));
}
void applyRight(osg::StateSet* stateset, osgUtil::CullVisitor* nv) override
{
auto* uProjectionMatrix = stateset->getUniform("projectionMatrix");
if (uProjectionMatrix)
uProjectionMatrix->set(mManager->computeEyeViewOffset(1) * mManager->computeEyeProjection(1, SceneUtil::AutoDepth::isReversed()));
uProjectionMatrix->set(mManager->computeEyeProjection(1, SceneUtil::AutoDepth::isReversed()));
}
private:
@ -245,23 +245,23 @@ namespace Stereo
osg::Matrixd computeLeftEyeProjection(const osg::Matrixd& projection) const override
{
(void)projection;
return mManager->computeEyeViewOffset(0) * mManager->computeEyeProjection(0, false);
return mManager->computeEyeProjection(0, false);
}
osg::Matrixd computeLeftEyeView(const osg::Matrixd& view) const override
{
return view;
return view * mManager->computeEyeViewOffset(0);
}
osg::Matrixd computeRightEyeProjection(const osg::Matrixd& projection) const override
{
(void)projection;
return mManager->computeEyeViewOffset(1) * mManager->computeEyeProjection(1, false);
return mManager->computeEyeProjection(1, false);
}
osg::Matrixd computeRightEyeView(const osg::Matrixd& view) const override
{
return view;
return view * mManager->computeEyeViewOffset(1);
}
Manager* mManager;
@ -368,8 +368,8 @@ namespace Stereo
mFrustumManager->update(
{
mViewOffsetMatrix[0] * mProjectionMatrix[0],
mViewOffsetMatrix[1] * mProjectionMatrix[1]
mProjectionMatrix[0],
mProjectionMatrix[1]
});
}

Loading…
Cancel
Save