Counter Strike : Global Offensive Source Code
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.
 
 
 
 
 
 

89 lines
2.4 KiB

//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
// STATIC: "BLOOMTYPE" "0..1"
// STATIC: "PS3REGCOUNT48" "0..0"
// STATIC: "SRGB_INPUT_ADAPTER" "0..1" [ps20b] [PC]
// STATIC: "SRGB_INPUT_ADAPTER" "0..0" [CONSOLE]
// DYNAMIC: "FLOAT_BACK_BUFFER" "0..1" [ps20b] [ps30] [PC]
// DYNAMIC: "FLOAT_BACK_BUFFER" "0..0" [ps20b] [CONSOLE]
// SKIP: ( $FLOAT_BACK_BUFFER == 1 ) && ( $SRGB_INPUT_ADAPTER == 1 )
#include "common_ps_fxc.h"
sampler TexSampler : register( s0 );
float4 params : register( c0 );
float4 params2 : register( c1 );
#define g_flBloomExp params2.x
#define g_flBloomSaturation params2.y
struct PS_INPUT
{
float2 coordTap0 : TEXCOORD0;
float2 coordTap1 : TEXCOORD1;
float2 coordTap2 : TEXCOORD2;
float2 coordTap3 : TEXCOORD3;
};
float4 Shape( float4 cColor )
{
#if ( BLOOMTYPE == 0 )
{
float flLum = dot( cColor.xyz, params.xyz );
cColor.rgb = pow( cColor.xyz, params.w ) * flLum;
}
#endif
#if ( BLOOMTYPE == 1 )
{
float flScale = 1.55f; // Color scale
float flBias = -0.09f; // Color bias
float flBrightnessClamp = 0.59f; // After scale and bias, clamp RGB values brighter than this
float flExp = g_flBloomExp;
cColor.rgb = pow( saturate( min( flBrightnessClamp, ( cColor.rgb * flScale ) + flBias ) ), flExp );
}
#endif
return cColor;
}
float4_color_return_type main( PS_INPUT i ) : COLOR
{
// Sample 4 taps
float4 s0 = tex2D( TexSampler, i.coordTap0 );
float4 s1 = tex2D( TexSampler, i.coordTap1 );
float4 s2 = tex2D( TexSampler, i.coordTap2 );
float4 s3 = tex2D( TexSampler, i.coordTap3 );
#if ( ( SRGB_INPUT_ADAPTER == 1 ) || ( FLOAT_BACK_BUFFER == 1 ) )
{
s0.rgb = SrgbLinearToGamma( saturate( s0.rgb ) );
s1.rgb = SrgbLinearToGamma( saturate( s1.rgb ) );
s2.rgb = SrgbLinearToGamma( saturate( s2.rgb ) );
s3.rgb = SrgbLinearToGamma( saturate( s3.rgb ) );
}
#endif
float4 avgColor = ( s0 + s1 + s2 + s3 ) * 0.25f;
float fAvgLuminance = dot( avgColor.rgb, float3( 0.299, 0.587, 0.114 ) );
avgColor = Shape( avgColor );
// Saturation
#if ( BLOOMTYPE == 1 )
{
avgColor.rgb = lerp( dot( params.rgb, avgColor.rgb ), avgColor.rgb, g_flBloomSaturation );
}
#endif
avgColor.a = fAvgLuminance;
#if ( SRGB_INPUT_ADAPTER == 1 )
{
avgColor.rgb = SrgbGammaToLinear( saturate( avgColor.rgb ) );
}
#endif
return FinalOutput( avgColor, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
}