mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 23:40:11 +02:00
Attempting to fix 3DTV/Oculus deferred lighting/ambient occlusion.
This commit is contained in:
parent
c5ad603321
commit
2cba7b37bf
5 changed files with 48 additions and 1 deletions
|
@ -2971,7 +2971,14 @@ void Application::getProjectionMatrix(glm::dmat4* projectionMatrix) {
|
||||||
void Application::computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
|
void Application::computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
|
||||||
float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const {
|
float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const {
|
||||||
|
|
||||||
|
// allow 3DTV/Oculus to override parameters from camera
|
||||||
_viewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
|
_viewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
|
||||||
|
if (OculusManager::isConnected()) {
|
||||||
|
OculusManager::overrideOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
|
||||||
|
|
||||||
|
} else if (TV3DManager::isConnected()) {
|
||||||
|
TV3DManager::overrideOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {
|
glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {
|
||||||
|
|
|
@ -53,6 +53,7 @@ unsigned int OculusManager::_frameIndex = 0;
|
||||||
bool OculusManager::_frameTimingActive = false;
|
bool OculusManager::_frameTimingActive = false;
|
||||||
bool OculusManager::_programInitialized = false;
|
bool OculusManager::_programInitialized = false;
|
||||||
Camera* OculusManager::_camera = NULL;
|
Camera* OculusManager::_camera = NULL;
|
||||||
|
int OculusManager::_activeEyeIndex = -1;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -330,6 +331,8 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p
|
||||||
|
|
||||||
//Render each eye into an fbo
|
//Render each eye into an fbo
|
||||||
for (int eyeIndex = 0; eyeIndex < ovrEye_Count; eyeIndex++) {
|
for (int eyeIndex = 0; eyeIndex < ovrEye_Count; eyeIndex++) {
|
||||||
|
_activeEyeIndex = eyeIndex;
|
||||||
|
|
||||||
#if defined(__APPLE__) || defined(_WIN32)
|
#if defined(__APPLE__) || defined(_WIN32)
|
||||||
ovrEyeType eye = _ovrHmd->EyeRenderOrder[eyeIndex];
|
ovrEyeType eye = _ovrHmd->EyeRenderOrder[eyeIndex];
|
||||||
#else
|
#else
|
||||||
|
@ -363,6 +366,7 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p
|
||||||
Application::getInstance()->displaySide(*_camera);
|
Application::getInstance()->displaySide(*_camera);
|
||||||
|
|
||||||
applicationOverlay.displayOverlayTextureOculus(*_camera);
|
applicationOverlay.displayOverlayTextureOculus(*_camera);
|
||||||
|
_activeEyeIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Wait till time-warp to reduce latency
|
//Wait till time-warp to reduce latency
|
||||||
|
@ -528,3 +532,16 @@ QSize OculusManager::getRenderTargetSize() {
|
||||||
return QSize(100, 100);
|
return QSize(100, 100);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OculusManager::overrideOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
|
||||||
|
float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) {
|
||||||
|
#ifdef HAVE_LIBOVR
|
||||||
|
if (_activeEyeIndex != -1) {
|
||||||
|
float extent = nearVal * glm::tan(_eyeRenderDesc[_activeEyeIndex].Fov / 2.0f);
|
||||||
|
right = extent;
|
||||||
|
left = -extent;
|
||||||
|
top = extent;
|
||||||
|
bottom = -extent;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
|
@ -43,6 +43,9 @@ public:
|
||||||
static glm::vec3 getRelativePosition();
|
static glm::vec3 getRelativePosition();
|
||||||
static QSize getRenderTargetSize();
|
static QSize getRenderTargetSize();
|
||||||
|
|
||||||
|
static void overrideOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
|
||||||
|
float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef HAVE_LIBOVR
|
#ifdef HAVE_LIBOVR
|
||||||
static void generateDistortionMesh();
|
static void generateDistortionMesh();
|
||||||
|
@ -92,6 +95,7 @@ private:
|
||||||
static bool _frameTimingActive;
|
static bool _frameTimingActive;
|
||||||
static bool _programInitialized;
|
static bool _programInitialized;
|
||||||
static Camera* _camera;
|
static Camera* _camera;
|
||||||
|
static int _activeEyeIndex;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ int TV3DManager::_screenHeight = 1;
|
||||||
double TV3DManager::_aspect = 1.0;
|
double TV3DManager::_aspect = 1.0;
|
||||||
eyeFrustum TV3DManager::_leftEye;
|
eyeFrustum TV3DManager::_leftEye;
|
||||||
eyeFrustum TV3DManager::_rightEye;
|
eyeFrustum TV3DManager::_rightEye;
|
||||||
|
eyeFrustum* TV3DManager::_activeEye = NULL;
|
||||||
|
|
||||||
|
|
||||||
bool TV3DManager::isConnected() {
|
bool TV3DManager::isConnected() {
|
||||||
|
@ -111,7 +112,7 @@ void TV3DManager::display(Camera& whichCamera) {
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
{
|
{
|
||||||
|
_activeEye = &_leftEye;
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity(); // reset projection matrix
|
glLoadIdentity(); // reset projection matrix
|
||||||
glFrustum(_leftEye.left, _leftEye.right, _leftEye.bottom, _leftEye.top, nearZ, farZ); // set left view frustum
|
glFrustum(_leftEye.left, _leftEye.right, _leftEye.bottom, _leftEye.top, nearZ, farZ); // set left view frustum
|
||||||
|
@ -128,6 +129,7 @@ void TV3DManager::display(Camera& whichCamera) {
|
||||||
if (displayOverlays) {
|
if (displayOverlays) {
|
||||||
applicationOverlay.displayOverlayTexture3DTV(whichCamera, _aspect, fov);
|
applicationOverlay.displayOverlayTexture3DTV(whichCamera, _aspect, fov);
|
||||||
}
|
}
|
||||||
|
_activeEye = NULL;
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
@ -140,6 +142,7 @@ void TV3DManager::display(Camera& whichCamera) {
|
||||||
glScissor(portalX, portalY, portalW, portalH);
|
glScissor(portalX, portalY, portalW, portalH);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
{
|
{
|
||||||
|
_activeEye = &_rightEye;
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity(); // reset projection matrix
|
glLoadIdentity(); // reset projection matrix
|
||||||
glFrustum(_rightEye.left, _rightEye.right, _rightEye.bottom, _rightEye.top, nearZ, farZ); // set left view frustum
|
glFrustum(_rightEye.left, _rightEye.right, _rightEye.bottom, _rightEye.top, nearZ, farZ); // set left view frustum
|
||||||
|
@ -156,6 +159,7 @@ void TV3DManager::display(Camera& whichCamera) {
|
||||||
if (displayOverlays) {
|
if (displayOverlays) {
|
||||||
applicationOverlay.displayOverlayTexture3DTV(whichCamera, _aspect, fov);
|
applicationOverlay.displayOverlayTexture3DTV(whichCamera, _aspect, fov);
|
||||||
}
|
}
|
||||||
|
_activeEye = NULL;
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
@ -166,3 +170,13 @@ void TV3DManager::display(Camera& whichCamera) {
|
||||||
|
|
||||||
Application::getInstance()->getGlowEffect()->render();
|
Application::getInstance()->getGlowEffect()->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TV3DManager::overrideOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
|
||||||
|
float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) {
|
||||||
|
if (_activeEye) {
|
||||||
|
left = _activeEye->left;
|
||||||
|
right = _activeEye->right;
|
||||||
|
bottom = _activeEye->bottom;
|
||||||
|
top = _activeEye->top;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
class Camera;
|
class Camera;
|
||||||
|
|
||||||
struct eyeFrustum {
|
struct eyeFrustum {
|
||||||
|
@ -32,6 +34,8 @@ public:
|
||||||
static bool isConnected();
|
static bool isConnected();
|
||||||
static void configureCamera(Camera& camera, int screenWidth, int screenHeight);
|
static void configureCamera(Camera& camera, int screenWidth, int screenHeight);
|
||||||
static void display(Camera& whichCamera);
|
static void display(Camera& whichCamera);
|
||||||
|
static void overrideOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
|
||||||
|
float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane);
|
||||||
private:
|
private:
|
||||||
static void setFrustum(Camera& whichCamera);
|
static void setFrustum(Camera& whichCamera);
|
||||||
static int _screenWidth;
|
static int _screenWidth;
|
||||||
|
@ -39,6 +43,7 @@ private:
|
||||||
static double _aspect;
|
static double _aspect;
|
||||||
static eyeFrustum _leftEye;
|
static eyeFrustum _leftEye;
|
||||||
static eyeFrustum _rightEye;
|
static eyeFrustum _rightEye;
|
||||||
|
static eyeFrustum* _activeEye;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_TV3DManager_h
|
#endif // hifi_TV3DManager_h
|
||||||
|
|
Loading…
Reference in a new issue