Fix random texture sampling bug

This commit is contained in:
Magnus Norddahl 2016-09-11 11:09:40 +02:00
parent 03d0b09f29
commit a0b6a0275c
2 changed files with 6 additions and 4 deletions

View File

@ -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);

View File

@ -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);