mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-31 03: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 <osgParticle/Particle>
|
||||||
|
|
||||||
#include <components/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
#include <components/stereo/stereomanager.hpp>
|
||||||
|
|
||||||
#include <components/resource/scenemanager.hpp>
|
#include <components/resource/scenemanager.hpp>
|
||||||
#include <components/resource/imagemanager.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()
|
CameraRelativeTransform::CameraRelativeTransform()
|
||||||
{
|
{
|
||||||
// Culling works in node-local space, not in camera space, so we can't cull this node correctly
|
// 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);
|
setCullingActive(false);
|
||||||
|
|
||||||
addCullCallback(new CameraRelativeTransformCullCallback);
|
addCullCallback(new CameraRelativeTransformCullCallback);
|
||||||
|
addCullCallback(new SkyMultiviewStatesetUpdater);
|
||||||
}
|
}
|
||||||
|
|
||||||
CameraRelativeTransform::CameraRelativeTransform(const CameraRelativeTransform& copy, const osg::CopyOp& copyop)
|
CameraRelativeTransform::CameraRelativeTransform(const CameraRelativeTransform& copy, const osg::CopyOp& copyop)
|
||||||
|
|
|
@ -406,6 +406,11 @@ namespace Stereo
|
||||||
return mViewMatrix[view];
|
return mViewMatrix[view];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
osg::Matrixd Manager::computeEyeViewOffset(int view) const
|
||||||
|
{
|
||||||
|
return mViewOffsetMatrix[view];
|
||||||
|
}
|
||||||
|
|
||||||
Eye Manager::getEye(const osgUtil::CullVisitor* cv) const
|
Eye Manager::getEye(const osgUtil::CullVisitor* cv) const
|
||||||
{
|
{
|
||||||
if (cv->getIdentifier() == mIdentifierMain)
|
if (cv->getIdentifier() == mIdentifierMain)
|
||||||
|
|
|
@ -70,6 +70,7 @@ namespace Stereo
|
||||||
|
|
||||||
osg::Matrixd computeEyeProjection(int view, bool reverseZ) const;
|
osg::Matrixd computeEyeProjection(int view, bool reverseZ) const;
|
||||||
osg::Matrixd computeEyeView(int view) const;
|
osg::Matrixd computeEyeView(int view) const;
|
||||||
|
osg::Matrixd computeEyeViewOffset(int view) const;
|
||||||
|
|
||||||
//! Sets up any definitions necessary for stereo rendering
|
//! Sets up any definitions necessary for stereo rendering
|
||||||
void shaderStereoDefines(Shader::ShaderManager::DefineMap& defines) const;
|
void shaderStereoDefines(Shader::ShaderManager::DefineMap& defines) const;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#version 120
|
#version 120
|
||||||
|
|
||||||
#include "openmw_vertex.h.glsl"
|
|
||||||
|
|
||||||
#if @useUBO
|
#if @useUBO
|
||||||
#extension GL_ARB_uniform_buffer_object : require
|
#extension GL_ARB_uniform_buffer_object : require
|
||||||
#endif
|
#endif
|
||||||
|
@ -146,7 +144,7 @@ void main(void)
|
||||||
if (length(gl_ModelViewMatrix * vec4(position, 1.0)) > @groundcoverFadeEnd)
|
if (length(gl_ModelViewMatrix * vec4(position, 1.0)) > @groundcoverFadeEnd)
|
||||||
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
|
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
|
||||||
else
|
else
|
||||||
gl_Position = mw_viewToClip(mw_viewStereoAdjust(viewPos));
|
gl_Position = mw_viewToClip(viewPos);
|
||||||
|
|
||||||
linearDepth = getLinearDepth(gl_Position.z, viewPos.z);
|
linearDepth = getLinearDepth(gl_Position.z, viewPos.z);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#version 120
|
#version 120
|
||||||
|
|
||||||
#include "openmw_vertex.h.glsl"
|
|
||||||
|
|
||||||
#if @useUBO
|
#if @useUBO
|
||||||
#extension GL_ARB_uniform_buffer_object : require
|
#extension GL_ARB_uniform_buffer_object : require
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#version 120
|
#version 120
|
||||||
|
|
||||||
#include "openmw_vertex.h.glsl"
|
|
||||||
|
|
||||||
#if @useUBO
|
#if @useUBO
|
||||||
#extension GL_ARB_uniform_buffer_object : require
|
#extension GL_ARB_uniform_buffer_object : require
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,13 +23,3 @@ vec4 mw_viewStereoAdjust(vec4 pos)
|
||||||
{
|
{
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
mat4 mw_viewMatrix()
|
|
||||||
{
|
|
||||||
return gl_ModelViewMatrix;
|
|
||||||
}
|
|
||||||
|
|
||||||
mat4 mw_projectionMatrix()
|
|
||||||
{
|
|
||||||
return projectionMatrix;
|
|
||||||
}
|
|
||||||
|
|
|
@ -5,5 +5,3 @@ vec4 mw_modelToClip(vec4 pos);
|
||||||
vec4 mw_modelToView(vec4 pos);
|
vec4 mw_modelToView(vec4 pos);
|
||||||
vec4 mw_viewToClip(vec4 pos);
|
vec4 mw_viewToClip(vec4 pos);
|
||||||
vec4 mw_viewStereoAdjust(vec4 pos);
|
vec4 mw_viewStereoAdjust(vec4 pos);
|
||||||
mat4 mw_viewMatrix();
|
|
||||||
mat4 mw_projectionMatrix();
|
|
|
@ -22,20 +22,10 @@ vec4 mw_modelToView(vec4 pos)
|
||||||
|
|
||||||
vec4 mw_viewToClip(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)
|
vec4 mw_viewStereoAdjust(vec4 pos)
|
||||||
{
|
{
|
||||||
return viewMatrixMultiView[gl_ViewID_OVR] * 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 "openmw_vertex.h.glsl"
|
|
||||||
|
|
||||||
#include "skypasses.glsl"
|
#include "skypasses.glsl"
|
||||||
|
|
||||||
uniform int pass;
|
uniform int pass;
|
||||||
|
@ -11,23 +9,9 @@ uniform int pass;
|
||||||
varying vec4 passColor;
|
varying vec4 passColor;
|
||||||
varying vec2 diffuseMapUV;
|
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()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = mw_viewToClip(selectModelViewMatrix() * gl_Vertex);
|
gl_Position = mw_modelToClip(gl_Vertex);
|
||||||
passColor = gl_Color;
|
passColor = gl_Color;
|
||||||
|
|
||||||
if (pass == PASS_CLOUDS)
|
if (pass == PASS_CLOUDS)
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#version 120
|
#version 120
|
||||||
|
|
||||||
#include "openmw_vertex.h.glsl"
|
|
||||||
|
|
||||||
#if @useUBO
|
#if @useUBO
|
||||||
#extension GL_ARB_uniform_buffer_object : require
|
#extension GL_ARB_uniform_buffer_object : require
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#version 120
|
#version 120
|
||||||
|
|
||||||
#include "openmw_fragment.h.glsl"
|
|
||||||
|
|
||||||
#if @useUBO
|
#if @useUBO
|
||||||
#extension GL_ARB_uniform_buffer_object : require
|
#extension GL_ARB_uniform_buffer_object : require
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue