From e76a8c2234c886fc7a87ed3444c505493177ef1e Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Mon, 3 Nov 2014 17:36:10 -0800 Subject: [PATCH] Fix for ambient occlusion in 3DTV mode. --- interface/resources/shaders/ambient_occlusion.frag | 12 ++++-------- interface/src/renderer/AmbientOcclusionEffect.cpp | 9 +-------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/interface/resources/shaders/ambient_occlusion.frag b/interface/resources/shaders/ambient_occlusion.frag index 621b123966..512922ca43 100644 --- a/interface/resources/shaders/ambient_occlusion.frag +++ b/interface/resources/shaders/ambient_occlusion.frag @@ -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); diff --git a/interface/src/renderer/AmbientOcclusionEffect.cpp b/interface/src/renderer/AmbientOcclusionEffect.cpp index 33a0b6e77d..f75ed7e8c3 100644 --- a/interface/src/renderer/AmbientOcclusionEffect.cpp +++ b/interface/src/renderer/AmbientOcclusionEffect.cpp @@ -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