mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 22:51:20 +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
|
// the depth texture
|
||||||
uniform sampler2D depthTexture;
|
uniform sampler2D depthTexture;
|
||||||
|
|
||||||
// the normal texture
|
|
||||||
uniform sampler2D normalTexture;
|
|
||||||
|
|
||||||
// the random rotation texture
|
// the random rotation texture
|
||||||
uniform sampler2D rotationTexture;
|
uniform sampler2D rotationTexture;
|
||||||
|
|
||||||
|
@ -60,11 +57,10 @@ vec3 texCoordToViewSpace(vec2 texCoord) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec3 rotationZ = texture2D(normalTexture, gl_TexCoord[0].st).xyz * 2.0 - vec3(1.0, 1.0, 1.0);
|
vec3 rotationX = texture2D(rotationTexture, gl_TexCoord[0].st * noiseScale).rgb;
|
||||||
vec3 rotationY = normalize(cross(rotationZ, texture2D(rotationTexture,
|
vec3 rotationY = normalize(cross(rotationX, vec3(0.0, 0.0, 1.0)));
|
||||||
gl_TexCoord[0].st * noiseScale).xyz - vec3(0.5, 0.5, 0.5)));
|
mat3 rotation = mat3(rotationX, rotationY, cross(rotationX, rotationY));
|
||||||
mat3 rotation = mat3(cross(rotationY, rotationZ), rotationY, rotationZ);
|
|
||||||
|
|
||||||
vec3 center = texCoordToViewSpace(gl_TexCoord[0].st);
|
vec3 center = texCoordToViewSpace(gl_TexCoord[0].st);
|
||||||
|
|
||||||
vec2 rdenominator = 1.0 / (rightTop - leftBottom);
|
vec2 rdenominator = 1.0 / (rightTop - leftBottom);
|
||||||
|
|
|
@ -51,8 +51,7 @@ void AmbientOcclusionEffect::init() {
|
||||||
|
|
||||||
_occlusionProgram->bind();
|
_occlusionProgram->bind();
|
||||||
_occlusionProgram->setUniformValue("depthTexture", 0);
|
_occlusionProgram->setUniformValue("depthTexture", 0);
|
||||||
_occlusionProgram->setUniformValue("normalTexture", 1);
|
_occlusionProgram->setUniformValue("rotationTexture", 1);
|
||||||
_occlusionProgram->setUniformValue("rotationTexture", 2);
|
|
||||||
_occlusionProgram->setUniformValueArray("sampleKernel", sampleKernel, SAMPLE_KERNEL_SIZE);
|
_occlusionProgram->setUniformValueArray("sampleKernel", sampleKernel, SAMPLE_KERNEL_SIZE);
|
||||||
_occlusionProgram->setUniformValue("radius", 0.1f);
|
_occlusionProgram->setUniformValue("radius", 0.1f);
|
||||||
_occlusionProgram->release();
|
_occlusionProgram->release();
|
||||||
|
@ -102,9 +101,6 @@ void AmbientOcclusionEffect::render() {
|
||||||
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryDepthTextureID());
|
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryDepthTextureID());
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryNormalTextureID());
|
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE2);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, _rotationTextureID);
|
glBindTexture(GL_TEXTURE_2D, _rotationTextureID);
|
||||||
|
|
||||||
// render with the occlusion shader to the secondary/tertiary buffer
|
// render with the occlusion shader to the secondary/tertiary buffer
|
||||||
|
@ -142,9 +138,6 @@ void AmbientOcclusionEffect::render() {
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
// now render secondary to primary with 4x4 blur
|
// now render secondary to primary with 4x4 blur
|
||||||
|
|
Loading…
Reference in a new issue