Fix yellowish artifacts due to quantization error in TAA and composite image output
#3318 #3254
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a430a05bdfa8476cc742748d5406e9c8c80a7e1ed00f392947b8c88cdf7cd176
|
||||
size 23062
|
||||
oid sha256:17fc5977b0e82aea17310dad1a93745fd923ebc920b74ee29a55afb909275e56
|
||||
size 23340
|
||||
|
||||
BIN
Content/Shaders/TAA.flax
(Stored with Git LFS)
BIN
Content/Shaders/TAA.flax
(Stored with Git LFS)
Binary file not shown.
@@ -6,10 +6,10 @@
|
||||
#include "Engine/Graphics/GPUContext.h"
|
||||
#include "Engine/Graphics/RenderTargetPool.h"
|
||||
#include "Engine/Graphics/RenderBuffers.h"
|
||||
#include "Engine/Graphics/RenderTask.h"
|
||||
#include "Engine/Renderer/RenderList.h"
|
||||
#include "Engine/Renderer/GBufferPass.h"
|
||||
#include "Engine/Engine/Engine.h"
|
||||
#include "Engine/Graphics/RenderTools.h"
|
||||
|
||||
GPU_CB_STRUCT(Data {
|
||||
Float2 ScreenSizeInv;
|
||||
@@ -18,6 +18,8 @@ GPU_CB_STRUCT(Data {
|
||||
float StationaryBlending;
|
||||
float MotionBlending;
|
||||
float Dummy0;
|
||||
Float3 QuantizationError;
|
||||
float Dummy1;
|
||||
ShaderGBufferData GBuffer;
|
||||
});
|
||||
|
||||
@@ -122,6 +124,7 @@ void TAA::Render(const RenderContext& renderContext, GPUTexture* input, GPUTextu
|
||||
data.Sharpness = settings.TAA_Sharpness;
|
||||
data.StationaryBlending = settings.TAA_StationaryBlending * blendStrength;
|
||||
data.MotionBlending = settings.TAA_MotionBlending * blendStrength;
|
||||
data.QuantizationError = RenderTools::GetColorQuantizationError(tempDesc.Format);
|
||||
GBufferPass::SetInputs(renderContext.View, data.GBuffer);
|
||||
const auto cb = _shader->GetShader()->GetCB(0);
|
||||
context->UpdateCB(cb, &data);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "Engine/Content/Content.h"
|
||||
#include "Engine/Graphics/Graphics.h"
|
||||
#include "Engine/Graphics/GPUContext.h"
|
||||
#include "Engine/Graphics/RenderTask.h"
|
||||
#include "Engine/Graphics/RenderTools.h"
|
||||
#include "Engine/Graphics/RenderTargetPool.h"
|
||||
#include "Engine/Engine/Time.h"
|
||||
|
||||
@@ -58,6 +58,9 @@ GPU_CB_STRUCT(Data{
|
||||
|
||||
Color ScreenFadeColor;
|
||||
|
||||
Float3 QuantizationError;
|
||||
float Dummy2;
|
||||
|
||||
Matrix LensFlareStarMat;
|
||||
});
|
||||
|
||||
@@ -359,6 +362,7 @@ void PostProcessingPass::Render(RenderContext& renderContext, GPUTexture* input,
|
||||
data.LensFlareIntensity = 0;
|
||||
data.LensDirtIntensity = 0;
|
||||
}
|
||||
data.QuantizationError = RenderTools::GetColorQuantizationError(output->Format());
|
||||
data.PostExposure = Math::Exp2(settings.EyeAdaptation.PostExposure);
|
||||
data.InputSize = Float2(static_cast<float>(w1), static_cast<float>(h1));
|
||||
data.InvInputSize = Float2(1.0f / static_cast<float>(w1), 1.0f / static_cast<float>(h1));
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "./Flax/Common.hlsl"
|
||||
#include "./Flax/Random.hlsl"
|
||||
#include "./Flax/Noise.hlsl"
|
||||
#include "./Flax/GammaCorrectionCommon.hlsl"
|
||||
|
||||
#define GB_RADIUS 6
|
||||
@@ -80,6 +81,9 @@ float LensDirtIntensity;
|
||||
|
||||
float4 ScreenFadeColor;
|
||||
|
||||
float3 QuantizationError;
|
||||
float Dummy2;
|
||||
|
||||
float4x4 LensFlareStarMat;
|
||||
|
||||
META_CB_END
|
||||
@@ -738,6 +742,10 @@ float4 PS_Composite(Quad_VS2PS input) : SV_Target
|
||||
// Saturate color since it will be rendered to the screen
|
||||
color.rgb = saturate(color.rgb);
|
||||
|
||||
// Apply quantization error to reduce yellowish artifacts due to R11G11B10 format
|
||||
float noise = rand2dTo1d(input.TexCoord);
|
||||
color.rgb = QuantizeColor(color.rgb, noise, QuantizationError);
|
||||
|
||||
// Return final pixel color (preserve input alpha)
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "./Flax/Common.hlsl"
|
||||
#include "./Flax/GBuffer.hlsl"
|
||||
#include "./Flax/Noise.hlsl"
|
||||
|
||||
META_CB_BEGIN(0, Data)
|
||||
float2 ScreenSizeInv;
|
||||
@@ -13,6 +14,8 @@ float Sharpness;
|
||||
float StationaryBlending;
|
||||
float MotionBlending;
|
||||
float Dummy0;
|
||||
float3 QuantizationError;
|
||||
float Dummy1;
|
||||
GBufferData GBuffer;
|
||||
META_CB_END
|
||||
|
||||
@@ -104,5 +107,10 @@ float4 PS(Quad_VS2PS input) : SV_Target0
|
||||
color = lerp(color, neighborhoodSharp, saturate(miss));
|
||||
|
||||
color = clamp(color, 0, HDR_CLAMP_MAX);
|
||||
|
||||
// Apply quantization error to reduce yellowish artifacts due to R11G11B10 format
|
||||
float noise = rand2dTo1d(input.TexCoord);
|
||||
color.rgb = QuantizeColor(color.rgb, noise, QuantizationError);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user