// Copyright Epic Games, Inc. All Rights Reserved. #include "Common.ush" #include "SlateShaderCommon.ush" #include "GammaCorrectionCommon.ush" #define MAX_SAMPLES 127 // Weigts and offsets are packed into 4 floats (Weight, Offset, Weight, Offset) float4 WeightAndOffsets[MAX_SAMPLES/2]; /** Blur sample count */ int SampleCount; Texture2D ElementTexture; SamplerState ElementTextureSampler; float4 BufferSizeAndDirection; float4 UVBounds; float4 ShaderParams; float4 ShaderParams2; float4 GetSample(float Weight, float Offset, float2 UV) { const float2 MinUV = UVBounds.xy; const float2 MaxUV = UVBounds.zw; const float2 Direction = BufferSizeAndDirection.zw; const float2 BufferSize = BufferSizeAndDirection.xy; const float2 UVOffset = float2(Offset*BufferSize.x*Direction.x, Offset*BufferSize.y*Direction.y); return Texture2DSample(ElementTexture, ElementTextureSampler, clamp(UV + UVOffset, MinUV, MaxUV)) * Weight + Texture2DSample(ElementTexture, ElementTextureSampler, clamp(UV - UVOffset, MinUV, MaxUV)) * Weight; } float4 GaussianBlurMain(in noperspective float4 InUVAndScreenPos : TEXCOORD0) : SV_Target0 { float4 OutColor = Texture2DSample(ElementTexture, ElementTextureSampler, clamp(InUVAndScreenPos.xy, UVBounds.xy, UVBounds.zw)) * WeightAndOffsets[0].x; // First offset is in zw { float Weight = WeightAndOffsets[0].z; float Offset = WeightAndOffsets[0].w; OutColor += GetSample(Weight, Offset, InUVAndScreenPos.xy); } for (int i = 2; i