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:
parent
606a795a54
commit
79577f37de
12 changed files with 44 additions and 52 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#version 120
|
||||
|
||||
#include "openmw_vertex.h.glsl"
|
||||
|
||||
#if @useUBO
|
||||
#extension GL_ARB_uniform_buffer_object : require
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#version 120
|
||||
|
||||
#include "openmw_vertex.h.glsl"
|
||||
|
||||
#if @useUBO
|
||||
#extension GL_ARB_uniform_buffer_object : require
|
||||
#endif
|
||||
|
|
|
@ -23,13 +23,3 @@ vec4 mw_viewStereoAdjust(vec4 pos)
|
|||
{
|
||||
return pos;
|
||||
}
|
||||
|
||||
mat4 mw_viewMatrix()
|
||||
{
|
||||
return gl_ModelViewMatrix;
|
||||
}
|
||||
|
||||
mat4 mw_projectionMatrix()
|
||||
{
|
||||
return projectionMatrix;
|
||||
}
|
||||
|
|
|
@ -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);
|
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#version 120
|
||||
|
||||
#include "openmw_vertex.h.glsl"
|
||||
|
||||
#if @useUBO
|
||||
#extension GL_ARB_uniform_buffer_object : require
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#version 120
|
||||
|
||||
#include "openmw_fragment.h.glsl"
|
||||
|
||||
#if @useUBO
|
||||
#extension GL_ARB_uniform_buffer_object : require
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue