Mapbase v6.1

- Added postprocess_controller entity from later versions of Source
- Added env_dof_controller entity from later versions of Source
- Added SDK_Engine_Post and DepthOfField shaders from the Momentum repo/Alien Swarm SDK
- Fixed auto-breaking game_text/choreo text not null terminating
- Fixed console groups showing up at the wrong developer levels
- Added more mesages to console groups, including a new "NPC AI" console group
- Fixed typos and added elaboration in various cvars, console messages, etc.
- Fixed npc_metropolice not using frag grenades correctly when allowed to use them
- Fixed npc_metropolice not registering stitching squad slots in AI
- Fixed SetModel input late precache warning
- Fixed env_global_light angles resetting upon loading a save
- Fixed an issue with ScriptKeyValuesRead using the wrong name and having a memory leak
- Allowed VScript functions which return null strings to actually return null instead of empty strings
- Added VScript member variable documentation
- Fixed VScript documentation lines sometimes mixing together
- Fixed VScript singletons having a ! at the beginning of descriptions
- Added Color struct to VScript and allowed color-related inputs to use it
- Added more VScript functions for weapons, ammo, ragdolling, and response contexts
- Added GameRules singleton for VScript
- Exposed AI interaction system to VScript
- Recovered some lost documentation from older revisions of the Mapbase wiki
- Added a way to get the current game's load type in VScript
- Fixed Precache/SpawnEntityFromTable not accounting for a few important field types
- Added VScript functions for getting a player's eye vectors
- Fixed a crash caused by removing the active weapon of a Combine soldier while it's firing
- Changed the way metrocops deploy their manhacks so they could use their manhack death response properly
- Fixed "Use Server" keyvalue on game_convar_mod not working
- Adjusted CAI_Expresser in VScript
This commit is contained in:
Blixibon
2020-12-17 03:38:23 +00:00
parent 6d45d9591e
commit 87cd9b24bb
82 changed files with 4596 additions and 337 deletions

View File

@@ -0,0 +1,22 @@
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
sampler g_texSampler : register( s0 );
struct PS_INPUT
{
float2 uv : TEXCOORD0;
};
float2 g_vPsTapOffsets[2] : register( c0 );
float4 main( PS_INPUT i ) : COLOR
{
float4 cOut;
cOut = 0.25 * tex2D( g_texSampler, i.uv + g_vPsTapOffsets[0] );
cOut += 0.25 * tex2D( g_texSampler, i.uv - g_vPsTapOffsets[0] );
cOut += 0.25 * tex2D( g_texSampler, i.uv + g_vPsTapOffsets[1] );
cOut += 0.25 * tex2D( g_texSampler, i.uv - g_vPsTapOffsets[1] );
return cOut;
}

View File

@@ -0,0 +1,137 @@
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
// DYNAMIC: "QUALITY" "0..3"
// Includes =======================================================================================
#include "common_ps_fxc.h"
// Texture Samplers ===============================================================================
sampler g_tFullFB : register( s0 );
sampler g_tSmallFB : register( s1 );
// Shaders Constants and Globals ==================================================================
float4 g_vDists : register( c0 );
#define g_flNearBlurDist g_vDists.x
#define g_flNearFocusDist g_vDists.y
#define g_flFarFocusDist g_vDists.z
#define g_flFarBlurDist g_vDists.w
float3 g_vBlurAmounts : register( c1 );
#define g_flMaxBlurRadius g_vBlurAmounts.x
#define g_flNearBlurStrength g_vBlurAmounts.y
#define g_flFarBlurStrength g_vBlurAmounts.z
float3 g_vNearFarDists : register( c2 );
#define g_flNearPlaneDist g_vNearFarDists.x
#define g_flFarPlaneDist g_vNearFarDists.y
#define g_flDepthConv g_vNearFarDists.z
float4 g_vMagicConsts : register( c3 );
#if ( QUALITY == 0 )
#define NUM_SAMPLES 8 // These must match the C code
#elif ( QUALITY == 1 )
#define NUM_SAMPLES 16
#elif ( QUALITY == 2 )
#define NUM_SAMPLES 16
#elif ( QUALITY == 3 )
#define NUM_SAMPLES 32
#endif
float4 g_vPoisson[ NUM_SAMPLES/2 ] : register( c4 );
// Interpolated values ============================================================================
struct PS_INPUT
{
float2 vUv0 : TEXCOORD0;
};
float DestAlphaDepthToViewSpaceDepth( float flDepth )
{
return g_flDepthConv * flDepth + g_flNearPlaneDist;
}
// returns blur radius from depth as a fraction of max_blur.
float BlurAmountFromDepth( float flDestAlphaDepth )
{
/*
dist = DestAlphaDepthToViewSpaceDepth( flDestAlphaDepth );
float flBlur = max( g_flNearBlurStrength * saturate( (flDestAlphaDepth - g_flNearFocusDist) / ( g_flNearBlurDist - g_flNearFocusDist ) ),
g_flFarBlurStrength * saturate( (flDestAlphaDepth - g_flFarFocusDist) / ( g_flFarBlurDist - g_flFarFocusDist ) ) );
*/
// A more optimized version that concatenates the math above and the one in DestAlphaDepthToViewSpaceDepth to a single muladd
float flBlur = max( g_flNearBlurStrength * saturate( g_vMagicConsts.x * flDestAlphaDepth + g_vMagicConsts.y ),
g_flFarBlurStrength * saturate( g_vMagicConsts.z * flDestAlphaDepth + g_vMagicConsts.w ) );
return flBlur;
}
float BlurRadiusFromDepth( float flDepth )
{
return g_flMaxBlurRadius * BlurAmountFromDepth( flDepth );
}
float4 ComputeTap( float flCenterDepth, float flCenterBlurRadius, float2 vUV, float2 vPoisson )
{
float4 cTapSmall;
float4 cTap;
float2 vPoissonUV = vUV.xy + flCenterBlurRadius * vPoisson.xy;
cTapSmall = tex2D( g_tSmallFB, vPoissonUV.xy );
cTap = tex2D( g_tFullFB, vPoissonUV.xy );
float flTapBlur = BlurAmountFromDepth( cTap.a ); // Maybe 50/50 mix between low and high here?
cTap = lerp( cTap, cTapSmall, saturate( 2.2 * flTapBlur ) ); // TODO: tweak blur amount.
float flLerpedTapBlur = BlurAmountFromDepth( cTap.a );
float weight = ( cTap.a >= flCenterDepth ) ? 1.0 : ( flLerpedTapBlur*flLerpedTapBlur );
return float4( cTap.rgb, 1 ) * weight;
}
float4 ComputeTapHQ( float flCenterDepth, float flCenterBlurRadius, float2 vUV, float2 vPoisson )
{
float4 cTap;
cTap = tex2D( g_tFullFB, vUV.xy + flCenterBlurRadius * vPoisson.xy );
float flTapBlur = BlurAmountFromDepth( cTap.a );
float weight = ( cTap.a >= flCenterDepth ) ? 1.0 : ( flTapBlur * flTapBlur );
return float4( cTap.rgb, 1 ) * weight;
}
// Main ===========================================================================================
float4 main( PS_INPUT i ) : COLOR
{
// TODO: BETTER DOWNSAMPLE THAT TAKES DEPTH INTO ACCOUNT?
float4 cOut = { 0, 0, 0, 0 };
float4 cCenterTap = tex2D( g_tFullFB, i.vUv0 );
float flCenterBlurRadius = BlurRadiusFromDepth( cCenterTap.a ); // circle of confusion radius for current pixel
cCenterTap.a -= 0.001; // z-bias to avoid strange banding artifact on almost orthogonal walls
#if ( QUALITY < 2 )
// ATI's Ruby1-style algorithm
for ( int t = 0; t < NUM_SAMPLES/2; t++ )
{
cOut.rgba += ComputeTap( cCenterTap.a, flCenterBlurRadius, i.vUv0, g_vPoisson[t].xy );
cOut.rgba += ComputeTap( cCenterTap.a, flCenterBlurRadius, i.vUv0, g_vPoisson[t].wz );
}
#else
// Less fancy, with less fetches per tap and less math. Needs more samples to look smooth.
cOut = cCenterTap;
cOut.a = 1.0; // Use the center sample we just fetched
for ( int t = 0; t < NUM_SAMPLES/2; t++ )
{
cOut.rgba += ComputeTapHQ( cCenterTap.a, flCenterBlurRadius, i.vUv0, g_vPoisson[t].xy );
cOut.rgba += ComputeTapHQ( cCenterTap.a, flCenterBlurRadius, i.vUv0, g_vPoisson[t].wz );
}
#endif
//cOut.rgb = cOut.a / float(NUM_SAMPLES+1);
//cOut = lerp( tex2D( g_tFullFB, i.vUv0 ), tex2D( g_tSmallFB, i.vUv0 ).aaaa, 0.5 );
if ( cOut.a > 0.0 )
cOut.rgba /= cOut.a;
else
cOut.rgba = cCenterTap.rgba;
return cOut;
}

View File

@@ -0,0 +1,29 @@
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
// Includes =======================================================================================
#include "common_vs_fxc.h"
// Input values ===================================================================================
struct VS_INPUT
{
float3 vPos : POSITION;
float2 vBaseTexCoord : TEXCOORD0;
};
// Interpolated values ============================================================================
struct VS_OUTPUT
{
float4 projPos : POSITION;
float2 vUv0 : TEXCOORD0;
};
// Main ===========================================================================================
VS_OUTPUT main( const VS_INPUT i )
{
VS_OUTPUT o;
o.projPos.xyzw = float4( i.vPos.xyz, 1.0f );
o.vUv0.xy = i.vBaseTexCoord.xy;
return o;
}

View File

