Files
UnrealEngineUWP/Engine/Shaders/Private/SlatePostProcessColorDeficiencyPixelShader.usf
benjamin rouveyrol 2aff3c61c3 Fix color deficiency filter (CDF) with HDR
The current problem is that the CDF is not taking into account PLATFORM_SUPPORTS_RENDERTARGET_WRITE_MASK and was only applying the filter to the UI rendertarget.

If the fix was applied inside FSlatePostProcessor::ColorDeficiency, we'd have to add support for PLATFORM_SUPPORTS_RENDERTARGET_WRITE_MASK, call FRenderTargetWriteMask::Decode, and add additional copies in order to apply the filter to both the HDR and SDR targets.

Since we apply the color deficiency filter at the end of FSlateRHIRenderingPolicy::DrawElements, we can apply the CDF inside the composition pass in HDR instead. We need to be careful to apply it to the whole screen now instead of relying on CompositeUIMask, but it's still cheaper and simpler than doing all the copies / processing I mentionned above

#preflight 633483c53041fbb5662179d5 6334aaafb946208fc1c009d8 6334aad31b5c12202432c6ba
#rb eric.renaudhoude
#jira UE-165414

[CL 22260598 by benjamin rouveyrol in ue5-main branch]
2022-09-29 20:26:27 -04:00

28 lines
954 B
Plaintext

// Copyright Epic Games, Inc. All Rights Reserved.
#include "Common.ush"
#include "SlateShaderCommon.ush"
#include "GammaCorrectionCommon.ush"
#include "ColorSpace.ush"
#include "ColorDeficiency.ush"
Texture2D ElementTexture;
SamplerState ElementTextureSampler;
float ColorVisionDeficiencyType;
float ColorVisionDeficiencySeverity;
float bCorrectDeficiency;
float bSimulateCorrectionWithDeficiency;
float4 ColorDeficiencyMain(FScreenVertexOutput Input) : SV_Target0
{
float4 SourceColor = Texture2DSample(ElementTexture, ElementTextureSampler, Input.UV);
// Have to convert to linear color space first - so they say, but it doesn't appear to matter much.
//SourceColor.rgb = sRGBToLinear(SourceColor.rgb);
float3 OutRGB = ColorDeficiency(SourceColor.rgb, ColorVisionDeficiencyType, ColorVisionDeficiencySeverity, bCorrectDeficiency, bSimulateCorrectionWithDeficiency);
//OutRGB = LinearToSrgb(OutRGB);
return float4(OutRGB, SourceColor.a);
}