mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
Merge pull request #3728 from ey6es/master
Fix for lights/shadows on Oculus, as well as a couple fixes for 3DTV mode.
This commit is contained in:
commit
2a84149d15
4 changed files with 17 additions and 26 deletions
|
@ -14,9 +14,6 @@
|
|||
// the depth texture
|
||||
uniform sampler2D depthTexture;
|
||||
|
||||
// the normal texture
|
||||
uniform sampler2D normalTexture;
|
||||
|
||||
// the random rotation texture
|
||||
uniform sampler2D rotationTexture;
|
||||
|
||||
|
@ -60,11 +57,10 @@ vec3 texCoordToViewSpace(vec2 texCoord) {
|
|||
}
|
||||
|
||||
void main(void) {
|
||||
vec3 rotationZ = texture2D(normalTexture, gl_TexCoord[0].st).xyz * 2.0 - vec3(1.0, 1.0, 1.0);
|
||||
vec3 rotationY = normalize(cross(rotationZ, texture2D(rotationTexture,
|
||||
gl_TexCoord[0].st * noiseScale).xyz - vec3(0.5, 0.5, 0.5)));
|
||||
mat3 rotation = mat3(cross(rotationY, rotationZ), rotationY, rotationZ);
|
||||
|
||||
vec3 rotationX = texture2D(rotationTexture, gl_TexCoord[0].st * noiseScale).rgb;
|
||||
vec3 rotationY = normalize(cross(rotationX, vec3(0.0, 0.0, 1.0)));
|
||||
mat3 rotation = mat3(rotationX, rotationY, cross(rotationX, rotationY));
|
||||
|
||||
vec3 center = texCoordToViewSpace(gl_TexCoord[0].st);
|
||||
|
||||
vec2 rdenominator = 1.0 / (rightTop - leftBottom);
|
||||
|
|
|
@ -420,7 +420,7 @@ void OculusManager::endFrameTiming() {
|
|||
//Sets the camera FoV and aspect ratio
|
||||
void OculusManager::configureCamera(Camera& camera, int screenWidth, int screenHeight) {
|
||||
#ifdef HAVE_LIBOVR
|
||||
camera.setAspectRatio(_renderTargetSize.w / _renderTargetSize.h);
|
||||
camera.setAspectRatio((float)_renderTargetSize.w / _renderTargetSize.h);
|
||||
camera.setFieldOfView(atan(_eyeFov[0].UpTan) * DEGREES_PER_RADIAN * 2.0f);
|
||||
#endif
|
||||
}
|
||||
|
@ -511,12 +511,13 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p
|
|||
|
||||
_camera->update(1.0f / Application::getInstance()->getFps());
|
||||
|
||||
Matrix4f proj = ovrMatrix4f_Projection(_eyeRenderDesc[eye].Fov, whichCamera.getNearClip(), whichCamera.getFarClip(), true);
|
||||
proj.Transpose();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glLoadMatrixf((GLfloat *)proj.M);
|
||||
|
||||
const ovrFovPort& port = _eyeFov[_activeEyeIndex];
|
||||
float nearClip = whichCamera.getNearClip(), farClip = whichCamera.getFarClip();
|
||||
glFrustum(-nearClip * port.LeftTan, nearClip * port.RightTan, -nearClip * port.DownTan,
|
||||
nearClip * port.UpTan, nearClip, farClip);
|
||||
|
||||
glViewport(_eyeRenderViewport[eye].Pos.x, _eyeRenderViewport[eye].Pos.y,
|
||||
_eyeRenderViewport[eye].Size.w, _eyeRenderViewport[eye].Size.h);
|
||||
|
||||
|
|
|
@ -91,8 +91,10 @@ void TV3DManager::display(Camera& whichCamera) {
|
|||
// left eye portal
|
||||
int portalX = 0;
|
||||
int portalY = 0;
|
||||
int portalW = Application::getInstance()->getGLWidget()->getDeviceWidth() / 2;
|
||||
int portalH = Application::getInstance()->getGLWidget()->getDeviceHeight();
|
||||
QSize deviceSize = Application::getInstance()->getGLWidget()->getDeviceSize() *
|
||||
Application::getInstance()->getRenderResolutionScale();
|
||||
int portalW = deviceSize.width() / 2;
|
||||
int portalH = deviceSize.height();
|
||||
|
||||
ApplicationOverlay& applicationOverlay = Application::getInstance()->getApplicationOverlay();
|
||||
|
||||
|
@ -135,7 +137,7 @@ void TV3DManager::display(Camera& whichCamera) {
|
|||
glDisable(GL_SCISSOR_TEST);
|
||||
|
||||
// render right side view
|
||||
portalX = Application::getInstance()->getGLWidget()->getDeviceWidth() / 2;
|
||||
portalX = deviceSize.width() / 2;
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
// render left side view
|
||||
glViewport(portalX, portalY, portalW, portalH);
|
||||
|
@ -165,8 +167,7 @@ void TV3DManager::display(Camera& whichCamera) {
|
|||
glDisable(GL_SCISSOR_TEST);
|
||||
|
||||
// reset the viewport to how we started
|
||||
glViewport(0, 0, Application::getInstance()->getGLWidget()->getDeviceWidth(),
|
||||
Application::getInstance()->getGLWidget()->getDeviceHeight());
|
||||
glViewport(0, 0, deviceSize.width(), deviceSize.height());
|
||||
|
||||
Application::getInstance()->getGlowEffect()->render();
|
||||
}
|
||||
|
|
|
@ -51,8 +51,7 @@ void AmbientOcclusionEffect::init() {
|
|||
|
||||
_occlusionProgram->bind();
|
||||
_occlusionProgram->setUniformValue("depthTexture", 0);
|
||||
_occlusionProgram->setUniformValue("normalTexture", 1);
|
||||
_occlusionProgram->setUniformValue("rotationTexture", 2);
|
||||
_occlusionProgram->setUniformValue("rotationTexture", 1);
|
||||
_occlusionProgram->setUniformValueArray("sampleKernel", sampleKernel, SAMPLE_KERNEL_SIZE);
|
||||
_occlusionProgram->setUniformValue("radius", 0.1f);
|
||||
_occlusionProgram->release();
|
||||
|
@ -102,9 +101,6 @@ void AmbientOcclusionEffect::render() {
|
|||
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryDepthTextureID());
|
||||
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryNormalTextureID());
|
||||
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, _rotationTextureID);
|
||||
|
||||
// render with the occlusion shader to the secondary/tertiary buffer
|
||||
|
@ -142,9 +138,6 @@ void AmbientOcclusionEffect::render() {
|
|||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
// now render secondary to primary with 4x4 blur
|
||||
|
|
Loading…
Reference in a new issue