Files
UnrealEngineUWP/Engine/Shaders/Private/LensDistortion.ush
guillaume abadie f141b08a6f Fixes up editor viewports's selection, outline and gizmo with lens distortion enabled.
#jira UE-216401

[CL 34143355 by guillaume abadie in ue5-main branch]
2024-06-05 18:33:26 -04:00

33 lines
1.1 KiB
Plaintext

// 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