From a0b6a0275c5c521455e843709153ed1d7270435b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 11 Sep 2016 11:09:40 +0200 Subject: [PATCH] Fix random texture sampling bug --- src/gl/renderer/gl_postprocess.cpp | 2 ++ src/gl/renderer/gl_renderbuffers.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 9b791a3f1..f79ab2bf1 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -201,6 +201,8 @@ void FGLRenderer::AmbientOccludeScene() glBindTexture(GL_TEXTURE_2D, mBuffers->AmbientRandomTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glActiveTexture(GL_TEXTURE0); mSSAOShader->Bind(); mSSAOShader->DepthTexture.Set(0); diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp index 9c442ce4e..dec9ab8ed 100644 --- a/src/gl/renderer/gl_renderbuffers.cpp +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -342,10 +342,10 @@ void FGLRenderBuffers::CreateAmbientOcclusion(int width, int height) double z = distribution(generator); double w = distribution(generator); - randomValues[i * 4 + 0] = (int16_t)clamp(x * 32768.0, -32767.0, 32768.0); - randomValues[i * 4 + 1] = (int16_t)clamp(y * 32768.0, -32767.0, 32768.0); - randomValues[i * 4 + 2] = (int16_t)clamp(z * 32768.0, -32767.0, 32768.0); - randomValues[i * 4 + 3] = (int16_t)clamp(w * 32768.0, -32767.0, 32768.0); + randomValues[i * 4 + 0] = (int16_t)clamp(x * 32767.0, -32768.0, 32767.0); + randomValues[i * 4 + 1] = (int16_t)clamp(y * 32767.0, -32768.0, 32767.0); + randomValues[i * 4 + 2] = (int16_t)clamp(z * 32767.0, -32768.0, 32767.0); + randomValues[i * 4 + 3] = (int16_t)clamp(w * 32767.0, -32768.0, 32767.0); } AmbientRandomTexture = Create2DTexture("AmbientRandomTexture", GL_RGBA16_SNORM, 4, 4, randomValues);