Files
UnrealEngine/Engine/Shaders/Private/LensDistortion.ush
2025-05-18 13:04:45 +08:00

33 lines
1.1 KiB
HLSL

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Common.ush"
float2 ApplyLensDistortionOnViewportUV(Texture2D<float2> DisplacementTexture, SamplerState DisplacementSampler, float2 DestViewportUV)
{
return DestViewportUV + DisplacementTexture.SampleLevel(DisplacementSampler, DestViewportUV, 0);
}
float2 ApplyLensDistortionOnScreenPos(Texture2D<float2> DisplacementTexture, SamplerState DisplacementSampler, float2 DestScreenPos)
{
float2 DestViewportUV = ScreenPosToViewportUV(DestScreenPos);
return DestScreenPos + DisplacementTexture.SampleLevel(DisplacementSampler, DestViewportUV, 0) * float2(2, -2);
}
#if SUPPORTS_INDEPENDENT_SAMPLERS
float2 ApplyLensDistortionOnViewportUV(Texture2D<float2> DisplacementTexture, float2 DestViewportUV)
{
return ApplyLensDistortionOnViewportUV(DisplacementTexture, GlobalBilinearClampedSampler, DestViewportUV);
}
float2 ApplyLensDistortionOnScreenPos(Texture2D<float2> DisplacementTexture, float2 DestScreenPos)
{
return ApplyLensDistortionOnScreenPos(DisplacementTexture, GlobalBilinearClampedSampler, DestScreenPos);
}
#endif