mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-06 10:15:33 +00:00
Cherry pick 'openmw-48-stereo-fixes' into 'master'
Openmw 48 stereo fixes See merge request OpenMW/openmw!2815
This commit is contained in:
parent
efebb8efd8
commit
e37860c1dc
5 changed files with 21 additions and 27 deletions
|
@ -566,7 +566,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);
|
||||
}
|
||||
|
||||
|
|
|
@ -140,8 +140,7 @@ namespace MWRender
|
|||
private:
|
||||
osg::Matrixf getEyeProjectionMatrix(int view)
|
||||
{
|
||||
return Stereo::Manager::instance().computeEyeViewOffset(view)
|
||||
* Stereo::Manager::instance().computeEyeProjection(view, SceneUtil::AutoDepth::isReversed());
|
||||
return Stereo::Manager::instance().computeEyeProjection(view, SceneUtil::AutoDepth::isReversed());
|
||||
}
|
||||
|
||||
osg::Matrixf mProjectionMatrix;
|
||||
|
|
|
@ -630,7 +630,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;
|
||||
|
@ -645,23 +645,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:
|
||||
|
|
|
@ -67,16 +67,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:
|
||||
|
@ -239,18 +237,24 @@ 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; }
|
||||
osg::Matrixd computeLeftEyeView(const osg::Matrixd& view) const override
|
||||
{
|
||||
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; }
|
||||
osg::Matrixd computeRightEyeView(const osg::Matrixd& view) const override
|
||||
{
|
||||
return view * mManager->computeEyeViewOffset(1);
|
||||
}
|
||||
|
||||
Manager* mManager;
|
||||
};
|
||||
|
@ -351,8 +355,7 @@ namespace Stereo
|
|||
}
|
||||
}
|
||||
|
||||
mFrustumManager->update(
|
||||
{ mViewOffsetMatrix[0] * mProjectionMatrix[0], mViewOffsetMatrix[1] * mProjectionMatrix[1] });
|
||||
mFrustumManager->update({ mProjectionMatrix[0], mProjectionMatrix[1] });
|
||||
}
|
||||
|
||||
void Manager::updateMultiviewStateset(osg::StateSet* stateset)
|
||||
|
|
Loading…
Reference in a new issue