@@ -0,0 +1,280 @@
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose: Depth of field material
//
//===========================================================================//
#include "BaseVSShader.h"
#include "depth_of_field_vs20.inc"
#include "depth_of_field_ps20b.inc"
#include "convar.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
ConVar mat_dof_max_blur_radius( "mat_dof_max_blur_radius", "50" );
ConVar mat_dof_quality( "mat_dof_quality", "3" );
ConVar mat_dof_constant( "mat_dof_constant", "512" );
// 8 samples
static const float s_flPoissonConstsQuality0[16] = {
0.0, 0.0,
0.527837, -0.085868,
-0.040088, 0.536087,
-0.670445, -0.179949,
-0.419418, -0.616039,
0.440453, -0.639399,
-0.757088, 0.349334,
0.574619, 0.685879
};
// 16 samples
static const float s_flPoissonConstsQuality1[32] = {
0.0747, -0.8341,
-0.9138, 0.3251,
0.8667, -0.3029,
-0.4642, 0.2187,
-0.1505, 0.7320,
0.7310, -0.6786,
0.2859, -0.3254,
-0.1311, -0.2292,
0.3518, 0.6470,
-0.7485, -0.6307,
0.1687, 0.1873,
-0.3604, -0.7483,
-0.5658, -0.1521,
0.7102, 0.0536,
-0.6056, 0.7747,
0.7793, 0.6194
};
// 32 samples
static const float s_flPoissonConstsQuality2[64] = {
0.0854f, -0.0644f,
0.8744f, 0.1665f,
0.2329f, 0.3995f,
-0.7804f, 0.5482f,
-0.4577f, 0.7647f,
-0.1936f, 0.5564f,
0.4205f, -0.5768f,
-0.0304f, -0.9050f,
-0.5215f, 0.1854f,
0.3161f, -0.2954f,
0.0666f, -0.5564f,
-0.2137f, -0.0072f,
-0.4112f, -0.3311f,
0.6438f, -0.2484f,
-0.9055f, -0.0360f,
0.8323f, 0.5268f,
0.5592f, 0.3459f,
-0.6797f, -0.5201f,
-0.4325f, -0.8857f,
0.8768f, -0.4197f,
0.3090f, -0.8646f,
0.5034f, 0.8603f,
0.3752f, 0.0627f,
-0.0161f, 0.2627f,
0.0969f, 0.7054f,
-0.2291f, -0.6595f,
-0.5887f, -0.1100f,
0.7048f, -0.6528f,
-0.8438f, 0.2706f,
-0.5061f, 0.4653f,
-0.1245f, -0.3302f,
-0.1801f, 0.8486f
};
DEFINE_FALLBACK_SHADER( DepthOfField, DepthOfField_dx9 )
BEGIN_VS_SHADER_FLAGS( DepthOfField_dx9, "Depth of Field", SHADER_NOT_EDITABLE )
BEGIN_SHADER_PARAMS
SHADER_PARAM( SMALLFB, SHADER_PARAM_TYPE_TEXTURE, "_rt_SmallFB1", "Downsampled backbuffer" )
SHADER_PARAM( NEARPLANE, SHADER_PARAM_TYPE_FLOAT, "0", "Near plane depth" )
SHADER_PARAM( FARPLANE, SHADER_PARAM_TYPE_FLOAT, "0", "Far plane depth" )
SHADER_PARAM( NEARBLURDEPTH, SHADER_PARAM_TYPE_FLOAT, "0", "Near blur plane depth" )
SHADER_PARAM( NEARFOCUSDEPTH, SHADER_PARAM_TYPE_FLOAT, "0", "Near focus plane depth" )
SHADER_PARAM( FARFOCUSDEPTH, SHADER_PARAM_TYPE_FLOAT, "0", "Far focus plane depth" )
SHADER_PARAM( FARBLURDEPTH, SHADER_PARAM_TYPE_FLOAT, "0", "Far blur plane depth" )
SHADER_PARAM( NEARBLURRADIUS, SHADER_PARAM_TYPE_FLOAT, "0", "Max near blur radius" )
SHADER_PARAM( FARBLURRADIUS, SHADER_PARAM_TYPE_FLOAT, "0", "Max far blur radius" )
SHADER_PARAM( QUALITY, SHADER_PARAM_TYPE_INTEGER, "0", "Quality level. Selects different algorithms." )
END_SHADER_PARAMS
SHADER_INIT_PARAMS()
{
SET_PARAM_STRING_IF_NOT_DEFINED( SMALLFB, "_rt_SmallFB1" );
SET_PARAM_FLOAT_IF_NOT_DEFINED( NEARPLANE, 0.0f );
SET_PARAM_FLOAT_IF_NOT_DEFINED( FARPLANE, 0.0f );
SET_PARAM_FLOAT_IF_NOT_DEFINED( NEARBLURDEPTH, 0.0f );
SET_PARAM_FLOAT_IF_NOT_DEFINED( NEARFOCUSDEPTH, 0.0f );
SET_PARAM_FLOAT_IF_NOT_DEFINED( FARFOCUSDEPTH, 0.0f );
SET_PARAM_FLOAT_IF_NOT_DEFINED( FARBLURDEPTH, 0.0f );
SET_PARAM_FLOAT_IF_NOT_DEFINED( NEARBLURRADIUS, 0.0f );
SET_PARAM_FLOAT_IF_NOT_DEFINED( FARBLURRADIUS, 0.0f );
SET_PARAM_INT_IF_NOT_DEFINED( QUALITY, 0 );
}
SHADER_FALLBACK
{
if ( g_pHardwareConfig->GetDXSupportLevel() < 92 )
{
return "Wireframe";
}
return 0;
}
SHADER_INIT
{
if ( params[BASETEXTURE]->IsDefined() )
{
LoadTexture( BASETEXTURE );
}
if ( params[SMALLFB]->IsDefined() )
{
LoadTexture( SMALLFB );
}
}
SHADER_DRAW
{
SHADOW_STATE
{
pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 1, 0, 0 );
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, false );
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, false );
pShaderShadow->EnableSRGBWrite( false );
DECLARE_STATIC_VERTEX_SHADER( depth_of_field_vs20 );
SET_STATIC_VERTEX_SHADER( depth_of_field_vs20 );
if ( g_pHardwareConfig->SupportsPixelShaders_2_b() )
{
DECLARE_STATIC_PIXEL_SHADER( depth_of_field_ps20b );
SET_STATIC_PIXEL_SHADER( depth_of_field_ps20b );
}
else
{
Assert( !"No ps_2_b. This shouldn't be happening" );
}
pShaderShadow->EnableDepthWrites( false );
pShaderShadow->EnableAlphaWrites( false );
}
DYNAMIC_STATE
{
DECLARE_DYNAMIC_VERTEX_SHADER( depth_of_field_vs20 );
SET_DYNAMIC_VERTEX_SHADER( depth_of_field_vs20 );
// Bind textures
BindTexture( SHADER_SAMPLER0, BASETEXTURE );
BindTexture( SHADER_SAMPLER1, SMALLFB );
// near blur = blur of stuff in front of focus range
// far blur = blur of stuff behind focus range
// C0: set near/far blur and focus distances
// x = near blur distance
// y = near focus distance
// z = far focus distance
// w = far blur distance
// C1:
// x = blur radius for near blur (in pixels)
// y = blur radius for far blur (in pixels)
// TODO: Specifying this stuff in pixels makes blurs look smaller on high backbuffer resolutions.
// This might be a problem for tweaking these values.
float vConst[16] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
vConst[0] = params[NEARBLURDEPTH]->GetFloatValue();
vConst[1] = params[NEARFOCUSDEPTH]->GetFloatValue();
vConst[2] = params[FARFOCUSDEPTH]->GetFloatValue();
vConst[3] = params[FARBLURDEPTH]->GetFloatValue();;
// max blur radius will need to be set based on quality level and screen res
vConst[4] = mat_dof_max_blur_radius.GetFloat();
vConst[5] = MIN( params[NEARBLURRADIUS]->GetFloatValue(), vConst[4] ) / vConst[4]; // near and far blur radius as fraction of max radius
vConst[6] = MIN( params[FARBLURRADIUS]->GetFloatValue(), vConst[4] ) / vConst[4];
vConst[8] = params[NEARPLANE]->GetFloatValue();
vConst[9] = params[FARPLANE]->GetFloatValue();
vConst[10] = mat_dof_constant.GetFloat() * ( vConst[9] - vConst[8] ) / vConst[9];
vConst[12] = vConst[10] / ( vConst[0] - vConst[1] );
vConst[13] = ( vConst[8] - vConst[1] ) / ( vConst[0] - vConst[1] );
vConst[14] = vConst[10] / ( vConst[3] - vConst[2] );
vConst[15] = ( vConst[8] - vConst[2] ) / ( vConst[3] - vConst[2] );
pShaderAPI->SetPixelShaderConstant( 0, vConst, 4 );
// set up poisson sample location constants pre-divided by screen res
int nNumPoissonSamples = 0;
const float *pPoissonSrc = NULL;
switch ( params[QUALITY]->GetIntValue() )
{
case 0:
// NOTE: These must match the shader
nNumPoissonSamples = 8;
pPoissonSrc = s_flPoissonConstsQuality0;
break;
case 1:
case 2:
nNumPoissonSamples = 16;
pPoissonSrc = s_flPoissonConstsQuality1;
break;
case 3:
nNumPoissonSamples = 32;
pPoissonSrc = s_flPoissonConstsQuality2;
break;
default:
Warning( "Invalid mat_dof_quality value. Resetting to 0.\n" );
mat_dof_quality.SetValue( 0 );
nNumPoissonSamples = 8;
pPoissonSrc = s_flPoissonConstsQuality0;
break;
}
float vPoissonConst[64]; // temp table
// Get texture dimensions
ITexture *pTex = params[BASETEXTURE]->GetTextureValue();
Assert( pTex );
float flInvTexWidth = 1.0f / static_cast<float>( pTex->GetActualWidth() );
float flInvTexHeight = 1.0f / static_cast<float>( pTex->GetActualHeight() );
for ( int i = 0; i < nNumPoissonSamples; i++ )
{
vPoissonConst[ 2*i ] = pPoissonSrc[ 2*i ] * flInvTexWidth;
vPoissonConst[ 2*i+1 ] = pPoissonSrc[ 2*i+1 ] * flInvTexHeight;
}
// swizzle every other 2-tuple so that I can use the free .wz swizzle in the shader
for ( int i = 1; i < nNumPoissonSamples; i += 2)
{
float t = vPoissonConst[ 2*i ];
vPoissonConst[ 2*i ] = vPoissonConst[ 2*i+1 ];
vPoissonConst[ 2*i+1 ] = t;
}
pShaderAPI->SetPixelShaderConstant( 4, vPoissonConst, nNumPoissonSamples / 2 );
if ( g_pHardwareConfig->SupportsPixelShaders_2_b() )
{
DECLARE_DYNAMIC_PIXEL_SHADER( depth_of_field_ps20b );
SET_DYNAMIC_PIXEL_SHADER_COMBO( QUALITY, params[QUALITY]->GetIntValue() );
SET_DYNAMIC_PIXEL_SHADER( depth_of_field_ps20b );
}
else
{
Assert( !"No ps_2_b. This shouldn't be happening" );
}
}
Draw();
}
END_SHADER

View File

