Modified source engine (2017) developed by valve and leaked in 2020. Not for commercial purporses
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.1 KiB

5 years ago
// DYNAMIC: "CMBO_USERENDERTARGET" "0..1"
#include "shader_constant_register_map.h"
#include "common_ps_fxc.h"
sampler BaseTextureSampler : register( s0 );
sampler DistortMapTextureSampler : register( s1 );
struct PS_INPUT
{
float2 vBaseTexCoord : TEXCOORD0;
};
float4 main( PS_INPUT i ) : COLOR
{
float2 vOriginal = i.vBaseTexCoord.xy;
float4 vRead = tex2D( DistortMapTextureSampler, vOriginal );
float2 vGreen;
vGreen.r = ( vRead.x + vRead.z ) / 2.0;
vGreen.g = ( vRead.y + vRead.w ) / 2.0;
float4 vFinal;
vFinal.r = tex2D( BaseTextureSampler, vRead.xy ).r;
vFinal.ga = tex2D( BaseTextureSampler, vGreen ).ga;
vFinal.b = tex2D( BaseTextureSampler, vRead.zw ).b;
float fBoundsCheck;
#if ( CMBO_USERENDERTARGET )
{
fBoundsCheck = saturate( dot( (vGreen.xy < float2(0.01,0.01)), float2(1,1)) + dot( (vGreen.xy > float2(0.99,0.99)), float2(1,1)) );
}
#else
{
fBoundsCheck = saturate( dot( (vGreen.xy < float2(0.005,0.005)), float2(1,1)) + dot( (vGreen.xy > float2(0.995,0.995)), float2(1,1))
+ (vGreen.x > 0.495 && vGreen.x < 0.505 ) );
}
#endif
vFinal.xyz = lerp( vFinal.xyz, float3(0,0,0), fBoundsCheck );
return vFinal;
}