Files
UnrealEngineUWP/Engine/Shaders/Private/PostProcessHistogramReduce.usf
tiago costa 6878643807 Support EyeAdaptationBuffer on every platform.
- Converted EyeAdaptation shaders to output to buffer.
- Updated most PostFX shaders to read from EyeAdaptationBuffer.
- Temporary: Non postfx shaders, plugins, etc still expect a texture so, for compatibility, implemented a CS to copy data from EyeAdaptationBuffer to EyeAdaptationTexture.

#rb Guillaume.Abadie
#preflight 6388d458b36822f1c334e506

[CL 23354265 by tiago costa in ue5-main branch]
2022-12-01 12:02:27 -05:00

48 lines
1.5 KiB
Plaintext

// Copyright Epic Games, Inc. All Rights Reserved.
/*=============================================================================
PostProcessHistogramReduce.usf: PostProcessing combine multiple histograms into a single one
=============================================================================*/
#include "Common.ush"
// How many lines of histograms should be compiled into one
uint LoopSize;
// The last frames eye adaptation settings
StructuredBuffer<float4> EyeAdaptationBuffer;
Texture2D InputTexture;
SamplerState InputSampler;
float2 Input_ExtentInverse;
void MainPS(noperspective float4 UVAndScreenPos : TEXCOORD0, float4 SvPosition: SV_POSITION, out float4 OutColor : SV_Target0)
{
float2 UV = UVAndScreenPos.xy;
float4 SceneColor = 0;
// accumulate all histograms into a single one
// could be optimized using bilinear filtering (half sample count)
for (uint y = 0; y < LoopSize/2; ++y)
{
SceneColor += Texture2DSample(InputTexture, InputSampler, float2(UV.x, (float(2*y + 1) * Input_ExtentInverse.y)));
}
if(SvPosition.y < 1.0f)
{
// line 0: histogram, we're not going to divide by the number of lines because it gets normalized later anyways
OutColor = SceneColor;
}
else
{
// line 1: store 4 channels of EyeAdaptationBuffer (copied over so we can read the value in EyeAdaptation pass which is writing to eye adaptation)
// second line first pixel in the texture has the ExposureScale from last frame
float4 OldExposureScale = EyeAdaptationBuffer[0];
OutColor = OldExposureScale;
}
}