@@ -0,0 +1,636 @@
//========= Copyright <20> 1996-2007, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include "BaseVSShader.h"
#include "SDK_screenspaceeffect_vs20.inc"
#include "SDK_engine_post_ps20b.inc"
// NOTE: This has to be the last file included!
#include "tier0/memdbgon.h"
ConVar mat_screen_blur_override( "mat_screen_blur_override", "-1.0" );
ConVar mat_depth_blur_focal_distance_override( "mat_depth_blur_focal_distance_override", "-1.0" );
ConVar mat_depth_blur_strength_override( "mat_depth_blur_strength_override", "-1.0" );
ConVar mat_grain_scale_override( "mat_grain_scale_override", "-1.0" );
ConVar mat_local_contrast_scale_override( "mat_local_contrast_scale_override", "0.0" );
ConVar mat_local_contrast_midtone_mask_override( "mat_local_contrast_midtone_mask_override", "-1.0" );
ConVar mat_local_contrast_vignette_start_override( "mat_local_contrast_vignette_start_override", "-1.0" );
ConVar mat_local_contrast_vignette_end_override( "mat_local_contrast_vignette_end_override", "-1.0" );
ConVar mat_local_contrast_edge_scale_override( "mat_local_contrast_edge_scale_override", "-1000.0" );
DEFINE_FALLBACK_SHADER( SDK_Engine_Post, SDK_Engine_Post_dx9 )
BEGIN_VS_SHADER_FLAGS( SDK_Engine_Post_dx9, "Engine post-processing effects (software anti-aliasing, bloom, color-correction", SHADER_NOT_EDITABLE )
BEGIN_SHADER_PARAMS
SHADER_PARAM( FBTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_FullFrameFB", "Full framebuffer texture" )
SHADER_PARAM( AAENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Enable software anti-aliasing" )
SHADER_PARAM( AAINTERNAL1, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0]", "Internal anti-aliasing values set via material proxy" )
SHADER_PARAM( AAINTERNAL2, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0]", "Internal anti-aliasing values set via material proxy" )
SHADER_PARAM( AAINTERNAL3, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0]", "Internal anti-aliasing values set via material proxy" )
SHADER_PARAM( BLOOMENABLE, SHADER_PARAM_TYPE_BOOL, "1", "Enable bloom" )
SHADER_PARAM( BLOOMAMOUNT, SHADER_PARAM_TYPE_FLOAT, "1.0", "Bloom scale factor" )
SHADER_PARAM( SCREENEFFECTTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "used for paint or vomit screen effect" )
SHADER_PARAM( DEPTHBLURENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Inexpensive depth-of-field substitute" )
SHADER_PARAM( ALLOWVIGNETTE, SHADER_PARAM_TYPE_BOOL, "0", "Allow vignette" )
SHADER_PARAM( VIGNETTEENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Enable vignette" )
SHADER_PARAM( INTERNAL_VIGNETTETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "dev/vignette", "" )
SHADER_PARAM( ALLOWNOISE, SHADER_PARAM_TYPE_BOOL, "0", "Allow noise" )
SHADER_PARAM( NOISEENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Enable noise" )
SHADER_PARAM( NOISESCALE, SHADER_PARAM_TYPE_FLOAT, "0", "Noise scale" )
SHADER_PARAM( NOISETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "Noise texture" )
SHADER_PARAM( ALLOWLOCALCONTRAST, SHADER_PARAM_TYPE_BOOL, "0", "Enable local contrast enhancement" )
SHADER_PARAM( LOCALCONTRASTENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Enable local contrast enhancement" )
SHADER_PARAM( LOCALCONTRASTSCALE, SHADER_PARAM_TYPE_FLOAT, "0", "Local contrast scale" )
SHADER_PARAM( LOCALCONTRASTMIDTONEMASK, SHADER_PARAM_TYPE_FLOAT, "0", "Local contrast midtone mask" )
SHADER_PARAM( LOCALCONTRASTVIGNETTESTART, SHADER_PARAM_TYPE_BOOL, "0", "Enable local contrast enhancement" )
SHADER_PARAM( LOCALCONTRASTVIGNETTEEND, SHADER_PARAM_TYPE_FLOAT, "0", "Local contrast scale" )
SHADER_PARAM( LOCALCONTRASTEDGESCALE, SHADER_PARAM_TYPE_FLOAT, "0", "Local contrast midtone mask" )
SHADER_PARAM( BLURREDVIGNETTEENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Enable blurred vignette" )
SHADER_PARAM( BLURREDVIGNETTESCALE, SHADER_PARAM_TYPE_FLOAT, "0", "blurred vignette strength" )
SHADER_PARAM( FADETOBLACKSCALE, SHADER_PARAM_TYPE_FLOAT, "0", "fade strength" )
SHADER_PARAM( DEPTHBLURFOCALDISTANCE, SHADER_PARAM_TYPE_FLOAT, "0", "Distance in dest-alpha space [0,1] of focal plane." )
SHADER_PARAM( DEPTHBLURSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0", "Strength of depth-blur effect" )
SHADER_PARAM( SCREENBLURSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0", "Full-screen blur factor" )
SHADER_PARAM( VOMITCOLOR1, SHADER_PARAM_TYPE_VEC3, "[0 0 0 0]", "1st vomit blend color" )
SHADER_PARAM( VOMITCOLOR2, SHADER_PARAM_TYPE_VEC3, "[0 0 0 0]", "2st vomit blend color" )
SHADER_PARAM( VOMITREFRACTSCALE, SHADER_PARAM_TYPE_FLOAT, "0.15", "vomit refract strength" )
SHADER_PARAM( VOMITENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Enable vomit refract" )
SHADER_PARAM( FADECOLOR, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0]", "viewfade color" )
SHADER_PARAM( FADE, SHADER_PARAM_TYPE_INTEGER, "0", "fade type. 0 = off, 1 = lerp, 2 = modulate" )
SHADER_PARAM( TV_GAMMA, SHADER_PARAM_TYPE_INTEGER, "0", "0 default, 1 used for laying off 360 movies" )
SHADER_PARAM( DESATURATEENABLE, SHADER_PARAM_TYPE_INTEGER, "0", "Desaturate with math, turns off color correction" )
SHADER_PARAM( DESATURATION, SHADER_PARAM_TYPE_FLOAT, "0", "Desaturation Amount" )
// Tool color correction setup
SHADER_PARAM( TOOLMODE, SHADER_PARAM_TYPE_BOOL, "1", "tool mode" )
SHADER_PARAM( TOOLCOLORCORRECTION, SHADER_PARAM_TYPE_FLOAT, "1", "tool color correction override" )
SHADER_PARAM( WEIGHT_DEFAULT, SHADER_PARAM_TYPE_FLOAT, "1", "weight default" )
SHADER_PARAM( WEIGHT0, SHADER_PARAM_TYPE_FLOAT, "1", "weight0" )
SHADER_PARAM( WEIGHT1, SHADER_PARAM_TYPE_FLOAT, "1", "weight1" )
SHADER_PARAM( WEIGHT2, SHADER_PARAM_TYPE_FLOAT, "1", "weight2" )
SHADER_PARAM( WEIGHT3, SHADER_PARAM_TYPE_FLOAT, "1", "weight3" )
SHADER_PARAM( NUM_LOOKUPS, SHADER_PARAM_TYPE_FLOAT, "0", "num_lookups" )
SHADER_PARAM( TOOLTIME, SHADER_PARAM_TYPE_FLOAT, "0", "tooltime" )
END_SHADER_PARAMS
SHADER_INIT_PARAMS()
{
if ( !params[ INTERNAL_VIGNETTETEXTURE ]->IsDefined() )
{
params[ INTERNAL_VIGNETTETEXTURE ]->SetStringValue( "dev/vignette" );
}
if ( !params[ AAENABLE ]->IsDefined() )
{
params[ AAENABLE ]->SetIntValue( 0 );
}
if ( !params[ AAINTERNAL1 ]->IsDefined() )
{
params[ AAINTERNAL1 ]->SetVecValue( 0, 0, 0, 0 );
}
if ( !params[ AAINTERNAL2 ]->IsDefined() )
{
params[ AAINTERNAL2 ]->SetVecValue( 0, 0, 0, 0 );
}
if ( !params[ AAINTERNAL3 ]->IsDefined() )
{
params[ AAINTERNAL3 ]->SetVecValue( 0, 0, 0, 0 );
}
if ( !params[ BLOOMENABLE ]->IsDefined() )
{
params[ BLOOMENABLE ]->SetIntValue( 1 );
}
if ( !params[ BLOOMAMOUNT ]->IsDefined() )
{
params[ BLOOMAMOUNT ]->SetFloatValue( 1.0f );
}
if ( !params[ DEPTHBLURENABLE ]->IsDefined() )
{
params[ DEPTHBLURENABLE ]->SetIntValue( 0 );
}
if ( !params[ ALLOWNOISE ]->IsDefined() )
{
params[ ALLOWNOISE ]->SetIntValue( 1 );
}
if ( !params[ NOISESCALE ]->IsDefined() )
{
params[ NOISESCALE ]->SetFloatValue( 1.0f );
}
if ( !params[ NOISEENABLE ]->IsDefined() )
{
params[ NOISEENABLE ]->SetIntValue( 0 );
}
if ( !params[ ALLOWVIGNETTE ]->IsDefined() )
{
params[ ALLOWVIGNETTE ]->SetIntValue( 1 );
}
if ( !params[ VIGNETTEENABLE ]->IsDefined() )
{
params[ VIGNETTEENABLE ]->SetIntValue( 0 );
}
if ( !params[ ALLOWLOCALCONTRAST ]->IsDefined() )
{
params[ ALLOWLOCALCONTRAST ]->SetIntValue( 1 );
}
if ( !params[ LOCALCONTRASTSCALE ]->IsDefined() )
{
params[ LOCALCONTRASTSCALE ]->SetFloatValue( 1.0f );
}
if ( !params[ LOCALCONTRASTMIDTONEMASK ]->IsDefined() )
{
params[ LOCALCONTRASTMIDTONEMASK ]->SetFloatValue( 1000.0f );
}
if ( !params[ LOCALCONTRASTENABLE ]->IsDefined() )
{
params[ LOCALCONTRASTENABLE ]->SetIntValue( 0 );
}
if ( !params[ LOCALCONTRASTVIGNETTESTART ]->IsDefined() )
{
params[ LOCALCONTRASTVIGNETTESTART ]->SetFloatValue( 0.7f );
}
if ( !params[ LOCALCONTRASTVIGNETTEEND ]->IsDefined() )
{
params[ LOCALCONTRASTVIGNETTEEND ]->SetFloatValue( 1.0f );
}
if ( !params[ LOCALCONTRASTEDGESCALE ]->IsDefined() )
{
params[ LOCALCONTRASTEDGESCALE ]->SetFloatValue( 0.0f );
}
if ( !params[ BLURREDVIGNETTEENABLE ]->IsDefined() )
{
params[ BLURREDVIGNETTEENABLE ]->SetIntValue( 0 );
}
if ( !params[ BLURREDVIGNETTESCALE ]->IsDefined() )
{
params[ BLURREDVIGNETTESCALE ]->SetFloatValue( 0.0f );
}
if ( !params[ FADETOBLACKSCALE ]->IsDefined() )
{
params[ FADETOBLACKSCALE ]->SetFloatValue( 0.0f );
}
if ( !params[ DEPTHBLURFOCALDISTANCE ]->IsDefined() )
{
params[ DEPTHBLURFOCALDISTANCE ]->SetFloatValue( 0.0f );
}
if ( !params[ DEPTHBLURSTRENGTH ]->IsDefined() )
{
params[ DEPTHBLURSTRENGTH ]->SetFloatValue( 0.0f );
}
if ( !params[ SCREENBLURSTRENGTH ]->IsDefined() )
{
params[ SCREENBLURSTRENGTH ]->SetFloatValue( 0.0f );
}
if ( !params[ TOOLMODE ]->IsDefined() )
{
params[ TOOLMODE ]->SetIntValue( 0 );
}
if ( !params[ TOOLCOLORCORRECTION ]->IsDefined() )
{
params[ TOOLCOLORCORRECTION ]->SetFloatValue( 0.0f );
}
if ( !params[ VOMITENABLE ]->IsDefined() )
{
params[ VOMITENABLE ]->SetIntValue( 0 );
}
if ( !params[ VOMITREFRACTSCALE ]->IsDefined() )
{
params[ VOMITREFRACTSCALE ]->SetFloatValue( 0.15f );
}
if ( !params[ VOMITCOLOR1 ]->IsDefined() )
{
params[ VOMITCOLOR1 ]->SetVecValue( 1.0, 1.0, 0.0 );
}
if ( !params[ VOMITCOLOR2 ]->IsDefined() )
{
params[ VOMITCOLOR2 ]->SetVecValue( 0.0, 1.0, 0.0 );
}
if ( !params[ FADE ]->IsDefined() )
{
params[ FADE ]->SetIntValue( 0 );
}
if ( !params[ FADECOLOR ]->IsDefined() )
{
params[ FADECOLOR ]->SetVecValue( 0.0f, 0.0f, 0.0f, 0.0f );
}
if ( !params[ TV_GAMMA ]->IsDefined() )
{
params[ TV_GAMMA ]->SetIntValue( 0 );
}
if ( !params[ DESATURATEENABLE ]->IsDefined() )
{
params[ DESATURATEENABLE ]->SetIntValue( 0 );
}
if ( !params[ DESATURATION ]->IsDefined() )
{
params[ DESATURATION ]->SetFloatValue( 0.0f );
}
SET_FLAGS2( MATERIAL_VAR2_NEEDS_FULL_FRAME_BUFFER_TEXTURE );
}
SHADER_FALLBACK
{
// This shader should not be *used* unless we're >= DX9 (bloomadd.vmt/screenspace_general_dx8 should be used for DX8)
return 0;
}
SHADER_INIT
{
if ( params[BASETEXTURE]->IsDefined() )
{
LoadTexture( BASETEXTURE );
}
if ( params[FBTEXTURE]->IsDefined() )
{
LoadTexture( FBTEXTURE );
}
if ( params[SCREENEFFECTTEXTURE]->IsDefined() )
{
LoadTexture( SCREENEFFECTTEXTURE );
}
if ( params[NOISETEXTURE]->IsDefined() )
{
LoadTexture( NOISETEXTURE );
}
if ( params[INTERNAL_VIGNETTETEXTURE]->IsDefined() )
{
LoadTexture( INTERNAL_VIGNETTETEXTURE );
}
}
SHADER_DRAW
{
bool bToolMode = params[TOOLMODE]->GetIntValue() != 0;
bool bDepthBlurEnable = params[ DEPTHBLURENABLE ]->GetIntValue() != 0;
SHADOW_STATE
{
// This shader uses opaque blending, but needs to match the behaviour of bloom_add/screen_spacegeneral,
// which uses additive blending (and is used when bloom is enabled but col-correction and AA are not).
// BUT!
// Hardware sRGB blending is incorrect (on pre-DX10 cards, sRGB values are added directly).
// SO...
// When doing the bloom addition in the pixel shader, we need to emulate that incorrect
// behaviour - by turning sRGB read OFF for the FB texture and by turning sRGB write OFF
// (which is fine, since the AA process works better on an sRGB framebuffer than a linear
// one; gamma colours more closely match luminance perception. The color-correction process
// has always taken gamma-space values as input anyway).
pShaderShadow->EnableBlending( false );
// The (sRGB) bloom texture is bound to sampler 0
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, false );
pShaderShadow->EnableSRGBWrite( false );
// The (sRGB) full framebuffer texture is bound to sampler 1:
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, false );
// Up to 4 (sRGB) color-correction lookup textures are bound to samplers 2-5:
pShaderShadow->EnableTexture( SHADER_SAMPLER2, true );
pShaderShadow->EnableTexture( SHADER_SAMPLER3, true );
pShaderShadow->EnableTexture( SHADER_SAMPLER4, true );
pShaderShadow->EnableTexture( SHADER_SAMPLER5, true );
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER2, false );
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER3, false );
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER4, false );
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER5, false );
// Noise
pShaderShadow->EnableTexture( SHADER_SAMPLER6, true );
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER6, false );
// Vignette
pShaderShadow->EnableTexture( SHADER_SAMPLER7, true );
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER7, false );
// Screen effect texture
pShaderShadow->EnableTexture( SHADER_SAMPLER8, true );
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER8, false );
pShaderShadow->EnableSRGBWrite( false );
int format = VERTEX_POSITION;
int numTexCoords = 1;
int * pTexCoordDimensions = NULL;
int userDataSize = 0;
pShaderShadow->VertexShaderVertexFormat( format, numTexCoords, pTexCoordDimensions, userDataSize );
DECLARE_STATIC_VERTEX_SHADER( sdk_screenspaceeffect_vs20 );
SET_STATIC_VERTEX_SHADER( sdk_screenspaceeffect_vs20 );
DECLARE_STATIC_PIXEL_SHADER( sdk_engine_post_ps20b );
SET_STATIC_PIXEL_SHADER_COMBO( TOOL_MODE, bToolMode );
SET_STATIC_PIXEL_SHADER_COMBO( DEPTH_BLUR_ENABLE, bDepthBlurEnable );
SET_STATIC_PIXEL_SHADER( sdk_engine_post_ps20b );
}
DYNAMIC_STATE
{
BindTexture( SHADER_SAMPLER0, BASETEXTURE, -1 );
// FIXME: need to set FBTEXTURE to be point-sampled (will speed up this shader significantly on 360)
// and assert that it's set to SHADER_TEXWRAPMODE_CLAMP (since the shader will sample offscreen)
BindTexture( SHADER_SAMPLER1, FBTEXTURE, -1 );
ShaderColorCorrectionInfo_t ccInfo = { false, 0, 1.0f, { 1.0f, 1.0f, 1.0f, 1.0f } };
float flTime;
if ( bToolMode )
{
flTime = params[TOOLTIME]->GetFloatValue();
}
else
{
flTime = pShaderAPI->CurrentTime();
}
// PC, ps20b has a desaturation control that overrides color correction
bool bDesaturateEnable = bToolMode && ( params[DESATURATEENABLE]->GetIntValue() != 0 ) && g_pHardwareConfig->SupportsPixelShaders_2_b();
float vPsConst16[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
vPsConst16[0] = params[ DESATURATION ]->GetFloatValue();
vPsConst16[1] = ( params[FADE]->GetIntValue() == 2 ) ? 1.0f : 0.0f; // Enable lerping to ( color * fadecolor ) for FADE_COLOR=2
pShaderAPI->SetPixelShaderConstant( 16, vPsConst16, 1 );
if ( params[FADE]->GetIntValue() == 0 )
{
// Not fading, so set the constant to cause nothing to change about the pixel color
float vConst[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
pShaderAPI->SetPixelShaderConstant( 15, vConst );
}
else
{
pShaderAPI->SetPixelShaderConstant( 15, params[ FADECOLOR ]->GetVecValue(), 1 );
}
if ( !bDesaturateEnable ) // set up color correction
{
bool bToolColorCorrection = params[TOOLCOLORCORRECTION]->GetIntValue() != 0;
if ( bToolColorCorrection )
{
ccInfo.m_bIsEnabled = true;
ccInfo.m_nLookupCount = (int) params[NUM_LOOKUPS]->GetFloatValue();
ccInfo.m_flDefaultWeight = params[WEIGHT_DEFAULT]->GetFloatValue();
ccInfo.m_pLookupWeights[0] = params[WEIGHT0]->GetFloatValue();
ccInfo.m_pLookupWeights[1] = params[WEIGHT1]->GetFloatValue();
ccInfo.m_pLookupWeights[2] = params[WEIGHT2]->GetFloatValue();
ccInfo.m_pLookupWeights[3] = params[WEIGHT3]->GetFloatValue();
}
else
{
pShaderAPI->GetCurrentColorCorrection( &ccInfo );
}
}
int colCorrectNumLookups = MIN( ccInfo.m_nLookupCount, 3 );
for ( int i = 0; i < colCorrectNumLookups; i++ )
{
pShaderAPI->BindStandardTexture( (Sampler_t)(SHADER_SAMPLER2 + i), (StandardTextureId_t)(TEXTURE_COLOR_CORRECTION_VOLUME_0 + i) );
}
// Upload 1-pixel X&Y offsets [ (+dX,0,+dY,-dX) is chosen to work with the allowed ps20 swizzles ]
// The shader will sample in a cross (up/down/left/right from the current sample), for 5-tap
// (quality 0) mode and add another 4 samples in a diagonal cross, for 9-tap (quality 1) mode
ITexture * pTarget = params[FBTEXTURE]->GetTextureValue();
int width = pTarget->GetActualWidth();
int height = pTarget->GetActualHeight();
float dX = 1.0f / width;
float dY = 1.0f / height;
float offsets[4] = { +dX, 0, +dY, -dX };
pShaderAPI->SetPixelShaderConstant( 0, &offsets[0], 1 );
// Upload AA tweakables:
// x - strength (this can be used to toggle the AA off, or to weaken it where pathological cases are showing)
// y - reduction of 1-pixel-line blurring (blurring of 1-pixel lines causes issues, so it's tunable)
// z - edge threshold multiplier (default 1.0, < 1.0 => more edges softened, > 1.0 => fewer edges softened)
// w - tap offset multiplier (default 1.0, < 1.0 => sharper image, > 1.0 => blurrier image)
float tweakables[4] = { params[ AAINTERNAL1 ]->GetVecValue()[0],
params[ AAINTERNAL1 ]->GetVecValue()[1],
params[ AAINTERNAL3 ]->GetVecValue()[0],
params[ AAINTERNAL3 ]->GetVecValue()[1] };
pShaderAPI->SetPixelShaderConstant( 1, &tweakables[0], 1 );
// Upload AA UV transform (converts bloom texture UVs to framebuffer texture UVs)
// NOTE: we swap the order of the z and w components since 'wz' is an allowed ps20 swizzle, but 'zw' is not:
float uvTrans[4] = { params[ AAINTERNAL2 ]->GetVecValue()[0],
params[ AAINTERNAL2 ]->GetVecValue()[1],
params[ AAINTERNAL2 ]->GetVecValue()[3],
params[ AAINTERNAL2 ]->GetVecValue()[2] };
pShaderAPI->SetPixelShaderConstant( 2, &uvTrans[0], 1 );
// Upload color-correction weights:
pShaderAPI->SetPixelShaderConstant( 3, &ccInfo.m_flDefaultWeight );
pShaderAPI->SetPixelShaderConstant( 4, ccInfo.m_pLookupWeights );
int aaEnabled = 0;
int bloomEnabled = ( params[ BLOOMENABLE ]->GetIntValue() == 0 ) ? 0 : 1;
int colCorrectEnabled = ccInfo.m_bIsEnabled;
float flBloomFactor = bloomEnabled ? 1.0f : 0.0f;
flBloomFactor *= params[BLOOMAMOUNT]->GetFloatValue();
float bloomConstant[4] =
{
flBloomFactor,
params[ SCREENBLURSTRENGTH ]->GetFloatValue(),
params[ DEPTHBLURFOCALDISTANCE ]->GetFloatValue(),
params[ DEPTHBLURSTRENGTH ]->GetFloatValue()
};
if ( mat_screen_blur_override.GetFloat() >= 0.0f )
{
bloomConstant[1] = mat_screen_blur_override.GetFloat();
}
if ( mat_depth_blur_focal_distance_override.GetFloat() >= 0.0f )
{
bloomConstant[2] = mat_depth_blur_focal_distance_override.GetFloat();
}
if ( mat_depth_blur_strength_override.GetFloat() >= 0.0f )
{
bloomConstant[3] = mat_depth_blur_strength_override.GetFloat();
}
pShaderAPI->SetPixelShaderConstant( 5, bloomConstant );
// Vignette
bool bVignetteEnable = ( params[ VIGNETTEENABLE ]->GetIntValue() != 0 ) && ( params[ ALLOWVIGNETTE ]->GetIntValue() != 0 );
if ( bVignetteEnable )
{
BindTexture( SHADER_SAMPLER7, INTERNAL_VIGNETTETEXTURE );
}
// Noise
bool bNoiseEnable = ( params[ NOISEENABLE ]->GetIntValue() != 0 ) && ( params[ ALLOWNOISE ]->GetIntValue() != 0 );
int nFbTextureHeight = params[FBTEXTURE]->GetTextureValue()->GetActualHeight();
if ( nFbTextureHeight < 720 )
{
// Disable noise at low resolutions
bNoiseEnable = false;
}
if ( bNoiseEnable )
{
BindTexture( SHADER_SAMPLER6, NOISETEXTURE );
// Noise scale
float vPsConst6[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
vPsConst6[0] = params[ NOISESCALE ]->GetFloatValue();
if ( mat_grain_scale_override.GetFloat() != -1.0f )
{
vPsConst6[0] = mat_grain_scale_override.GetFloat();
}
if ( vPsConst6[0] <= 0.0f )
{
bNoiseEnable = false;
}
pShaderAPI->SetPixelShaderConstant( 6, vPsConst6 );
// Time % 1000 for scrolling
float vPsConst[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
vPsConst[0] = flTime;
vPsConst[0] -= (float)( (int)( vPsConst[0] / 1000.0f ) ) * 1000.0f;
pShaderAPI->SetPixelShaderConstant( 7, vPsConst, 1 );
}
// Local Contrast
bool bLocalContrastEnable = ( params[ LOCALCONTRASTENABLE ]->GetIntValue() != 0 ) && ( params[ ALLOWLOCALCONTRAST ]->GetIntValue() != 0 );
bool bBlurredVignetteEnable = ( bLocalContrastEnable ) && ( params[ BLURREDVIGNETTEENABLE ]->GetIntValue() != 0 );
if ( bLocalContrastEnable )
{
// Contrast scale
float vPsConst[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
vPsConst[0] = params[ LOCALCONTRASTSCALE ]->GetFloatValue();
if ( mat_local_contrast_scale_override.GetFloat() != 0.0f )
{
vPsConst[0] = mat_local_contrast_scale_override.GetFloat();
}
vPsConst[1] = params[ LOCALCONTRASTMIDTONEMASK ]->GetFloatValue();
if ( mat_local_contrast_midtone_mask_override.GetFloat() >= 0.0f )
{
vPsConst[1] = mat_local_contrast_midtone_mask_override.GetFloat();
}
vPsConst[2] = params[ BLURREDVIGNETTESCALE ]->GetFloatValue();
pShaderAPI->SetPixelShaderConstant( 8, vPsConst, 1 );
vPsConst[0] = params[ LOCALCONTRASTVIGNETTESTART ]->GetFloatValue();
if ( mat_local_contrast_vignette_start_override.GetFloat() >= 0.0f )
{
vPsConst[0] = mat_local_contrast_vignette_start_override.GetFloat();
}
vPsConst[1] = params[ LOCALCONTRASTVIGNETTEEND ]->GetFloatValue();
if ( mat_local_contrast_vignette_end_override.GetFloat() >= 0.0f )
{
vPsConst[1] = mat_local_contrast_vignette_end_override.GetFloat();
}
vPsConst[2] = params[ LOCALCONTRASTEDGESCALE ]->GetFloatValue();
if ( mat_local_contrast_edge_scale_override.GetFloat() >= -1.0f )
{
vPsConst[2] = mat_local_contrast_edge_scale_override.GetFloat();
}
pShaderAPI->SetPixelShaderConstant( 9, vPsConst, 1 );
}
// fade to black
float vPsConst[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
vPsConst[0] = params[ FADETOBLACKSCALE ]->GetFloatValue();
pShaderAPI->SetPixelShaderConstant( 10, vPsConst, 1 );
bool bVomitEnable = ( params[ VOMITENABLE ]->GetIntValue() != 0 );
if ( bVomitEnable )
{
BindTexture( SHADER_SAMPLER8, SCREENEFFECTTEXTURE );
params[ VOMITCOLOR1 ]->GetVecValue( vPsConst, 3 );
vPsConst[3] = params[ VOMITREFRACTSCALE ]->GetFloatValue();
pShaderAPI->SetPixelShaderConstant( 11, vPsConst, 1 );
params[ VOMITCOLOR2 ]->GetVecValue( vPsConst, 3 );
vPsConst[3] = 0.0f;
pShaderAPI->SetPixelShaderConstant( 12, vPsConst, 1 );
// Get viewport and render target dimensions and set shader constant to do a 2D mad
ShaderViewport_t vp;
pShaderAPI->GetViewports( &vp, 1 );
int nViewportX = vp.m_nTopLeftX;
int nViewportY = vp.m_nTopLeftY;
int nViewportWidth = vp.m_nWidth;
int nViewportHeight = vp.m_nHeight;
int nRtWidth, nRtHeight;
ITexture *pRenderTarget = pShaderAPI->GetRenderTargetEx( 0 );
if( pRenderTarget != nullptr )
{
nRtWidth = pRenderTarget->GetActualWidth();
nRtHeight = pRenderTarget->GetActualHeight();
}
else
{
pShaderAPI->GetBackBufferDimensions( nRtWidth, nRtHeight );
}
float vViewportMad[4];
// screen->viewport transform
vViewportMad[0] = ( float )nRtWidth / ( float )nViewportWidth;
vViewportMad[1] = ( float )nRtHeight / ( float )nViewportHeight;
vViewportMad[2] = -( float )nViewportX / ( float )nViewportWidth;
vViewportMad[3] = -( float )nViewportY / ( float )nViewportHeight;
pShaderAPI->SetPixelShaderConstant( 13, vViewportMad, 1 );
// viewport->screen transform
vViewportMad[0] = ( float )nViewportWidth / ( float )nRtWidth;
vViewportMad[1] = ( float )nViewportHeight / ( float )nRtHeight;
vViewportMad[2] = ( float )nViewportX / ( float )nRtWidth;
vViewportMad[3] = ( float )nViewportY / ( float )nRtHeight;
pShaderAPI->SetPixelShaderConstant( 14, vViewportMad, 1 );
}
if ( !colCorrectEnabled )
{
colCorrectNumLookups = 0;
}
bool bConvertFromLinear = ( g_pHardwareConfig->GetHDRType() == HDR_TYPE_FLOAT );
// JasonM - double check this if the SFM needs to use the engine post FX clip in main
bool bConvertToLinear = bToolMode && bConvertFromLinear && ( g_pHardwareConfig->GetHDRType() == HDR_TYPE_FLOAT );
DECLARE_DYNAMIC_PIXEL_SHADER( sdk_engine_post_ps20b );
SET_DYNAMIC_PIXEL_SHADER_COMBO( AA_ENABLE, aaEnabled );
SET_DYNAMIC_PIXEL_SHADER_COMBO( COL_CORRECT_NUM_LOOKUPS, colCorrectNumLookups );
SET_DYNAMIC_PIXEL_SHADER_COMBO( CONVERT_FROM_LINEAR, bConvertFromLinear );
SET_DYNAMIC_PIXEL_SHADER_COMBO( CONVERT_TO_LINEAR, bConvertToLinear );
SET_DYNAMIC_PIXEL_SHADER_COMBO( NOISE_ENABLE, bNoiseEnable );
SET_DYNAMIC_PIXEL_SHADER_COMBO( VIGNETTE_ENABLE, bVignetteEnable );
SET_DYNAMIC_PIXEL_SHADER_COMBO( LOCAL_CONTRAST_ENABLE, bLocalContrastEnable );
SET_DYNAMIC_PIXEL_SHADER_COMBO( BLURRED_VIGNETTE_ENABLE, bBlurredVignetteEnable );
SET_DYNAMIC_PIXEL_SHADER_COMBO( VOMIT_ENABLE, bVomitEnable );
SET_DYNAMIC_PIXEL_SHADER_COMBO( TV_GAMMA, params[TV_GAMMA]->GetIntValue() && bToolMode ? 1 : 0 );
SET_DYNAMIC_PIXEL_SHADER_COMBO( DESATURATEENABLE, bDesaturateEnable );
SET_DYNAMIC_PIXEL_SHADER( sdk_engine_post_ps20b );
DECLARE_DYNAMIC_VERTEX_SHADER( sdk_screenspaceeffect_vs20 );
SET_DYNAMIC_VERTEX_SHADER( sdk_screenspaceeffect_vs20 );
}
Draw();
}
END_SHADER

View File

@@ -0,0 +1,33 @@
#include "shaderlib/cshader.h"
class blurgaussian_3x3_ps20_Static_Index
{
public:
blurgaussian_3x3_ps20_Static_Index( )
{
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
#endif // _DEBUG
return 0;
}
};
#define shaderStaticTest_blurgaussian_3x3_ps20 0
class blurgaussian_3x3_ps20_Dynamic_Index
{
public:
blurgaussian_3x3_ps20_Dynamic_Index()
{
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
#endif // _DEBUG
return 0;
}
};
#define shaderDynamicTest_blurgaussian_3x3_ps20 0

View File

@@ -0,0 +1,33 @@
#include "shaderlib/cshader.h"
class blurgaussian_3x3_ps20b_Static_Index
{
public:
blurgaussian_3x3_ps20b_Static_Index( )
{
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
#endif // _DEBUG
return 0;
}
};
#define shaderStaticTest_blurgaussian_3x3_ps20b 0
class blurgaussian_3x3_ps20b_Dynamic_Index
{
public:
blurgaussian_3x3_ps20b_Dynamic_Index()
{
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
#endif // _DEBUG
return 0;
}
};
#define shaderDynamicTest_blurgaussian_3x3_ps20b 0

View File

@@ -0,0 +1,60 @@
#include "shaderlib/cshader.h"
class depth_of_field_ps20b_Static_Index
{
public:
depth_of_field_ps20b_Static_Index( )
{
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
#endif // _DEBUG
return 0;
}
};
#define shaderStaticTest_depth_of_field_ps20b 0
class depth_of_field_ps20b_Dynamic_Index
{
private:
int m_nQUALITY;
#ifdef _DEBUG
bool m_bQUALITY;
#endif
public:
void SetQUALITY( int i )
{
Assert( i >= 0 && i <= 3 );
m_nQUALITY = i;
#ifdef _DEBUG
m_bQUALITY = true;
#endif
}
void SetQUALITY( bool i )
{
m_nQUALITY = i ? 1 : 0;
#ifdef _DEBUG
m_bQUALITY = true;
#endif
}
public:
depth_of_field_ps20b_Dynamic_Index()
{
#ifdef _DEBUG
m_bQUALITY = false;
#endif // _DEBUG
m_nQUALITY = 0;
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
bool bAllDynamicVarsDefined = m_bQUALITY;
Assert( bAllDynamicVarsDefined );
#endif // _DEBUG
return ( 1 * m_nQUALITY ) + 0;
}
};
#define shaderDynamicTest_depth_of_field_ps20b psh_forgot_to_set_dynamic_QUALITY + 0

View File

@@ -0,0 +1,33 @@
#include "shaderlib/cshader.h"
class depth_of_field_vs20_Static_Index
{
public:
depth_of_field_vs20_Static_Index( )
{
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
#endif // _DEBUG
return 0;
}
};
#define shaderStaticTest_depth_of_field_vs20 0
class depth_of_field_vs20_Dynamic_Index
{
public:
depth_of_field_vs20_Dynamic_Index()
{
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
#endif // _DEBUG
return 0;
}
};
#define shaderDynamicTest_depth_of_field_vs20 0

View File

@@ -0,0 +1,362 @@
#include "shaderlib/cshader.h"
class engine_post_ps20b_Static_Index
{
private:
int m_nTOOL_MODE;
#ifdef _DEBUG
bool m_bTOOL_MODE;
#endif
public:
void SetTOOL_MODE( int i )
{
Assert( i >= 0 && i <= 1 );
m_nTOOL_MODE = i;
#ifdef _DEBUG
m_bTOOL_MODE = true;
#endif
}
void SetTOOL_MODE( bool i )
{
m_nTOOL_MODE = i ? 1 : 0;
#ifdef _DEBUG
m_bTOOL_MODE = true;
#endif
}
private:
int m_nDEPTH_BLUR_ENABLE;
#ifdef _DEBUG
bool m_bDEPTH_BLUR_ENABLE;
#endif
public:
void SetDEPTH_BLUR_ENABLE( int i )
{
Assert( i >= 0 && i <= 1 );
m_nDEPTH_BLUR_ENABLE = i;
#ifdef _DEBUG
m_bDEPTH_BLUR_ENABLE = true;
#endif
}
void SetDEPTH_BLUR_ENABLE( bool i )
{
m_nDEPTH_BLUR_ENABLE = i ? 1 : 0;
#ifdef _DEBUG
m_bDEPTH_BLUR_ENABLE = true;
#endif
}
public:
engine_post_ps20b_Static_Index( )
{
#ifdef _DEBUG
m_bTOOL_MODE = false;
#endif // _DEBUG
m_nTOOL_MODE = 0;
#ifdef _DEBUG
m_bDEPTH_BLUR_ENABLE = false;
#endif // _DEBUG
m_nDEPTH_BLUR_ENABLE = 0;
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
bool bAllStaticVarsDefined = m_bTOOL_MODE && m_bDEPTH_BLUR_ENABLE;
Assert( bAllStaticVarsDefined );
#endif // _DEBUG
return ( 2048 * m_nTOOL_MODE ) + ( 4096 * m_nDEPTH_BLUR_ENABLE ) + 0;
}
};
#define shaderStaticTest_engine_post_ps20b psh_forgot_to_set_static_TOOL_MODE + psh_forgot_to_set_static_DEPTH_BLUR_ENABLE + 0
class engine_post_ps20b_Dynamic_Index
{
private:
int m_nAA_ENABLE;
#ifdef _DEBUG
bool m_bAA_ENABLE;
#endif
public:
void SetAA_ENABLE( int i )
{
Assert( i >= 0 && i <= 0 );
m_nAA_ENABLE = i;
#ifdef _DEBUG
m_bAA_ENABLE = true;
#endif
}
void SetAA_ENABLE( bool i )
{
m_nAA_ENABLE = i ? 1 : 0;
#ifdef _DEBUG
m_bAA_ENABLE = true;
#endif
}
private:
int m_nCOL_CORRECT_NUM_LOOKUPS;
#ifdef _DEBUG
bool m_bCOL_CORRECT_NUM_LOOKUPS;
#endif
public:
void SetCOL_CORRECT_NUM_LOOKUPS( int i )
{
Assert( i >= 0 && i <= 3 );
m_nCOL_CORRECT_NUM_LOOKUPS = i;
#ifdef _DEBUG
m_bCOL_CORRECT_NUM_LOOKUPS = true;
#endif
}
void SetCOL_CORRECT_NUM_LOOKUPS( bool i )
{
m_nCOL_CORRECT_NUM_LOOKUPS = i ? 1 : 0;
#ifdef _DEBUG
m_bCOL_CORRECT_NUM_LOOKUPS = true;
#endif
}
private:
int m_nCONVERT_FROM_LINEAR;
#ifdef _DEBUG
bool m_bCONVERT_FROM_LINEAR;
#endif
public:
void SetCONVERT_FROM_LINEAR( int i )
{
Assert( i >= 0 && i <= 1 );
m_nCONVERT_FROM_LINEAR = i;
#ifdef _DEBUG
m_bCONVERT_FROM_LINEAR = true;
#endif
}
void SetCONVERT_FROM_LINEAR( bool i )
{
m_nCONVERT_FROM_LINEAR = i ? 1 : 0;
#ifdef _DEBUG
m_bCONVERT_FROM_LINEAR = true;
#endif
}
private:
int m_nCONVERT_TO_LINEAR;
#ifdef _DEBUG
bool m_bCONVERT_TO_LINEAR;
#endif
public:
void SetCONVERT_TO_LINEAR( int i )
{
Assert( i >= 0 && i <= 1 );
m_nCONVERT_TO_LINEAR = i;
#ifdef _DEBUG
m_bCONVERT_TO_LINEAR = true;
#endif
}
void SetCONVERT_TO_LINEAR( bool i )
{
m_nCONVERT_TO_LINEAR = i ? 1 : 0;
#ifdef _DEBUG
m_bCONVERT_TO_LINEAR = true;
#endif
}
private:
int m_nNOISE_ENABLE;
#ifdef _DEBUG
bool m_bNOISE_ENABLE;
#endif
public:
void SetNOISE_ENABLE( int i )
{
Assert( i >= 0 && i <= 1 );
m_nNOISE_ENABLE = i;
#ifdef _DEBUG
m_bNOISE_ENABLE = true;
#endif
}
void SetNOISE_ENABLE( bool i )
{
m_nNOISE_ENABLE = i ? 1 : 0;
#ifdef _DEBUG
m_bNOISE_ENABLE = true;
#endif
}
private:
int m_nVIGNETTE_ENABLE;
#ifdef _DEBUG
bool m_bVIGNETTE_ENABLE;
#endif
public:
void SetVIGNETTE_ENABLE( int i )
{
Assert( i >= 0 && i <= 1 );
m_nVIGNETTE_ENABLE = i;
#ifdef _DEBUG
m_bVIGNETTE_ENABLE = true;
#endif
}
void SetVIGNETTE_ENABLE( bool i )
{
m_nVIGNETTE_ENABLE = i ? 1 : 0;
#ifdef _DEBUG
m_bVIGNETTE_ENABLE = true;
#endif
}
private:
int m_nLOCAL_CONTRAST_ENABLE;
#ifdef _DEBUG
bool m_bLOCAL_CONTRAST_ENABLE;
#endif
public:
void SetLOCAL_CONTRAST_ENABLE( int i )
{
Assert( i >= 0 && i <= 1 );
m_nLOCAL_CONTRAST_ENABLE = i;
#ifdef _DEBUG
m_bLOCAL_CONTRAST_ENABLE = true;
#endif
}
void SetLOCAL_CONTRAST_ENABLE( bool i )
{
m_nLOCAL_CONTRAST_ENABLE = i ? 1 : 0;
#ifdef _DEBUG
m_bLOCAL_CONTRAST_ENABLE = true;
#endif
}
private:
int m_nBLURRED_VIGNETTE_ENABLE;
#ifdef _DEBUG
bool m_bBLURRED_VIGNETTE_ENABLE;
#endif
public:
void SetBLURRED_VIGNETTE_ENABLE( int i )
{
Assert( i >= 0 && i <= 1 );
m_nBLURRED_VIGNETTE_ENABLE = i;
#ifdef _DEBUG
m_bBLURRED_VIGNETTE_ENABLE = true;
#endif
}
void SetBLURRED_VIGNETTE_ENABLE( bool i )
{
m_nBLURRED_VIGNETTE_ENABLE = i ? 1 : 0;
#ifdef _DEBUG
m_bBLURRED_VIGNETTE_ENABLE = true;
#endif
}
private:
int m_nVOMIT_ENABLE;
#ifdef _DEBUG
bool m_bVOMIT_ENABLE;
#endif
public:
void SetVOMIT_ENABLE( int i )
{
Assert( i >= 0 && i <= 1 );
m_nVOMIT_ENABLE = i;
#ifdef _DEBUG
m_bVOMIT_ENABLE = true;
#endif
}
void SetVOMIT_ENABLE( bool i )
{
m_nVOMIT_ENABLE = i ? 1 : 0;
#ifdef _DEBUG
m_bVOMIT_ENABLE = true;
#endif
}
private:
int m_nTV_GAMMA;
#ifdef _DEBUG
bool m_bTV_GAMMA;
#endif
public:
void SetTV_GAMMA( int i )
{
Assert( i >= 0 && i <= 1 );
m_nTV_GAMMA = i;
#ifdef _DEBUG
m_bTV_GAMMA = true;
#endif
}
void SetTV_GAMMA( bool i )
{
m_nTV_GAMMA = i ? 1 : 0;
#ifdef _DEBUG
m_bTV_GAMMA = true;
#endif
}
private:
int m_nDESATURATEENABLE;
#ifdef _DEBUG
bool m_bDESATURATEENABLE;
#endif
public:
void SetDESATURATEENABLE( int i )
{
Assert( i >= 0 && i <= 1 );
m_nDESATURATEENABLE = i;
#ifdef _DEBUG
m_bDESATURATEENABLE = true;
#endif
}
void SetDESATURATEENABLE( bool i )
{
m_nDESATURATEENABLE = i ? 1 : 0;
#ifdef _DEBUG
m_bDESATURATEENABLE = true;
#endif
}
public:
engine_post_ps20b_Dynamic_Index()
{
#ifdef _DEBUG
m_bAA_ENABLE = false;
#endif // _DEBUG
m_nAA_ENABLE = 0;
#ifdef _DEBUG
m_bCOL_CORRECT_NUM_LOOKUPS = false;
#endif // _DEBUG
m_nCOL_CORRECT_NUM_LOOKUPS = 0;
#ifdef _DEBUG
m_bCONVERT_FROM_LINEAR = false;
#endif // _DEBUG
m_nCONVERT_FROM_LINEAR = 0;
#ifdef _DEBUG
m_bCONVERT_TO_LINEAR = false;
#endif // _DEBUG
m_nCONVERT_TO_LINEAR = 0;
#ifdef _DEBUG
m_bNOISE_ENABLE = false;
#endif // _DEBUG
m_nNOISE_ENABLE = 0;
#ifdef _DEBUG
m_bVIGNETTE_ENABLE = false;
#endif // _DEBUG
m_nVIGNETTE_ENABLE = 0;
#ifdef _DEBUG
m_bLOCAL_CONTRAST_ENABLE = false;
#endif // _DEBUG
m_nLOCAL_CONTRAST_ENABLE = 0;
#ifdef _DEBUG
m_bBLURRED_VIGNETTE_ENABLE = false;
#endif // _DEBUG
m_nBLURRED_VIGNETTE_ENABLE = 0;
#ifdef _DEBUG
m_bVOMIT_ENABLE = false;
#endif // _DEBUG
m_nVOMIT_ENABLE = 0;
#ifdef _DEBUG
m_bTV_GAMMA = false;
#endif // _DEBUG
m_nTV_GAMMA = 0;
#ifdef _DEBUG
m_bDESATURATEENABLE = false;
#endif // _DEBUG
m_nDESATURATEENABLE = 0;
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
bool bAllDynamicVarsDefined = m_bAA_ENABLE && m_bCOL_CORRECT_NUM_LOOKUPS && m_bCONVERT_FROM_LINEAR && m_bCONVERT_TO_LINEAR && m_bNOISE_ENABLE && m_bVIGNETTE_ENABLE && m_bLOCAL_CONTRAST_ENABLE && m_bBLURRED_VIGNETTE_ENABLE && m_bVOMIT_ENABLE && m_bTV_GAMMA && m_bDESATURATEENABLE;
Assert( bAllDynamicVarsDefined );
#endif // _DEBUG
return ( 1 * m_nAA_ENABLE ) + ( 1 * m_nCOL_CORRECT_NUM_LOOKUPS ) + ( 4 * m_nCONVERT_FROM_LINEAR ) + ( 8 * m_nCONVERT_TO_LINEAR ) + ( 16 * m_nNOISE_ENABLE ) + ( 32 * m_nVIGNETTE_ENABLE ) + ( 64 * m_nLOCAL_CONTRAST_ENABLE ) + ( 128 * m_nBLURRED_VIGNETTE_ENABLE ) + ( 256 * m_nVOMIT_ENABLE ) + ( 512 * m_nTV_GAMMA ) + ( 1024 * m_nDESATURATEENABLE ) + 0;
}
};
#define shaderDynamicTest_engine_post_ps20b psh_forgot_to_set_dynamic_AA_ENABLE + psh_forgot_to_set_dynamic_COL_CORRECT_NUM_LOOKUPS + psh_forgot_to_set_dynamic_CONVERT_FROM_LINEAR + psh_forgot_to_set_dynamic_CONVERT_TO_LINEAR + psh_forgot_to_set_dynamic_NOISE_ENABLE + psh_forgot_to_set_dynamic_VIGNETTE_ENABLE + psh_forgot_to_set_dynamic_LOCAL_CONTRAST_ENABLE + psh_forgot_to_set_dynamic_BLURRED_VIGNETTE_ENABLE + psh_forgot_to_set_dynamic_VOMIT_ENABLE + psh_forgot_to_set_dynamic_TV_GAMMA + psh_forgot_to_set_dynamic_DESATURATEENABLE + 0

View File

@@ -0,0 +1,33 @@
#include "shaderlib/cshader.h"
class blurgaussian_3x3_ps20_Static_Index
{
public:
blurgaussian_3x3_ps20_Static_Index( )
{
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
#endif // _DEBUG
return 0;
}
};
#define shaderStaticTest_blurgaussian_3x3_ps20 0
class blurgaussian_3x3_ps20_Dynamic_Index
{
public:
blurgaussian_3x3_ps20_Dynamic_Index()
{
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
#endif // _DEBUG
return 0;
}
};
#define shaderDynamicTest_blurgaussian_3x3_ps20 0

View File

@@ -0,0 +1,33 @@
#include "shaderlib/cshader.h"
class blurgaussian_3x3_ps20b_Static_Index
{
public:
blurgaussian_3x3_ps20b_Static_Index( )
{
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
#endif // _DEBUG
return 0;
}
};
#define shaderStaticTest_blurgaussian_3x3_ps20b 0
class blurgaussian_3x3_ps20b_Dynamic_Index
{
public:
blurgaussian_3x3_ps20b_Dynamic_Index()
{
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
#endif // _DEBUG
return 0;
}
};
#define shaderDynamicTest_blurgaussian_3x3_ps20b 0

View File

@@ -0,0 +1,60 @@
#include "shaderlib/cshader.h"
class depth_of_field_ps20b_Static_Index
{
public:
depth_of_field_ps20b_Static_Index( )
{
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
#endif // _DEBUG
return 0;
}
};
#define shaderStaticTest_depth_of_field_ps20b 0
class depth_of_field_ps20b_Dynamic_Index
{
private:
int m_nQUALITY;
#ifdef _DEBUG
bool m_bQUALITY;
#endif
public:
void SetQUALITY( int i )
{
Assert( i >= 0 && i <= 3 );
m_nQUALITY = i;
#ifdef _DEBUG
m_bQUALITY = true;
#endif
}
void SetQUALITY( bool i )
{
m_nQUALITY = i ? 1 : 0;
#ifdef _DEBUG
m_bQUALITY = true;
#endif
}
public:
depth_of_field_ps20b_Dynamic_Index()
{
#ifdef _DEBUG
m_bQUALITY = false;
#endif // _DEBUG
m_nQUALITY = 0;
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
bool bAllDynamicVarsDefined = m_bQUALITY;
Assert( bAllDynamicVarsDefined );
#endif // _DEBUG
return ( 1 * m_nQUALITY ) + 0;
}
};
#define shaderDynamicTest_depth_of_field_ps20b psh_forgot_to_set_dynamic_QUALITY + 0

View File

@@ -0,0 +1,33 @@
#include "shaderlib/cshader.h"
class depth_of_field_vs20_Static_Index
{
public:
depth_of_field_vs20_Static_Index( )
{
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
#endif // _DEBUG
return 0;
}
};
#define shaderStaticTest_depth_of_field_vs20 0
class depth_of_field_vs20_Dynamic_Index
{
public:
depth_of_field_vs20_Dynamic_Index()
{
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
#endif // _DEBUG
return 0;
}
};
#define shaderDynamicTest_depth_of_field_vs20 0

View File

@@ -0,0 +1,362 @@
#include "shaderlib/cshader.h"
class engine_post_ps20b_Static_Index
{
private:
int m_nTOOL_MODE;
#ifdef _DEBUG
bool m_bTOOL_MODE;
#endif
public:
void SetTOOL_MODE( int i )
{
Assert( i >= 0 && i <= 1 );
m_nTOOL_MODE = i;
#ifdef _DEBUG
m_bTOOL_MODE = true;
#endif
}
void SetTOOL_MODE( bool i )
{
m_nTOOL_MODE = i ? 1 : 0;
#ifdef _DEBUG
m_bTOOL_MODE = true;
#endif
}
private:
int m_nDEPTH_BLUR_ENABLE;
#ifdef _DEBUG
bool m_bDEPTH_BLUR_ENABLE;
#endif
public:
void SetDEPTH_BLUR_ENABLE( int i )
{
Assert( i >= 0 && i <= 1 );
m_nDEPTH_BLUR_ENABLE = i;
#ifdef _DEBUG
m_bDEPTH_BLUR_ENABLE = true;
#endif
}
void SetDEPTH_BLUR_ENABLE( bool i )
{
m_nDEPTH_BLUR_ENABLE = i ? 1 : 0;
#ifdef _DEBUG
m_bDEPTH_BLUR_ENABLE = true;
#endif
}
public:
engine_post_ps20b_Static_Index( )
{
#ifdef _DEBUG
m_bTOOL_MODE = false;
#endif // _DEBUG
m_nTOOL_MODE = 0;
#ifdef _DEBUG
m_bDEPTH_BLUR_ENABLE = false;
#endif // _DEBUG
m_nDEPTH_BLUR_ENABLE = 0;
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
bool bAllStaticVarsDefined = m_bTOOL_MODE && m_bDEPTH_BLUR_ENABLE;
Assert( bAllStaticVarsDefined );
#endif // _DEBUG
return ( 2048 * m_nTOOL_MODE ) + ( 4096 * m_nDEPTH_BLUR_ENABLE ) + 0;
}
};
#define shaderStaticTest_engine_post_ps20b psh_forgot_to_set_static_TOOL_MODE + psh_forgot_to_set_static_DEPTH_BLUR_ENABLE + 0
class engine_post_ps20b_Dynamic_Index
{
private:
int m_nAA_ENABLE;
#ifdef _DEBUG
bool m_bAA_ENABLE;
#endif
public:
void SetAA_ENABLE( int i )
{
Assert( i >= 0 && i <= 0 );
m_nAA_ENABLE = i;
#ifdef _DEBUG
m_bAA_ENABLE = true;
#endif
}
void SetAA_ENABLE( bool i )
{
m_nAA_ENABLE = i ? 1 : 0;
#ifdef _DEBUG
m_bAA_ENABLE = true;
#endif
}
private:
int m_nCOL_CORRECT_NUM_LOOKUPS;
#ifdef _DEBUG
bool m_bCOL_CORRECT_NUM_LOOKUPS;
#endif
public:
void SetCOL_CORRECT_NUM_LOOKUPS( int i )
{
Assert( i >= 0 && i <= 3 );
m_nCOL_CORRECT_NUM_LOOKUPS = i;
#ifdef _DEBUG
m_bCOL_CORRECT_NUM_LOOKUPS = true;
#endif
}
void SetCOL_CORRECT_NUM_LOOKUPS( bool i )
{
m_nCOL_CORRECT_NUM_LOOKUPS = i ? 1 : 0;
#ifdef _DEBUG
m_bCOL_CORRECT_NUM_LOOKUPS = true;
#endif
}
private:
int m_nCONVERT_FROM_LINEAR;
#ifdef _DEBUG
bool m_bCONVERT_FROM_LINEAR;
#endif
public:
void SetCONVERT_FROM_LINEAR( int i )
{
Assert( i >= 0 && i <= 1 );
m_nCONVERT_FROM_LINEAR = i;
#ifdef _DEBUG
m_bCONVERT_FROM_LINEAR = true;
#endif
}
void SetCONVERT_FROM_LINEAR( bool i )
{
m_nCONVERT_FROM_LINEAR = i ? 1 : 0;
#ifdef _DEBUG
m_bCONVERT_FROM_LINEAR = true;
#endif
}
private:
int m_nCONVERT_TO_LINEAR;
#ifdef _DEBUG
bool m_bCONVERT_TO_LINEAR;
#endif
public:
void SetCONVERT_TO_LINEAR( int i )
{
Assert( i >= 0 && i <= 1 );
m_nCONVERT_TO_LINEAR = i;
#ifdef _DEBUG
m_bCONVERT_TO_LINEAR = true;
#endif
}
void SetCONVERT_TO_LINEAR( bool i )
{
m_nCONVERT_TO_LINEAR = i ? 1 : 0;
#ifdef _DEBUG
m_bCONVERT_TO_LINEAR = true;
#endif
}
private:
int m_nNOISE_ENABLE;
#ifdef _DEBUG
bool m_bNOISE_ENABLE;
#endif
public:
void SetNOISE_ENABLE( int i )
{
Assert( i >= 0 && i <= 1 );
m_nNOISE_ENABLE = i;
#ifdef _DEBUG
m_bNOISE_ENABLE = true;
#endif
}
void SetNOISE_ENABLE( bool i )
{
m_nNOISE_ENABLE = i ? 1 : 0;
#ifdef _DEBUG
m_bNOISE_ENABLE = true;
#endif
}
private:
int m_nVIGNETTE_ENABLE;
#ifdef _DEBUG
bool m_bVIGNETTE_ENABLE;
#endif
public:
void SetVIGNETTE_ENABLE( int i )
{
Assert( i >= 0 && i <= 1 );
m_nVIGNETTE_ENABLE = i;
#ifdef _DEBUG
m_bVIGNETTE_ENABLE = true;
#endif
}
void SetVIGNETTE_ENABLE( bool i )
{
m_nVIGNETTE_ENABLE = i ? 1 : 0;
#ifdef _DEBUG
m_bVIGNETTE_ENABLE = true;
#endif
}
private:
int m_nLOCAL_CONTRAST_ENABLE;
#ifdef _DEBUG
bool m_bLOCAL_CONTRAST_ENABLE;
#endif
public:
void SetLOCAL_CONTRAST_ENABLE( int i )
{
Assert( i >= 0 && i <= 1 );
m_nLOCAL_CONTRAST_ENABLE = i;
#ifdef _DEBUG
m_bLOCAL_CONTRAST_ENABLE = true;
#endif
}
void SetLOCAL_CONTRAST_ENABLE( bool i )
{
m_nLOCAL_CONTRAST_ENABLE = i ? 1 : 0;
#ifdef _DEBUG
m_bLOCAL_CONTRAST_ENABLE = true;
#endif
}
private:
int m_nBLURRED_VIGNETTE_ENABLE;
#ifdef _DEBUG
bool m_bBLURRED_VIGNETTE_ENABLE;
#endif
public:
void SetBLURRED_VIGNETTE_ENABLE( int i )
{
Assert( i >= 0 && i <= 1 );
m_nBLURRED_VIGNETTE_ENABLE = i;
#ifdef _DEBUG
m_bBLURRED_VIGNETTE_ENABLE = true;
#endif
}
void SetBLURRED_VIGNETTE_ENABLE( bool i )
{
m_nBLURRED_VIGNETTE_ENABLE = i ? 1 : 0;
#ifdef _DEBUG
m_bBLURRED_VIGNETTE_ENABLE = true;
#endif
}
private:
int m_nVOMIT_ENABLE;
#ifdef _DEBUG
bool m_bVOMIT_ENABLE;
#endif
public:
void SetVOMIT_ENABLE( int i )
{
Assert( i >= 0 && i <= 1 );
m_nVOMIT_ENABLE = i;
#ifdef _DEBUG
m_bVOMIT_ENABLE = true;
#endif
}
void SetVOMIT_ENABLE( bool i )
{
m_nVOMIT_ENABLE = i ? 1 : 0;
#ifdef _DEBUG
m_bVOMIT_ENABLE = true;
#endif
}
private:
int m_nTV_GAMMA;
#ifdef _DEBUG
bool m_bTV_GAMMA;
#endif
public:
void SetTV_GAMMA( int i )
{
Assert( i >= 0 && i <= 1 );
m_nTV_GAMMA = i;
#ifdef _DEBUG
m_bTV_GAMMA = true;
#endif
}
void SetTV_GAMMA( bool i )
{
m_nTV_GAMMA = i ? 1 : 0;
#ifdef _DEBUG
m_bTV_GAMMA = true;
#endif
}
private:
int m_nDESATURATEENABLE;
#ifdef _DEBUG
bool m_bDESATURATEENABLE;
#endif
public:
void SetDESATURATEENABLE( int i )
{
Assert( i >= 0 && i <= 1 );
m_nDESATURATEENABLE = i;
#ifdef _DEBUG
m_bDESATURATEENABLE = true;
#endif
}
void SetDESATURATEENABLE( bool i )
{
m_nDESATURATEENABLE = i ? 1 : 0;
#ifdef _DEBUG
m_bDESATURATEENABLE = true;
#endif
}
public:
engine_post_ps20b_Dynamic_Index()
{
#ifdef _DEBUG
m_bAA_ENABLE = false;
#endif // _DEBUG
m_nAA_ENABLE = 0;
#ifdef _DEBUG
m_bCOL_CORRECT_NUM_LOOKUPS = false;
#endif // _DEBUG
m_nCOL_CORRECT_NUM_LOOKUPS = 0;
#ifdef _DEBUG
m_bCONVERT_FROM_LINEAR = false;
#endif // _DEBUG
m_nCONVERT_FROM_LINEAR = 0;
#ifdef _DEBUG
m_bCONVERT_TO_LINEAR = false;
#endif // _DEBUG
m_nCONVERT_TO_LINEAR = 0;
#ifdef _DEBUG
m_bNOISE_ENABLE = false;
#endif // _DEBUG
m_nNOISE_ENABLE = 0;
#ifdef _DEBUG
m_bVIGNETTE_ENABLE = false;
#endif // _DEBUG
m_nVIGNETTE_ENABLE = 0;
#ifdef _DEBUG
m_bLOCAL_CONTRAST_ENABLE = false;
#endif // _DEBUG
m_nLOCAL_CONTRAST_ENABLE = 0;
#ifdef _DEBUG
m_bBLURRED_VIGNETTE_ENABLE = false;
#endif // _DEBUG
m_nBLURRED_VIGNETTE_ENABLE = 0;
#ifdef _DEBUG
m_bVOMIT_ENABLE = false;
#endif // _DEBUG
m_nVOMIT_ENABLE = 0;
#ifdef _DEBUG
m_bTV_GAMMA = false;
#endif // _DEBUG
m_nTV_GAMMA = 0;
#ifdef _DEBUG
m_bDESATURATEENABLE = false;
#endif // _DEBUG
m_nDESATURATEENABLE = 0;
}
int GetIndex()
{
// Asserts to make sure that we aren't using any skipped combinations.
// Asserts to make sure that we are setting all of the combination vars.
#ifdef _DEBUG
bool bAllDynamicVarsDefined = m_bAA_ENABLE && m_bCOL_CORRECT_NUM_LOOKUPS && m_bCONVERT_FROM_LINEAR && m_bCONVERT_TO_LINEAR && m_bNOISE_ENABLE && m_bVIGNETTE_ENABLE && m_bLOCAL_CONTRAST_ENABLE && m_bBLURRED_VIGNETTE_ENABLE && m_bVOMIT_ENABLE && m_bTV_GAMMA && m_bDESATURATEENABLE;
Assert( bAllDynamicVarsDefined );
#endif // _DEBUG
return ( 1 * m_nAA_ENABLE ) + ( 1 * m_nCOL_CORRECT_NUM_LOOKUPS ) + ( 4 * m_nCONVERT_FROM_LINEAR ) + ( 8 * m_nCONVERT_TO_LINEAR ) + ( 16 * m_nNOISE_ENABLE ) + ( 32 * m_nVIGNETTE_ENABLE ) + ( 64 * m_nLOCAL_CONTRAST_ENABLE ) + ( 128 * m_nBLURRED_VIGNETTE_ENABLE ) + ( 256 * m_nVOMIT_ENABLE ) + ( 512 * m_nTV_GAMMA ) + ( 1024 * m_nDESATURATEENABLE ) + 0;
}
};
#define shaderDynamicTest_engine_post_ps20b psh_forgot_to_set_dynamic_AA_ENABLE + psh_forgot_to_set_dynamic_COL_CORRECT_NUM_LOOKUPS + psh_forgot_to_set_dynamic_CONVERT_FROM_LINEAR + psh_forgot_to_set_dynamic_CONVERT_TO_LINEAR + psh_forgot_to_set_dynamic_NOISE_ENABLE + psh_forgot_to_set_dynamic_VIGNETTE_ENABLE + psh_forgot_to_set_dynamic_LOCAL_CONTRAST_ENABLE + psh_forgot_to_set_dynamic_BLURRED_VIGNETTE_ENABLE + psh_forgot_to_set_dynamic_VOMIT_ENABLE + psh_forgot_to_set_dynamic_TV_GAMMA + psh_forgot_to_set_dynamic_DESATURATEENABLE + 0

View File

@@ -61,6 +61,9 @@ $Project
$File "MonitorScreen_dx9.cpp"
$File "shatteredglass.cpp"
$File "windowimposter_dx90.cpp"
$File "engine_post_dx9.cpp"
$File "depthoffield_dx9.cpp"
}
//$Shaders "mapbase_dx9_20b.txt"

View File

@@ -227,7 +227,7 @@ void InitParamsLightmappedGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** pa
}
else if ( !params[info.m_nEnvmapMaskTransform]->MatrixIsIdentity() )
{
Warning( "Warning! material %s: $envmapmasktransform and $phong are mutial exclusive. Disabling phong..\n", pMaterialName );
Warning( "Warning! material %s: $envmapmasktransform and $phong are mutually exclusive. Disabling phong..\n", pMaterialName );
params[info.m_nPhong]->SetIntValue( 0 );
}
}

View File

@@ -95,3 +95,10 @@ SDK_ShatteredGlass_ps2x.fxc
SDK_ShatteredGlass_vs20.fxc
SDK_windowimposter_ps2x.fxc
SDK_windowimposter_vs20.fxc
SDK_engine_post_ps20b.fxc
depth_of_field_ps20b.fxc
depth_of_field_vs20.fxc
blurgaussian_3x3_ps2x.fxc