You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb none #preflight 61af8f5142028fda8e483da3 #ROBOMERGE-AUTHOR: guillaume.abadie #ROBOMERGE-SOURCE: CL 18396225 in //UE5/Release-5.0/... via CL 18396242 #ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v896-18170469) [CL 18396256 by guillaume abadie in ue5-release-engine-test branch]
88 lines
2.3 KiB
Plaintext
88 lines
2.3 KiB
Plaintext
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
/*=============================================================================
|
|
PostProcessBloom.usf: PostProcessing bloom
|
|
=============================================================================*/
|
|
|
|
#define EYE_ADAPTATION_LOOSE_PARAMETERS 1
|
|
|
|
#include "Common.ush"
|
|
#include "PostProcessCommon.ush"
|
|
#include "EyeAdaptationCommon.ush"
|
|
#include "ScreenPass.ush"
|
|
|
|
SCREEN_PASS_TEXTURE_VIEWPORT(Input)
|
|
|
|
Texture2D InputTexture;
|
|
|
|
SamplerState InputSampler;
|
|
|
|
float BloomThreshold;
|
|
|
|
void BloomSetupVS(
|
|
float4 InPosition : ATTRIBUTE0,
|
|
float2 InTexCoord : ATTRIBUTE1,
|
|
out noperspective float4 OutUVAndScreenPos : TEXCOORD0,
|
|
out nointerpolation float OutExposureScale : TEXCOORD1,
|
|
out float4 OutPosition : SV_POSITION)
|
|
{
|
|
DrawRectangle(InPosition, InTexCoord, OutPosition, OutUVAndScreenPos);
|
|
|
|
OutExposureScale = EyeAdaptationLookup();
|
|
}
|
|
|
|
float4 BloomSetupCommon(float2 UV, float ExposureScale)
|
|
{
|
|
float4 SceneColor = Texture2DSample(InputTexture, InputSampler, UV) * View.OneOverPreExposure;
|
|
|
|
// clamp to avoid artifacts from exceeding fp16 through framebuffer blending of multiple very bright lights
|
|
SceneColor.rgb = min(float3(256 * 256, 256 * 256, 256 * 256), SceneColor.rgb);
|
|
|
|
half3 LinearColor = SceneColor.rgb;
|
|
|
|
half TotalLuminance = Luminance(LinearColor) * ExposureScale;
|
|
half BloomLuminance = TotalLuminance - BloomThreshold;
|
|
half BloomAmount = saturate(BloomLuminance * 0.5f);
|
|
|
|
return float4(BloomAmount * LinearColor, 0) * View.PreExposure;
|
|
}
|
|
|
|
#if PIXELSHADER
|
|
|
|
FScreenTransform SvPositionToInputTextureUV;
|
|
|
|
void BloomSetupPS(
|
|
float4 SvPosition : SV_POSITION,
|
|
out float4 OutColor : SV_Target0)
|
|
{
|
|
float2 UV = ApplyScreenTransform(SvPosition.xy, SvPositionToInputTextureUV);
|
|
|
|
float ExposureScale = EyeAdaptationLookup();
|
|
|
|
OutColor = BloomSetupCommon(UV, ExposureScale);
|
|
}
|
|
|
|
#elif COMPUTESHADER
|
|
|
|
RWTexture2D<float4> RWOutputTexture;
|
|
|
|
[numthreads(THREADGROUP_SIZEX, THREADGROUP_SIZEY, 1)]
|
|
void BloomSetupCS(uint2 DispatchThreadId : SV_DispatchThreadID)
|
|
{
|
|
float2 UV = ((float2)DispatchThreadId + (float2)Input_ViewportMin + 0.5f) * Input_ExtentInverse;
|
|
|
|
if (IsComputeUVOutOfBounds(UV))
|
|
{
|
|
return;
|
|
}
|
|
|
|
float ExposureScale = EyeAdaptationLookup();
|
|
|
|
float4 OutColor = BloomSetupCommon(UV, ExposureScale);
|
|
|
|
uint2 PixelPos = DispatchThreadId + Input_ViewportMin;
|
|
|
|
RWOutputTexture[PixelPos] = OutColor;
|
|
}
|
|
|
|
#endif |