Used previous projection matrix to limit overblur

This commit is contained in:
Olivier Prat 2018-04-17 11:28:59 +02:00
parent 89669b326b
commit 08146a7618
7 changed files with 21 additions and 10 deletions

View file

@ -38,6 +38,9 @@ void DeferredFrameTransform::update(RenderArgs* args) {
args->getViewFrustum().evalProjectionMatrix(frameTransformBuffer.projectionMono);
frameTransformBuffer.previousProjection[0] = frameTransformBuffer.projection[0];
frameTransformBuffer.previousProjection[1] = frameTransformBuffer.projection[1];
// Running in stereo ?
bool isStereo = args->isStereo();
if (!isStereo) {

View file

@ -43,11 +43,14 @@ protected:
glm::vec4 depthInfo;
// Stereo info is { isStereoFrame, halfWidth }
glm::vec4 stereoInfo{ 0.0 };
// Mono proj matrix or Left and Right proj matrix going from Mono Eye space to side clip space
glm::mat4 projection[2];
// Inverse proj matrix or Left and Right proj matrix going from Mono Eye space to side clip space
glm::mat4 invProjection[2];
// THe mono projection for sure
// Mono proj matrix or Left and Right proj matrix going from Mono Eye space to side clip space
glm::mat4 projection[2];
// Inverse proj matrix or Left and Right proj matrix going from Mono Eye space to side clip space
glm::mat4 invProjection[2];
// Mono proj matrix or Left and Right proj matrix going from Mono Eye space to side clip space of
// the previous frame
glm::mat4 previousProjection[2];
// THe mono projection for sure
glm::mat4 projectionMono;
// Inv View matrix from eye space (mono) to world space
glm::mat4 invView;

View file

@ -32,6 +32,7 @@ struct DeferredFrameTransform {
vec4 _stereoInfo;
mat4 _projection[2];
mat4 _invProjection[2];
mat4 _previousProjection[2];
mat4 _projectionMono;
mat4 _viewInverse;
mat4 _view;

View file

@ -11,8 +11,6 @@
<@if not MODEL_MATERIAL_TEXTURES_SLH@>
<@def MODEL_MATERIAL_TEXTURES_SLH@>
#define TAA_TEXTURE_LOD_BIAS -1.0
<@func declareMaterialTexMapArrayBuffer()@>
const int MAX_TEXCOORDS = 2;
@ -49,6 +47,8 @@ TexMapArray getTexMapArray() {
<@func declareMaterialTextures(withAlbedo, withRoughness, withNormal, withMetallic, withEmissive, withOcclusion, withScattering)@>
#define TAA_TEXTURE_LOD_BIAS -1.0
<@include gpu/TextureTable.slh@>
#ifdef GPU_TEXTURE_TABLE_BINDLESS

View file

@ -15,6 +15,8 @@
<@include gpu/Color.slh@>
<@include DeferredBufferWrite.slh@>
#define TAA_TEXTURE_LOD_BIAS -1.0
// the albedo texture
uniform sampler2D originalTexture;
@ -24,7 +26,7 @@ in vec4 _color;
in vec2 _texCoord0;
void main(void) {
vec4 texel = texture(originalTexture, _texCoord0.st);
vec4 texel = texture(originalTexture, _texCoord0.st, TAA_TEXTURE_LOD_BIAS);
texel = color_sRGBAToLinear(texel);
packDeferredFragmentUnlit(normalize(_normal), 1.0, _color.rgb * texel.rgb);
}

View file

@ -15,6 +15,8 @@
<@include gpu/Color.slh@>
<@include DeferredBufferWrite.slh@>
#define TAA_TEXTURE_LOD_BIAS -1.0
// the albedo texture
uniform sampler2D originalTexture;
@ -24,7 +26,7 @@ in vec4 _color;
in vec2 _texCoord0;
void main(void) {
vec4 texel = texture(originalTexture, _texCoord0.st);
vec4 texel = texture(originalTexture, _texCoord0.st, TAA_TEXTURE_LOD_BIAS);
texel = color_sRGBAToLinear(texel);
packDeferredFragmentTranslucent(
normalize(_normal),

View file

@ -32,7 +32,7 @@ void main(void) {
vec3 worldPos = (getViewInverse() * vec4(eyePos, 1.0)).xyz;
vec3 prevEyePos = (getPreviousView() * vec4(worldPos, 1.0)).xyz;
vec4 prevClipPos = (frameTransform._projection[stereoSide.x] * vec4(prevEyePos, 1.0));
vec4 prevClipPos = (frameTransform._previousProjection[stereoSide.x] * vec4(prevEyePos, 1.0));
vec2 prevUV = 0.5 * (prevClipPos.xy / prevClipPos.w) + vec2(0.5);
//vec2 imageSize = getWidthHeight(0);