You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- Image exposure is locally adjusted by decomposing luminance of the frame into a base layer and a detail layer. - Base layer contrast can be reduced while preserving detail. - Support blending with gaussian blurred luminance as proposed in Advances in Real-Time Rendering in Games 2021. - Controls in PostProcessVolume. - r.LocalExposure cvar to control whether local exposure is supported. - Visualization mode in "Show->Visualize->Local Expsoure". Multiple modes controllable using r.LocalExposure.VisualizeDebugMode. - Bilateral grid generation not yet optimized. Optimization should include increasing depth of grid to match histogram size so that global histogram can be generated from grid. - Added option to use mirror address mode in PostProcessWeightedSampleSum, since black border adds noticeable vignetting to the blurred luminance. #preflight 612f65169db3090001ba3eec #rb Brian.Karis, Guillaume.Abadie, Krzysztof.Narkowicz #ROBOMERGE-SOURCE: CL 17385317 via CL 17387198 #ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v865-17346139) [CL 17387234 by tiago costa in ue5-release-engine-test branch]
57 lines
1.9 KiB
Plaintext
57 lines
1.9 KiB
Plaintext
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "Common.ush"
|
|
#include "ScreenPass.ush"
|
|
#include "PostProcessCommon.ush"
|
|
#include "PostProcessHistogramCommon.ush"
|
|
#include "DeferredShadingCommon.ush"
|
|
#include "TonemapCommon.ush"
|
|
|
|
Texture2D EyeAdaptationTexture;
|
|
|
|
Texture2D HDRSceneColorTexture;
|
|
|
|
Texture3D LumBilateralGrid;
|
|
Texture2D BlurredLogLum;
|
|
|
|
SamplerState TextureSampler;
|
|
|
|
uint DebugMode;
|
|
|
|
SCREEN_PASS_TEXTURE_VIEWPORT(Input)
|
|
SCREEN_PASS_TEXTURE_VIEWPORT(Output)
|
|
|
|
float4 MainPS(noperspective float4 UVAndScreenPos : TEXCOORD0, float4 SvPosition : SV_POSITION) : SV_Target0
|
|
{
|
|
float2 UV = UVAndScreenPos.xy;
|
|
int2 PixelPos = (int2)SvPosition.xy;
|
|
|
|
float2 ExposureScaleMiddleGrey = EyeAdaptationTexture.Load(int3(0, 0, 0)).xw;
|
|
|
|
float4 SceneColor = Texture2DSample(HDRSceneColorTexture, TextureSampler, UV) * View.OneOverPreExposure;
|
|
|
|
float LuminanceVal = CalculateEyeAdaptationLuminance(SceneColor.rgb);
|
|
float LogLuminance = log2(LuminanceVal);
|
|
float MiddleGreyLumValue = log2(0.18 * ExposureScaleMiddleGrey.y * EyeAdaptation_LocalExposureMiddleGreyExposureCompensation);
|
|
|
|
float BaseLogLum = CalculateBaseLogLuminance(LogLuminance, EyeAdaptation_LocalExposureBlurredLuminanceBlend, ExposureScaleMiddleGrey.x, UV, LumBilateralGrid, BlurredLogLum, TextureSampler, TextureSampler);
|
|
float LocalExposure = CalculateLocalExposure(LogLuminance + log2(ExposureScaleMiddleGrey.x), BaseLogLum, MiddleGreyLumValue, EyeAdaptation_LocalExposureContrastReduction, EyeAdaptation_LocalExposureDetailStrength);
|
|
float DetailLogLum = (LogLuminance + log2(ExposureScaleMiddleGrey.x)) - BaseLogLum;
|
|
|
|
float3 OutValue;
|
|
|
|
if (DebugMode == 0)
|
|
{
|
|
OutValue = saturate(abs(log2(LocalExposure) / 2)) * lerp(float3(1.0f, 0.0f, 0.0f), float3(0.0f, 1.0f, 0.0f), step(LocalExposure, 1));
|
|
}
|
|
else if (DebugMode == 1)
|
|
{
|
|
OutValue = exp2(BaseLogLum);
|
|
}
|
|
else if (DebugMode == 2)
|
|
{
|
|
OutValue = exp2(DetailLogLum);
|
|
}
|
|
|
|
return float4(OutValue, 1.0f);
|
|
} |