mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-12 10:52:32 +02:00
Fix for ambient occlusion in 3DTV mode.
This commit is contained in:
parent
38a04b53d2
commit
e76a8c2234
2 changed files with 5 additions and 16 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);
|
||||
|
|
|
@ -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