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