/*============================================================================= DistortApplyScreenPixelShader.usf: Pixel shader for rendering screen distortion pass Copyright 1998-2007 Epic Games, Inc. All Rights Reserved. =============================================================================*/ #include "Common.usf" static const half InvDistortionScaleBias = 1 / 4.0f; /** * contains accumulated distortion values as * R=positive horizontal offset * G=positive vertical offset * B=negative horizontal offset * A=negative vertical offset */ sampler2D AccumulatedDistortionTexture; /** distorts screen texture using accumulated distortion offsets */ void Main( in float2 TexCoord: TEXCOORD0, out float4 OutColor : COLOR0 ) { // sample accumulated distortion and apply inverse scale half4 AccumDist = tex2D(AccumulatedDistortionTexture,TexCoord); // offset = [R-B,G-A] and flip Y half2 DistOffset = (AccumDist.rg - AccumDist.ba) * half2(InvDistortionScaleBias,-InvDistortionScaleBias); #if SUPPORTS_DEPTH_TEXTURES // sample screen using offset coords half3 DistColor = tex2D(SceneColorTexture, TexCoord + DistOffset).xyz; OutColor = half4(DistColor,0); #else // sample screen using offset coords, distorting both scene color and depth half4 DistColor = CalcFullSceneColor(TexCoord + DistOffset); OutColor = RETURN_COLOR( DistColor ); #endif }