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.
 
 
 
 
 
 

107 lines
2.8 KiB

//===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//
#include "BaseVSShader.h"
#include "common_hlsl_cpp_consts.h"
#include "Downsample_ps20.inc"
#include "Downsample_ps20b.inc"
// NOTE: This has to be the last file included!
#include "tier0/memdbgon.h"
BEGIN_VS_SHADER_FLAGS( Downsample, "Help for Downsample", SHADER_NOT_EDITABLE )
BEGIN_SHADER_PARAMS
END_SHADER_PARAMS
SHADER_INIT
{
LoadTexture( BASETEXTURE );
}
SHADER_FALLBACK
{
return 0;
}
SHADER_DRAW
{
bool bForceSRGBReadAndWrite = false;
SHADOW_STATE
{
pShaderShadow->EnableDepthWrites( false );
pShaderShadow->EnableAlphaWrites( true );
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
// Render targets are pegged as sRGB on togl OSX, so just force these reads and writes
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, bForceSRGBReadAndWrite );
pShaderShadow->EnableSRGBWrite( bForceSRGBReadAndWrite );
int fmt = VERTEX_POSITION;
pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
pShaderShadow->SetVertexShader( "Downsample_vs20", 0 );
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
{
DECLARE_STATIC_PIXEL_SHADER( downsample_ps20b );
SET_STATIC_PIXEL_SHADER( downsample_ps20b );
}
else
{
DECLARE_STATIC_PIXEL_SHADER( downsample_ps20 );
SET_STATIC_PIXEL_SHADER( downsample_ps20 );
}
}
DYNAMIC_STATE
{
BindTexture( SHADER_SAMPLER0, bForceSRGBReadAndWrite ? TEXTURE_BINDFLAGS_SRGBREAD : TEXTURE_BINDFLAGS_NONE, BASETEXTURE, -1 );
int width, height;
pShaderAPI->GetBackBufferDimensions( width, height );
float v[4];
float dX = 1.0f / width;
float dY = 1.0f / height;
v[0] = -dX;
v[1] = -dY;
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, v, 1 );
v[0] = -dX;
v[1] = dY;
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_1, v, 1 );
v[0] = dX;
v[1] = -dY;
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, v, 1 );
v[0] = dX;
v[1] = dY;
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_3, v, 1 );
// Setup luminance threshold (all values are scaled down by max luminance)
// v[0] = 1.0f / MAX_HDR_OVERBRIGHT;
v[0] = 0.0f;
pShaderAPI->SetPixelShaderConstant( 0, v, 1 );
pShaderAPI->SetVertexShaderIndex( 0 );
if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
{
DECLARE_DYNAMIC_PIXEL_SHADER( downsample_ps20b );
SET_DYNAMIC_PIXEL_SHADER( downsample_ps20b );
}
else
{
DECLARE_DYNAMIC_PIXEL_SHADER( downsample_ps20 );
SET_DYNAMIC_PIXEL_SHADER( downsample_ps20 );
}
}
Draw();
}
END_SHADER