1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-30 07:15:34 +00:00

Rebase artifacts + cleaned up the remaining unnecessary exposures of stereo awareness.

This commit is contained in:
madsbuvi 2022-04-29 17:35:24 +02:00
parent 606a795a54
commit 79577f37de
12 changed files with 44 additions and 52 deletions

View file

@ -21,6 +21,7 @@
#include <osgParticle/Particle>
#include <components/misc/rng.hpp>
#include <components/stereo/stereomanager.hpp>
#include <components/resource/scenemanager.hpp>
#include <components/resource/imagemanager.hpp>
@ -602,6 +603,38 @@ namespace MWRender
}
}
class SkyMultiviewStatesetUpdater: public SceneUtil::StateSetUpdater
{
public:
SkyMultiviewStatesetUpdater()
{
}
protected:
virtual void setDefaults(osg::StateSet* stateset)
{
stateset->addUniform(new osg::Uniform(osg::Uniform::FLOAT_MAT4, "viewMatrixMultiView", 2), osg::StateAttribute::OVERRIDE);
}
virtual void apply(osg::StateSet* stateset, osg::NodeVisitor* /*nv*/)
{
auto* viewMatrixMultiViewUniform = stateset->getUniform("viewMatrixMultiView");
auto& sm = Stereo::Manager::instance();
for (int view : {0, 1})
{
auto viewOffsetMatrix = sm.computeEyeViewOffset(view);
for (int col : {0, 1, 2})
viewOffsetMatrix(3, col) = 0;
viewMatrixMultiViewUniform->setElement(view, viewOffsetMatrix);
}
}
private:
};
CameraRelativeTransform::CameraRelativeTransform()
{
// Culling works in node-local space, not in camera space, so we can't cull this node correctly
@ -610,6 +643,7 @@ namespace MWRender
setCullingActive(false);
addCullCallback(new CameraRelativeTransformCullCallback);
addCullCallback(new SkyMultiviewStatesetUpdater);
}
CameraRelativeTransform::CameraRelativeTransform(const CameraRelativeTransform& copy, const osg::CopyOp& copyop)

View file

@ -406,6 +406,11 @@ namespace Stereo
return mViewMatrix[view];
}
osg::Matrixd Manager::computeEyeViewOffset(int view) const
{
return mViewOffsetMatrix[view];
}
Eye Manager::getEye(const osgUtil::CullVisitor* cv) const
{
if (cv->getIdentifier() == mIdentifierMain)

View file

@ -70,6 +70,7 @@ namespace Stereo
osg::Matrixd computeEyeProjection(int view, bool reverseZ) const;
osg::Matrixd computeEyeView(int view) const;
osg::Matrixd computeEyeViewOffset(int view) const;
//! Sets up any definitions necessary for stereo rendering
void shaderStereoDefines(Shader::ShaderManager::DefineMap& defines) const;

View file

@ -1,7 +1,5 @@
#version 120
#include "openmw_vertex.h.glsl"
#if @useUBO
#extension GL_ARB_uniform_buffer_object : require
#endif
@ -146,7 +144,7 @@ void main(void)
if (length(gl_ModelViewMatrix * vec4(position, 1.0)) > @groundcoverFadeEnd)
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
else
gl_Position = mw_viewToClip(mw_viewStereoAdjust(viewPos));
gl_Position = mw_viewToClip(viewPos);
linearDepth = getLinearDepth(gl_Position.z, viewPos.z);

View file

@ -1,7 +1,5 @@
#version 120
#include "openmw_vertex.h.glsl"
#if @useUBO
#extension GL_ARB_uniform_buffer_object : require
#endif

View file

@ -1,7 +1,5 @@
#version 120
#include "openmw_vertex.h.glsl"
#if @useUBO
#extension GL_ARB_uniform_buffer_object : require
#endif

View file

@ -23,13 +23,3 @@ vec4 mw_viewStereoAdjust(vec4 pos)
{
return pos;
}
mat4 mw_viewMatrix()
{
return gl_ModelViewMatrix;
}
mat4 mw_projectionMatrix()
{
return projectionMatrix;
}

View file

@ -4,6 +4,4 @@
vec4 mw_modelToClip(vec4 pos);
vec4 mw_modelToView(vec4 pos);
vec4 mw_viewToClip(vec4 pos);
vec4 mw_viewStereoAdjust(vec4 pos);
mat4 mw_viewMatrix();
mat4 mw_projectionMatrix();
vec4 mw_viewStereoAdjust(vec4 pos);

View file

@ -22,20 +22,10 @@ vec4 mw_modelToView(vec4 pos)
vec4 mw_viewToClip(vec4 pos)
{
return projectionMatrixMultiView[gl_ViewID_OVR] * pos;
return projectionMatrixMultiView[gl_ViewID_OVR] * viewMatrixMultiView[gl_ViewID_OVR] * pos;
}
vec4 mw_viewStereoAdjust(vec4 pos)
{
return viewMatrixMultiView[gl_ViewID_OVR] * pos;
}
mat4 mw_viewMatrix()
{
return viewMatrixMultiView[gl_ViewID_OVR] * gl_ModelViewMatrix;
}
mat4 mw_projectionMatrix()
{
return projectionMatrixMultiView[gl_ViewID_OVR];
}

View file

@ -2,8 +2,6 @@
#include "openmw_vertex.h.glsl"
#include "openmw_vertex.h.glsl"
#include "skypasses.glsl"
uniform int pass;
@ -11,23 +9,9 @@ uniform int pass;
varying vec4 passColor;
varying vec2 diffuseMapUV;
mat4 selectModelViewMatrix()
{
#if @useOVR_multiview
mat4 viewOffsetMatrix = mw_viewMatrix();
// Sky geometries aren't actually all that distant. So delete view translation to keep them looking distant.
viewOffsetMatrix[3][0] = 0;
viewOffsetMatrix[3][1] = 0;
viewOffsetMatrix[3][2] = 0;
return viewOffsetMatrix;
#else
return gl_ModelViewMatrix;
#endif
}
void main()
{
gl_Position = mw_viewToClip(selectModelViewMatrix() * gl_Vertex);
gl_Position = mw_modelToClip(gl_Vertex);
passColor = gl_Color;
if (pass == PASS_CLOUDS)

View file

@ -1,7 +1,5 @@
#version 120
#include "openmw_vertex.h.glsl"
#if @useUBO
#extension GL_ARB_uniform_buffer_object : require
#endif

View file

@ -1,7 +1,5 @@
#version 120
#include "openmw_fragment.h.glsl"
#if @useUBO
#extension GL_ARB_uniform_buffer_object : require
#endif