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.

825 lines
33 KiB

  1. //========= Copyright (c) 1996-2007, Valve LLC, All rights reserved. ============
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #include "BaseVSShader.h"
  8. #if !defined( _GAMECONSOLE )
  9. #include "engine_post_vs30.inc"
  10. #include "engine_post_ps30.inc"
  11. #endif
  12. #include "engine_post_vs20.inc"
  13. #include "engine_post_ps20.inc"
  14. #include "engine_post_ps20b.inc"
  15. #include "../materialsystem_global.h"
  16. // NOTE: This has to be the last file included!
  17. #include "tier0/memdbgon.h"
  18. ConVar mat_screen_blur_override( "mat_screen_blur_override", "-1.0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
  19. ConVar mat_depth_blur_focal_distance_override( "mat_depth_blur_focal_distance_override", "-1.0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
  20. ConVar mat_depth_blur_strength_override( "mat_depth_blur_strength_override", "-1.0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
  21. ConVar mat_grain_scale_override( "mat_grain_scale_override", "-1.0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
  22. ConVar mat_local_contrast_scale_override( "mat_local_contrast_scale_override", "0.0", FCVAR_CHEAT );
  23. ConVar mat_local_contrast_midtone_mask_override( "mat_local_contrast_midtone_mask_override", "-1.0", FCVAR_CHEAT );
  24. ConVar mat_local_contrast_vignette_start_override( "mat_local_contrast_vignette_start_override", "-1.0", FCVAR_CHEAT );
  25. ConVar mat_local_contrast_vignette_end_override( "mat_local_contrast_vignette_end_override", "-1.0", FCVAR_CHEAT );
  26. ConVar mat_local_contrast_edge_scale_override( "mat_local_contrast_edge_scale_override", "-1000.0", FCVAR_CHEAT );
  27. ConVar mat_vignette_enable( "mat_vignette_enable", "1", FCVAR_REPLICATED );
  28. ConVar mat_noise_enable( "mat_noise_enable", "0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
  29. DEFINE_FALLBACK_SHADER( Engine_Post, Engine_Post_dx9 )
  30. BEGIN_VS_SHADER_FLAGS( Engine_Post_dx9, "Engine post-processing effects (software anti-aliasing, bloom, color-correction", SHADER_NOT_EDITABLE )
  31. BEGIN_SHADER_PARAMS
  32. SHADER_PARAM( FBTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_FullFrameFB", "Full framebuffer texture" )
  33. SHADER_PARAM( AAENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Enable software anti-aliasing" )
  34. SHADER_PARAM( FXAAINTERNALC, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0]", "Internal fxaa Console values set via material proxy" )
  35. SHADER_PARAM( FXAAINTERNALQ, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0]", "Internal fxaa Quality values set via material proxy" )
  36. SHADER_PARAM( AAINTERNAL1, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0]", "Internal anti-aliasing values set via material proxy" )
  37. SHADER_PARAM( AAINTERNAL2, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0]", "Internal anti-aliasing values set via material proxy" )
  38. SHADER_PARAM( AAINTERNAL3, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0]", "Internal anti-aliasing values set via material proxy" )
  39. SHADER_PARAM( BLOOMENABLE, SHADER_PARAM_TYPE_BOOL, "1", "Enable bloom" )
  40. SHADER_PARAM( BLOOMAMOUNT, SHADER_PARAM_TYPE_FLOAT, "1.0", "Bloom scale factor" )
  41. SHADER_PARAM( SCREENEFFECTTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "used for paint or vomit screen effect" )
  42. SHADER_PARAM( DEPTHBLURENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Inexpensive depth-of-field substitute" )
  43. SHADER_PARAM( ALLOWVIGNETTE, SHADER_PARAM_TYPE_BOOL, "0", "Allow vignette" )
  44. SHADER_PARAM( VIGNETTEENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Enable vignette" )
  45. SHADER_PARAM( INTERNAL_VIGNETTETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "dev/vignette", "" )
  46. SHADER_PARAM( ALLOWNOISE, SHADER_PARAM_TYPE_BOOL, "0", "Allow noise" )
  47. SHADER_PARAM( NOISEENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Enable noise" )
  48. SHADER_PARAM( NOISESCALE, SHADER_PARAM_TYPE_FLOAT, "0", "Noise scale" )
  49. SHADER_PARAM( NOISETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "Noise texture" )
  50. SHADER_PARAM( ALLOWLOCALCONTRAST, SHADER_PARAM_TYPE_BOOL, "0", "Enable local contrast enhancement" )
  51. SHADER_PARAM( LOCALCONTRASTENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Enable local contrast enhancement" )
  52. SHADER_PARAM( LOCALCONTRASTSCALE, SHADER_PARAM_TYPE_FLOAT, "0", "Local contrast scale" )
  53. SHADER_PARAM( LOCALCONTRASTMIDTONEMASK, SHADER_PARAM_TYPE_FLOAT, "0", "Local contrast midtone mask" )
  54. SHADER_PARAM( LOCALCONTRASTVIGNETTESTART, SHADER_PARAM_TYPE_BOOL, "0", "Enable local contrast enhancement" )
  55. SHADER_PARAM( LOCALCONTRASTVIGNETTEEND, SHADER_PARAM_TYPE_FLOAT, "0", "Local contrast scale" )
  56. SHADER_PARAM( LOCALCONTRASTEDGESCALE, SHADER_PARAM_TYPE_FLOAT, "0", "Local contrast midtone mask" )
  57. SHADER_PARAM( BLURREDVIGNETTEENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Enable blurred vignette" )
  58. SHADER_PARAM( BLURREDVIGNETTESCALE, SHADER_PARAM_TYPE_FLOAT, "0", "blurred vignette strength" )
  59. SHADER_PARAM( FADETOBLACKSCALE, SHADER_PARAM_TYPE_FLOAT, "0", "fade strength" )
  60. SHADER_PARAM( DEPTHBLURFOCALDISTANCE, SHADER_PARAM_TYPE_FLOAT, "0", "Distance in dest-alpha space [0,1] of focal plane." )
  61. SHADER_PARAM( DEPTHBLURSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0", "Strength of depth-blur effect" )
  62. SHADER_PARAM( SCREENBLURSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0", "Full-screen blur factor" )
  63. SHADER_PARAM( VOMITCOLOR1, SHADER_PARAM_TYPE_VEC3, "[0 0 0 0]", "1st vomit blend color" )
  64. SHADER_PARAM( VOMITCOLOR2, SHADER_PARAM_TYPE_VEC3, "[0 0 0 0]", "2st vomit blend color" )
  65. SHADER_PARAM( VOMITREFRACTSCALE, SHADER_PARAM_TYPE_FLOAT, "0.15", "vomit refract strength" )
  66. SHADER_PARAM( VOMITENABLE, SHADER_PARAM_TYPE_BOOL, "0", "Enable vomit refract" )
  67. SHADER_PARAM( FADECOLOR, SHADER_PARAM_TYPE_VEC4, "[0 0 0 0]", "viewfade color" )
  68. SHADER_PARAM( FADE, SHADER_PARAM_TYPE_INTEGER, "0", "fade type. 0 = off, 1 = lerp, 2 = modulate" )
  69. SHADER_PARAM( TV_GAMMA, SHADER_PARAM_TYPE_INTEGER, "0", "0 default, 1 used for laying off 360 movies" )
  70. SHADER_PARAM( DESATURATEENABLE, SHADER_PARAM_TYPE_INTEGER, "0", "Desaturate with math, turns off color correction" )
  71. SHADER_PARAM( DESATURATION, SHADER_PARAM_TYPE_FLOAT, "0", "Desaturation Amount" )
  72. // Tool color correction setup
  73. SHADER_PARAM( TOOLMODE, SHADER_PARAM_TYPE_BOOL, "1", "tool mode" )
  74. SHADER_PARAM( TOOLCOLORCORRECTION, SHADER_PARAM_TYPE_FLOAT, "1", "tool color correction override" )
  75. SHADER_PARAM( WEIGHT_DEFAULT, SHADER_PARAM_TYPE_FLOAT, "1", "weight default" )
  76. SHADER_PARAM( WEIGHT0, SHADER_PARAM_TYPE_FLOAT, "1", "weight0" )
  77. SHADER_PARAM( WEIGHT1, SHADER_PARAM_TYPE_FLOAT, "1", "weight1" )
  78. SHADER_PARAM( WEIGHT2, SHADER_PARAM_TYPE_FLOAT, "1", "weight2" )
  79. SHADER_PARAM( WEIGHT3, SHADER_PARAM_TYPE_FLOAT, "1", "weight3" )
  80. SHADER_PARAM( NUM_LOOKUPS, SHADER_PARAM_TYPE_FLOAT, "0", "num_lookups" )
  81. SHADER_PARAM( TOOLTIME, SHADER_PARAM_TYPE_FLOAT, "0", "tooltime" )
  82. END_SHADER_PARAMS
  83. SHADER_INIT_PARAMS()
  84. {
  85. if ( !params[ INTERNAL_VIGNETTETEXTURE ]->IsDefined() )
  86. {
  87. params[ INTERNAL_VIGNETTETEXTURE ]->SetStringValue( "dev/vignette" );
  88. }
  89. if ( !params[ AAENABLE ]->IsDefined() )
  90. {
  91. params[ AAENABLE ]->SetIntValue( 0 );
  92. }
  93. if ( !params[ FXAAINTERNALC ]->IsDefined() )
  94. {
  95. params[ FXAAINTERNALC ]->SetVecValue( 0, 0, 0, 0 );
  96. }
  97. if ( !params[ FXAAINTERNALQ ]->IsDefined() )
  98. {
  99. params[ FXAAINTERNALQ ]->SetVecValue( 0, 0, 0, 0 );
  100. }
  101. if ( !params[ AAINTERNAL1 ]->IsDefined() )
  102. {
  103. params[ AAINTERNAL1 ]->SetVecValue( 0, 0, 0, 0 );
  104. }
  105. if ( !params[ AAINTERNAL2 ]->IsDefined() )
  106. {
  107. params[ AAINTERNAL2 ]->SetVecValue( 0, 0, 0, 0 );
  108. }
  109. if ( !params[ AAINTERNAL3 ]->IsDefined() )
  110. {
  111. params[ AAINTERNAL3 ]->SetVecValue( 0, 0, 0, 0 );
  112. }
  113. if ( !params[ BLOOMENABLE ]->IsDefined() )
  114. {
  115. params[ BLOOMENABLE ]->SetIntValue( 1 );
  116. }
  117. if ( !params[ BLOOMAMOUNT ]->IsDefined() )
  118. {
  119. params[ BLOOMAMOUNT ]->SetFloatValue( 1.0f );
  120. }
  121. if ( !params[ DEPTHBLURENABLE ]->IsDefined() )
  122. {
  123. params[ DEPTHBLURENABLE ]->SetIntValue( 0 );
  124. }
  125. if ( !params[ ALLOWNOISE ]->IsDefined() )
  126. {
  127. params[ ALLOWNOISE ]->SetIntValue( 1 );
  128. }
  129. if ( !params[ NOISESCALE ]->IsDefined() )
  130. {
  131. params[ NOISESCALE ]->SetFloatValue( 1.0f );
  132. }
  133. if ( !params[ NOISEENABLE ]->IsDefined() )
  134. {
  135. params[ NOISEENABLE ]->SetIntValue( 0 );
  136. }
  137. if ( !params[ ALLOWVIGNETTE ]->IsDefined() )
  138. {
  139. params[ ALLOWVIGNETTE ]->SetIntValue( 1 );
  140. }
  141. if ( !params[ VIGNETTEENABLE ]->IsDefined() )
  142. {
  143. params[ VIGNETTEENABLE ]->SetIntValue( 0 );
  144. }
  145. if ( !params[ ALLOWLOCALCONTRAST ]->IsDefined() )
  146. {
  147. params[ ALLOWLOCALCONTRAST ]->SetIntValue( 1 );
  148. }
  149. if ( !params[ LOCALCONTRASTSCALE ]->IsDefined() )
  150. {
  151. params[ LOCALCONTRASTSCALE ]->SetFloatValue( 1.0f );
  152. }
  153. if ( !params[ LOCALCONTRASTMIDTONEMASK ]->IsDefined() )
  154. {
  155. params[ LOCALCONTRASTMIDTONEMASK ]->SetFloatValue( 1000.0f );
  156. }
  157. if ( !params[ LOCALCONTRASTENABLE ]->IsDefined() )
  158. {
  159. params[ LOCALCONTRASTENABLE ]->SetIntValue( 0 );
  160. }
  161. if ( !params[ LOCALCONTRASTVIGNETTESTART ]->IsDefined() )
  162. {
  163. params[ LOCALCONTRASTVIGNETTESTART ]->SetFloatValue( 0.7f );
  164. }
  165. if ( !params[ LOCALCONTRASTVIGNETTEEND ]->IsDefined() )
  166. {
  167. params[ LOCALCONTRASTVIGNETTEEND ]->SetFloatValue( 1.0f );
  168. }
  169. if ( !params[ LOCALCONTRASTEDGESCALE ]->IsDefined() )
  170. {
  171. params[ LOCALCONTRASTEDGESCALE ]->SetFloatValue( 0.0f );
  172. }
  173. if ( !params[ BLURREDVIGNETTEENABLE ]->IsDefined() )
  174. {
  175. params[ BLURREDVIGNETTEENABLE ]->SetIntValue( 0 );
  176. }
  177. if ( !params[ BLURREDVIGNETTESCALE ]->IsDefined() )
  178. {
  179. params[ BLURREDVIGNETTESCALE ]->SetFloatValue( 0.0f );
  180. }
  181. if ( !params[ FADETOBLACKSCALE ]->IsDefined() )
  182. {
  183. params[ FADETOBLACKSCALE ]->SetFloatValue( 0.0f );
  184. }
  185. if ( !params[ DEPTHBLURFOCALDISTANCE ]->IsDefined() )
  186. {
  187. params[ DEPTHBLURFOCALDISTANCE ]->SetFloatValue( 0.0f );
  188. }
  189. if ( !params[ DEPTHBLURSTRENGTH ]->IsDefined() )
  190. {
  191. params[ DEPTHBLURSTRENGTH ]->SetFloatValue( 0.0f );
  192. }
  193. if ( !params[ SCREENBLURSTRENGTH ]->IsDefined() )
  194. {
  195. params[ SCREENBLURSTRENGTH ]->SetFloatValue( 0.0f );
  196. }
  197. if ( !params[ TOOLMODE ]->IsDefined() )
  198. {
  199. params[ TOOLMODE ]->SetIntValue( 0 );
  200. }
  201. if ( !params[ TOOLCOLORCORRECTION ]->IsDefined() )
  202. {
  203. params[ TOOLCOLORCORRECTION ]->SetFloatValue( 0.0f );
  204. }
  205. if ( !params[ VOMITENABLE ]->IsDefined() )
  206. {
  207. params[ VOMITENABLE ]->SetIntValue( 0 );
  208. }
  209. if ( !params[ VOMITREFRACTSCALE ]->IsDefined() )
  210. {
  211. params[ VOMITREFRACTSCALE ]->SetFloatValue( 0.15f );
  212. }
  213. if ( !params[ VOMITCOLOR1 ]->IsDefined() )
  214. {
  215. params[ VOMITCOLOR1 ]->SetVecValue( 1.0, 1.0, 0.0 );
  216. }
  217. if ( !params[ VOMITCOLOR2 ]->IsDefined() )
  218. {
  219. params[ VOMITCOLOR2 ]->SetVecValue( 0.0, 1.0, 0.0 );
  220. }
  221. if ( !params[ FADE ]->IsDefined() )
  222. {
  223. params[ FADE ]->SetIntValue( 0 );
  224. }
  225. if ( !params[ FADECOLOR ]->IsDefined() )
  226. {
  227. params[ FADECOLOR ]->SetVecValue( 0.0f, 0.0f, 0.0f, 0.0f );
  228. }
  229. if ( !params[ TV_GAMMA ]->IsDefined() )
  230. {
  231. params[ TV_GAMMA ]->SetIntValue( 0 );
  232. }
  233. if ( !params[ DESATURATEENABLE ]->IsDefined() )
  234. {
  235. params[ DESATURATEENABLE ]->SetIntValue( 0 );
  236. }
  237. if ( !params[ DESATURATION ]->IsDefined() )
  238. {
  239. params[ DESATURATION ]->SetFloatValue( 0.0f );
  240. }
  241. SET_FLAGS2( MATERIAL_VAR2_NEEDS_FULL_FRAME_BUFFER_TEXTURE );
  242. }
  243. SHADER_FALLBACK
  244. {
  245. // This shader should not be *used* unless we're >= DX9 (bloomadd.vmt/screenspace_general_dx8 should be used for DX8)
  246. return 0;
  247. }
  248. SHADER_INIT
  249. {
  250. if ( params[BASETEXTURE]->IsDefined() )
  251. {
  252. LoadTexture( BASETEXTURE );
  253. }
  254. if ( params[FBTEXTURE]->IsDefined() )
  255. {
  256. LoadTexture( FBTEXTURE );
  257. }
  258. if ( params[SCREENEFFECTTEXTURE]->IsDefined() )
  259. {
  260. LoadTexture( SCREENEFFECTTEXTURE );
  261. }
  262. if ( params[NOISETEXTURE]->IsDefined() )
  263. {
  264. LoadTexture( NOISETEXTURE );
  265. }
  266. if ( params[INTERNAL_VIGNETTETEXTURE]->IsDefined() )
  267. {
  268. LoadTexture( INTERNAL_VIGNETTETEXTURE );
  269. }
  270. }
  271. SHADER_DRAW
  272. {
  273. bool bSFM = ( ToolsEnabled() && IsPlatformWindowsPC() && g_pHardwareConfig->SupportsPixelShaders_3_0() ) ? true : false;
  274. bSFM;
  275. bool bToolMode = params[TOOLMODE]->GetIntValue() != 0;
  276. bool bDepthBlurEnable = params[ DEPTHBLURENABLE ]->GetIntValue() != 0;
  277. bool bForceSRGBReadsAndWrites = false;
  278. SHADOW_STATE
  279. {
  280. // This shader uses opaque blending, but needs to match the behaviour of bloom_add/screen_spacegeneral,
  281. // which uses additive blending (and is used when bloom is enabled but col-correction and AA are not).
  282. // BUT!
  283. // Hardware sRGB blending is incorrect (on pre-DX10 cards, sRGB values are added directly).
  284. // SO...
  285. // When doing the bloom addition in the pixel shader, we need to emulate that incorrect
  286. // behaviour - by turning sRGB read OFF for the FB texture and by turning sRGB write OFF
  287. // (which is fine, since the AA process works better on an sRGB framebuffer than a linear
  288. // one; gamma colours more closely match luminance perception. The color-correction process
  289. // has always taken gamma-space values as input anyway).
  290. // On OpenGL, we MUST do sRGB reads from the bloom and full framebuffer textures AND sRGB
  291. // writes on the way out to the framebuffer. Hence, our colors are linear in the shader.
  292. // Given this, we use the LINEAR_INPUTS combo to convert to sRGB for the purposes of color
  293. // correction, since that is how the color correction textures are authored.
  294. bool bLinearInput = false;
  295. bool bLinearOutput = false;
  296. pShaderShadow->EnableBlending( false );
  297. // The (sRGB) bloom texture is bound to sampler 0
  298. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  299. pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, bForceSRGBReadsAndWrites );
  300. pShaderShadow->EnableSRGBWrite( bForceSRGBReadsAndWrites );
  301. // The (sRGB) full framebuffer texture is bound to sampler 1:
  302. pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
  303. pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, bForceSRGBReadsAndWrites );
  304. // Up to 4 (sRGB) color-correction lookup textures are bound to samplers 2-5:
  305. int nLookupCount = MIN( (int) params[NUM_LOOKUPS]->GetFloatValue(), 3 );
  306. for( int i = 0 ; i < nLookupCount; i++ )
  307. {
  308. pShaderShadow->EnableTexture( ( Sampler_t ) ( SHADER_SAMPLER2 + i ), true );
  309. pShaderShadow->EnableSRGBRead( ( Sampler_t ) ( SHADER_SAMPLER2 + i ), false );
  310. }
  311. // Noise
  312. pShaderShadow->EnableTexture( SHADER_SAMPLER6, true );
  313. pShaderShadow->EnableSRGBRead( SHADER_SAMPLER6, false );
  314. // Vignette
  315. pShaderShadow->EnableTexture( SHADER_SAMPLER7, true );
  316. pShaderShadow->EnableSRGBRead( SHADER_SAMPLER7, false );
  317. // Screen effect texture
  318. pShaderShadow->EnableTexture( SHADER_SAMPLER8, true );
  319. pShaderShadow->EnableSRGBRead( SHADER_SAMPLER8, false );
  320. int format = VERTEX_POSITION;
  321. int numTexCoords = 1;
  322. int * pTexCoordDimensions = NULL;
  323. int userDataSize = 0;
  324. pShaderShadow->VertexShaderVertexFormat( format, numTexCoords, pTexCoordDimensions, userDataSize );
  325. #if !defined( _GAMECONSOLE )
  326. if( g_pHardwareConfig->SupportsPixelShaders_3_0() )
  327. {
  328. DECLARE_STATIC_VERTEX_SHADER( engine_post_vs30 );
  329. SET_STATIC_VERTEX_SHADER( engine_post_vs30 );
  330. }
  331. else
  332. #endif
  333. {
  334. DECLARE_STATIC_VERTEX_SHADER( engine_post_vs20 );
  335. SET_STATIC_VERTEX_SHADER( engine_post_vs20 );
  336. }
  337. #if !defined( _GAMECONSOLE )
  338. if( g_pHardwareConfig->SupportsPixelShaders_3_0() )
  339. {
  340. DECLARE_STATIC_PIXEL_SHADER( engine_post_ps30 );
  341. SET_STATIC_PIXEL_SHADER_COMBO( TOOL_MODE, bToolMode );
  342. SET_STATIC_PIXEL_SHADER_COMBO( DEPTH_BLUR_ENABLE, bDepthBlurEnable );
  343. SET_STATIC_PIXEL_SHADER_COMBO( LINEAR_INPUT, bLinearInput );
  344. SET_STATIC_PIXEL_SHADER_COMBO( LINEAR_OUTPUT, bLinearOutput );
  345. SET_STATIC_PIXEL_SHADER( engine_post_ps30 );
  346. }
  347. else
  348. #endif
  349. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  350. {
  351. DECLARE_STATIC_PIXEL_SHADER( engine_post_ps20b );
  352. SET_STATIC_PIXEL_SHADER_COMBO( TOOL_MODE, bToolMode );
  353. SET_STATIC_PIXEL_SHADER_COMBO( DEPTH_BLUR_ENABLE, bDepthBlurEnable );
  354. SET_STATIC_PIXEL_SHADER_COMBO( LINEAR_INPUT, bLinearInput );
  355. SET_STATIC_PIXEL_SHADER_COMBO( LINEAR_OUTPUT, bLinearOutput );
  356. SET_STATIC_PIXEL_SHADER( engine_post_ps20b );
  357. }
  358. else
  359. {
  360. DECLARE_STATIC_PIXEL_SHADER( engine_post_ps20 );
  361. SET_STATIC_PIXEL_SHADER_COMBO( TOOL_MODE, bToolMode );
  362. SET_STATIC_PIXEL_SHADER_COMBO( DEPTH_BLUR_ENABLE, bDepthBlurEnable );
  363. SET_STATIC_PIXEL_SHADER( engine_post_ps20 );
  364. }
  365. }
  366. DYNAMIC_STATE
  367. {
  368. BindTexture( SHADER_SAMPLER0, bForceSRGBReadsAndWrites ? TEXTURE_BINDFLAGS_SRGBREAD : TEXTURE_BINDFLAGS_NONE, BASETEXTURE, -1 );
  369. // FIXME: need to set FBTEXTURE to be point-sampled (will speed up this shader significantly on 360)
  370. // and assert that it's set to SHADER_TEXWRAPMODE_CLAMP (since the shader will sample offscreen)
  371. BindTexture( SHADER_SAMPLER1, bForceSRGBReadsAndWrites ? TEXTURE_BINDFLAGS_SRGBREAD : TEXTURE_BINDFLAGS_NONE, FBTEXTURE, -1 );
  372. ShaderColorCorrectionInfo_t ccInfo = { false, 0, 1.0f, { 1.0f, 1.0f, 1.0f, 1.0f } };
  373. float flTime;
  374. if ( bToolMode )
  375. {
  376. flTime = params[TOOLTIME]->GetFloatValue();
  377. }
  378. else
  379. {
  380. flTime = pShaderAPI->CurrentTime();
  381. }
  382. // ps20b has a desaturation control that overrides color correction, only used by the SFM (tools mode on Windows)
  383. bool bDesaturateEnable = bToolMode && ( params[DESATURATEENABLE]->GetIntValue() != 0 ) && g_pHardwareConfig->SupportsPixelShaders_2_b() && IsPlatformWindows();
  384. if ( params[FADE]->GetIntValue() == 0 )
  385. {
  386. // Not fading, so set the constant to cause nothing to change about the pixel color
  387. float vConst[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
  388. pShaderAPI->SetPixelShaderConstant( 15, vConst );
  389. }
  390. else
  391. {
  392. pShaderAPI->SetPixelShaderConstant( 15, params[ FADECOLOR ]->GetVecValue(), 1 );
  393. }
  394. if ( bDesaturateEnable )
  395. {
  396. float vPsConst[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
  397. vPsConst[0] = params[DESATURATION]->GetFloatValue();
  398. pShaderAPI->SetPixelShaderConstant( 16, vPsConst, 1 );
  399. }
  400. else // set up color correction
  401. {
  402. bool bToolColorCorrection = params[TOOLCOLORCORRECTION]->GetIntValue() != 0;
  403. if ( bToolColorCorrection )
  404. {
  405. ccInfo.m_bIsEnabled = true;
  406. ccInfo.m_nLookupCount = (int) params[NUM_LOOKUPS]->GetFloatValue();
  407. ccInfo.m_flDefaultWeight = params[WEIGHT_DEFAULT]->GetFloatValue();
  408. ccInfo.m_pLookupWeights[0] = params[WEIGHT0]->GetFloatValue();
  409. ccInfo.m_pLookupWeights[1] = params[WEIGHT1]->GetFloatValue();
  410. ccInfo.m_pLookupWeights[2] = params[WEIGHT2]->GetFloatValue();
  411. ccInfo.m_pLookupWeights[3] = params[WEIGHT3]->GetFloatValue();
  412. }
  413. else
  414. {
  415. pShaderAPI->GetCurrentColorCorrection( &ccInfo );
  416. }
  417. }
  418. int colCorrectNumLookups = MIN( ccInfo.m_nLookupCount, 3 );
  419. if ( colCorrectNumLookups )
  420. {
  421. int i;
  422. for ( i = 0; i < colCorrectNumLookups; i++ )
  423. {
  424. StandardTextureId_t id = (StandardTextureId_t)(TEXTURE_COLOR_CORRECTION_VOLUME_0 + i);
  425. bool bIsTextureValid = pShaderAPI->IsStandardTextureHandleValid( id );
  426. if ( !bIsTextureValid )
  427. {
  428. // Texture isn't valid - give up now (and set the COL_CORRECT_NUM_LOOKUPS combo appropriately) otherwise GL mode will be unhappy
  429. break;
  430. }
  431. pShaderAPI->BindStandardTexture( (Sampler_t)(SHADER_SAMPLER2 + i), TEXTURE_BINDFLAGS_NONE, id );
  432. }
  433. colCorrectNumLookups = i;
  434. }
  435. // Upload 1-pixel X&Y offsets [ (+dX,0,+dY,-dX) is chosen to work with the allowed ps20 swizzles ]
  436. // The shader will sample in a cross (up/down/left/right from the current sample), for 5-tap
  437. // (quality 0) mode and add another 4 samples in a diagonal cross, for 9-tap (quality 1) mode
  438. ITexture * pTarget = params[FBTEXTURE]->GetTextureValue();
  439. int width = pTarget->GetActualWidth();
  440. int height = pTarget->GetActualHeight();
  441. float dX = 1.0f / width;
  442. float dY = 1.0f / height;
  443. float offsets[4] = { +dX, 0, +dY, -dX };
  444. pShaderAPI->SetPixelShaderConstant( 0, &offsets[0], 1 );
  445. // Upload AA tweakables:
  446. // x - strength (this can be used to toggle the AA off, or to weaken it where pathological cases are showing)
  447. // y - reduction of 1-pixel-line blurring (blurring of 1-pixel lines causes issues, so it's tunable)
  448. // z - edge threshold multiplier (default 1.0, < 1.0 => more edges softened, > 1.0 => fewer edges softened)
  449. // w - tap offset multiplier (default 1.0, < 1.0 => sharper image, > 1.0 => blurrier image)
  450. float tweakables[4] = { params[ AAINTERNAL1 ]->GetVecValue()[0],
  451. params[ AAINTERNAL1 ]->GetVecValue()[1],
  452. params[ AAINTERNAL3 ]->GetVecValue()[0],
  453. params[ AAINTERNAL3 ]->GetVecValue()[1] };
  454. pShaderAPI->SetPixelShaderConstant( 1, &tweakables[0], 1 );
  455. // Upload AA UV transform (converts bloom texture UVs to framebuffer texture UVs)
  456. float uvTrans[4] = { params[ AAINTERNAL2 ]->GetVecValue()[0],
  457. params[ AAINTERNAL2 ]->GetVecValue()[1],
  458. params[ AAINTERNAL2 ]->GetVecValue()[2],
  459. params[ AAINTERNAL2 ]->GetVecValue()[3] };
  460. pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, &uvTrans[0], 1 );
  461. // Upload FXAA constants
  462. // ensure indexes match those in engine_post_ps2x.fxc
  463. // refer to fxaa3_11_fxc.h for parameter documentation
  464. //
  465. // FXAA Console
  466. //
  467. float uvTrans_UpperLeftLowerRight[4] = { -0.5f*dX, -0.5f*dY, 0.5f*dX, 0.5f*dY };
  468. pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_1, &uvTrans_UpperLeftLowerRight[0], 1 );
  469. float N = params[ FXAAINTERNALC ]->GetVecValue()[0];
  470. float fxaaConsoleRcpFrameOpt[4] = { -N*dX, -N*dY, N*dX, N*dY };
  471. pShaderAPI->SetPixelShaderConstant( 17, &fxaaConsoleRcpFrameOpt[0], 1 );
  472. float fxaaConsoleRcpFrameOpt2[4] = { -2.0f*dX, -2.0f*dY, 2.0f*dX, 2.0f*dY };
  473. pShaderAPI->SetPixelShaderConstant( 18, &fxaaConsoleRcpFrameOpt2[0], 1 );
  474. float fxaaConsole360RcpFrameOpt2[4] = { 8.0f*dX, 8.0f*dY, -4.0f*dX, -4.0f*dY };
  475. pShaderAPI->SetPixelShaderConstant( 19, &fxaaConsole360RcpFrameOpt2[0], 1 );
  476. float fxaaConsoleEdge[4] = { 0.0f,
  477. params[ FXAAINTERNALC ]->GetVecValue()[1],
  478. params[ FXAAINTERNALC ]->GetVecValue()[2],
  479. params[ FXAAINTERNALC ]->GetVecValue()[3] };
  480. pShaderAPI->SetPixelShaderConstant( 20, &fxaaConsoleEdge[0], 1 );
  481. float fxaaConsole360ConstDir[4] = { 1.0f, -1.0f, 0.25f, -0.25f };
  482. pShaderAPI->SetPixelShaderConstant( 21, &fxaaConsole360ConstDir[0], 1 );
  483. //
  484. // FXAA Quality
  485. //
  486. float fxaaQualityRcpFrame[4] = { dX, dY, 0.5f*dX, 0.5f*dY };
  487. pShaderAPI->SetPixelShaderConstant( 22, &fxaaQualityRcpFrame[0], 1 );
  488. float fxaaQualitySubpixEdge[4] = { params[ FXAAINTERNALQ ]->GetVecValue()[0],
  489. params[ FXAAINTERNALQ ]->GetVecValue()[1],
  490. params[ FXAAINTERNALQ ]->GetVecValue()[2],
  491. params[ FXAAINTERNALQ ]->GetVecValue()[3] };
  492. pShaderAPI->SetPixelShaderConstant( 23, &fxaaQualitySubpixEdge[0], 1 );
  493. // Upload color-correction weights:
  494. pShaderAPI->SetPixelShaderConstant( 3, &ccInfo.m_flDefaultWeight );
  495. pShaderAPI->SetPixelShaderConstant( 4, ccInfo.m_pLookupWeights );
  496. int aaEnabled = false;
  497. if ( IsGameConsole() || ( g_pHardwareConfig->SupportsPixelShaders_3_0() && !bSFM ) )
  498. {
  499. aaEnabled = ( params[ AAINTERNAL1 ]->GetVecValue()[0] != 0.0f ) ? 1 : 0;
  500. }
  501. int bloomEnabled = ( params[ BLOOMENABLE ]->GetIntValue() == 0 ) ? 0 : 1;
  502. int colCorrectEnabled = ccInfo.m_bIsEnabled;
  503. float flBloomFactor = bloomEnabled ? 1.0f : 0.0f;
  504. flBloomFactor *= params[BLOOMAMOUNT]->GetFloatValue();
  505. float bloomConstant[4] =
  506. {
  507. flBloomFactor,
  508. params[ SCREENBLURSTRENGTH ]->GetFloatValue(),
  509. params[ DEPTHBLURFOCALDISTANCE ]->GetFloatValue(),
  510. params[ DEPTHBLURSTRENGTH ]->GetFloatValue()
  511. };
  512. if ( mat_screen_blur_override.GetFloat() >= 0.0f )
  513. {
  514. bloomConstant[1] = mat_screen_blur_override.GetFloat();
  515. }
  516. if ( mat_depth_blur_focal_distance_override.GetFloat() >= 0.0f )
  517. {
  518. bloomConstant[2] = mat_depth_blur_focal_distance_override.GetFloat();
  519. }
  520. #ifdef _X360
  521. bloomConstant[3] = 0.0f; // Depth blur is currently broken on X360 because we're not writing out the depth scale properly
  522. #else // !_X360
  523. if ( mat_depth_blur_strength_override.GetFloat() >= 0.0f )
  524. {
  525. bloomConstant[3] = mat_depth_blur_strength_override.GetFloat();
  526. }
  527. #endif // _X360
  528. pShaderAPI->SetPixelShaderConstant( 5, bloomConstant );
  529. // Vignette
  530. bool bVignetteEnable = false;
  531. if ( mat_vignette_enable.GetInt() )
  532. {
  533. bVignetteEnable = ( params[ VIGNETTEENABLE ]->GetIntValue() != 0 ) && ( params[ ALLOWVIGNETTE ]->GetIntValue() != 0 );
  534. }
  535. if ( bVignetteEnable )
  536. {
  537. BindTexture( SHADER_SAMPLER7, TEXTURE_BINDFLAGS_NONE, INTERNAL_VIGNETTETEXTURE );
  538. }
  539. // Noise
  540. bool bNoiseEnable = false;
  541. if ( mat_noise_enable.GetInt() )
  542. {
  543. bNoiseEnable = false; //( params[ NOISEENABLE ]->GetIntValue() != 0 ) && ( params[ ALLOWNOISE ]->GetIntValue() != 0 );
  544. }
  545. int nFbTextureHeight = params[FBTEXTURE]->GetTextureValue()->GetActualHeight();
  546. if ( nFbTextureHeight < 720 )
  547. {
  548. // Disable noise at low resolutions
  549. bNoiseEnable = false;
  550. }
  551. // Be even more draconian about disabling noise at low resolutions on Mac
  552. if ( ( nFbTextureHeight < 1024 ) )
  553. {
  554. bNoiseEnable = false;
  555. }
  556. if ( bNoiseEnable )
  557. {
  558. BindTexture( SHADER_SAMPLER6, TEXTURE_BINDFLAGS_NONE, NOISETEXTURE );
  559. // Noise scale
  560. float vPsConst6[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
  561. vPsConst6[0] = params[ NOISESCALE ]->GetFloatValue();
  562. if ( mat_grain_scale_override.GetFloat() != -1.0f )
  563. {
  564. vPsConst6[0] = mat_grain_scale_override.GetFloat();
  565. }
  566. if ( IsX360() )
  567. {
  568. vPsConst6[0] *= 0.15f;
  569. }
  570. if ( vPsConst6[0] <= 0.0f )
  571. {
  572. bNoiseEnable = false;
  573. }
  574. pShaderAPI->SetPixelShaderConstant( 6, vPsConst6 );
  575. // Time % 1000 for scrolling
  576. float vPsConst[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
  577. vPsConst[0] = flTime;
  578. vPsConst[0] -= (float)( (int)( vPsConst[0] / 1000.0f ) ) * 1000.0f;
  579. pShaderAPI->SetPixelShaderConstant( 7, vPsConst, 1 );
  580. }
  581. // Local Contrast
  582. bool bLocalContrastEnable = ( params[ LOCALCONTRASTENABLE ]->GetIntValue() != 0 ) && ( params[ ALLOWLOCALCONTRAST ]->GetIntValue() != 0 );
  583. bool bBlurredVignetteEnable = ( bLocalContrastEnable ) && ( params[ BLURREDVIGNETTEENABLE ]->GetIntValue() != 0 );
  584. if ( bLocalContrastEnable )
  585. {
  586. // Contrast scale
  587. float vPsConst[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
  588. vPsConst[0] = params[ LOCALCONTRASTSCALE ]->GetFloatValue();
  589. if ( mat_local_contrast_scale_override.GetFloat() != 0.0f )
  590. {
  591. vPsConst[0] = mat_local_contrast_scale_override.GetFloat();
  592. }
  593. vPsConst[1] = params[ LOCALCONTRASTMIDTONEMASK ]->GetFloatValue();
  594. if ( mat_local_contrast_midtone_mask_override.GetFloat() >= 0.0f )
  595. {
  596. vPsConst[1] = mat_local_contrast_midtone_mask_override.GetFloat();
  597. }
  598. vPsConst[2] = params[ BLURREDVIGNETTESCALE ]->GetFloatValue();
  599. pShaderAPI->SetPixelShaderConstant( 8, vPsConst, 1 );
  600. vPsConst[0] = params[ LOCALCONTRASTVIGNETTESTART ]->GetFloatValue();
  601. if ( mat_local_contrast_vignette_start_override.GetFloat() >= 0.0f )
  602. {
  603. vPsConst[0] = mat_local_contrast_vignette_start_override.GetFloat();
  604. }
  605. vPsConst[1] = params[ LOCALCONTRASTVIGNETTEEND ]->GetFloatValue();
  606. if ( mat_local_contrast_vignette_end_override.GetFloat() >= 0.0f )
  607. {
  608. vPsConst[1] = mat_local_contrast_vignette_end_override.GetFloat();
  609. }
  610. vPsConst[2] = params[ LOCALCONTRASTEDGESCALE ]->GetFloatValue();
  611. if ( mat_local_contrast_edge_scale_override.GetFloat() >= -1.0f )
  612. {
  613. vPsConst[2] = mat_local_contrast_edge_scale_override.GetFloat();
  614. }
  615. pShaderAPI->SetPixelShaderConstant( 9, vPsConst, 1 );
  616. }
  617. // fade to black
  618. float vPsConst[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
  619. vPsConst[0] = params[ FADETOBLACKSCALE ]->GetFloatValue();
  620. pShaderAPI->SetPixelShaderConstant( 10, vPsConst, 1 );
  621. bool bFadeToBlackEnable = vPsConst[0] > 0.0f;
  622. bool bVomitEnable = false; //( params[ VOMITENABLE ]->GetIntValue() != 0 );
  623. if ( bVomitEnable )
  624. {
  625. BindTexture( SHADER_SAMPLER8, TEXTURE_BINDFLAGS_NONE, SCREENEFFECTTEXTURE );
  626. params[ VOMITCOLOR1 ]->GetVecValue( vPsConst, 3 );
  627. vPsConst[3] = params[ VOMITREFRACTSCALE ]->GetFloatValue();
  628. pShaderAPI->SetPixelShaderConstant( 11, vPsConst, 1 );
  629. params[ VOMITCOLOR2 ]->GetVecValue( vPsConst, 3 );
  630. vPsConst[3] = 0.0f;
  631. pShaderAPI->SetPixelShaderConstant( 12, vPsConst, 1 );
  632. // Get viewport and render target dimensions and set shader constant to do a 2D mad
  633. int nViewportX, nViewportY, nViewportWidth, nViewportHeight;
  634. pShaderAPI->GetCurrentViewport( nViewportX, nViewportY, nViewportWidth, nViewportHeight );
  635. int nRtWidth, nRtHeight;
  636. pShaderAPI->GetCurrentRenderTargetDimensions( nRtWidth, nRtHeight );
  637. float vViewportMad[4];
  638. // screen->viewport transform
  639. vViewportMad[0] = ( float )nRtWidth / ( float )nViewportWidth;
  640. vViewportMad[1] = ( float )nRtHeight / ( float )nViewportHeight;
  641. vViewportMad[2] = -( float )nViewportX / ( float )nViewportWidth;
  642. vViewportMad[3] = -( float )nViewportY / ( float )nViewportHeight;
  643. pShaderAPI->SetPixelShaderConstant( 13, vViewportMad, 1 );
  644. // viewport->screen transform
  645. vViewportMad[0] = ( float )nViewportWidth / ( float )nRtWidth;
  646. vViewportMad[1] = ( float )nViewportHeight / ( float )nRtHeight;
  647. vViewportMad[2] = ( float )nViewportX / ( float )nRtWidth;
  648. vViewportMad[3] = ( float )nViewportY / ( float )nRtHeight;
  649. pShaderAPI->SetPixelShaderConstant( 14, vViewportMad, 1 );
  650. }
  651. if ( !colCorrectEnabled )
  652. {
  653. colCorrectNumLookups = 0;
  654. }
  655. bool bConvertFromLinear = bToolMode && ( g_pHardwareConfig->GetHDRType() == HDR_TYPE_FLOAT );
  656. // JasonM - double check this if the SFM needs to use the engine post FX clip in main
  657. bool bConvertToLinear = bToolMode && bConvertFromLinear && ( g_pHardwareConfig->GetHDRType() == HDR_TYPE_FLOAT );
  658. int nFadeType = clamp( params[FADE]->GetIntValue(), 0, 2 );
  659. #if !defined( _GAMECONSOLE )
  660. if ( g_pHardwareConfig->SupportsPixelShaders_3_0() )
  661. {
  662. DECLARE_DYNAMIC_PIXEL_SHADER( engine_post_ps30 );
  663. SET_DYNAMIC_PIXEL_SHADER_COMBO( AA_ENABLE, aaEnabled );
  664. SET_DYNAMIC_PIXEL_SHADER_COMBO( COL_CORRECT_NUM_LOOKUPS, colCorrectNumLookups );
  665. SET_DYNAMIC_PIXEL_SHADER_COMBO( CONVERT_FROM_LINEAR, bConvertFromLinear );
  666. SET_DYNAMIC_PIXEL_SHADER_COMBO( CONVERT_TO_LINEAR, bConvertToLinear );
  667. SET_DYNAMIC_PIXEL_SHADER_COMBO( NOISE_ENABLE, bNoiseEnable ); // Always zero in Portal 2
  668. SET_DYNAMIC_PIXEL_SHADER_COMBO( VIGNETTE_ENABLE, bVignetteEnable ); // Always zero in Portal 2
  669. SET_DYNAMIC_PIXEL_SHADER_COMBO( LOCAL_CONTRAST_ENABLE, bLocalContrastEnable ); // Always zero in Portal 2
  670. SET_DYNAMIC_PIXEL_SHADER_COMBO( BLURRED_VIGNETTE_ENABLE, bBlurredVignetteEnable ); // Always zero in Portal 2
  671. SET_DYNAMIC_PIXEL_SHADER_COMBO( VOMIT_ENABLE, bVomitEnable );
  672. SET_DYNAMIC_PIXEL_SHADER_COMBO( FADE_TO_BLACK, bFadeToBlackEnable );
  673. SET_DYNAMIC_PIXEL_SHADER_COMBO( FADE_TYPE, nFadeType );
  674. SET_DYNAMIC_PIXEL_SHADER_COMBO( TV_GAMMA, params[TV_GAMMA]->GetIntValue() && bToolMode ? 1 : 0 );
  675. SET_DYNAMIC_PIXEL_SHADER_COMBO( DESATURATEENABLE, bDesaturateEnable );
  676. SET_DYNAMIC_PIXEL_SHADER( engine_post_ps30 );
  677. }
  678. else
  679. #endif
  680. if ( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  681. {
  682. DECLARE_DYNAMIC_PIXEL_SHADER( engine_post_ps20b );
  683. SET_DYNAMIC_PIXEL_SHADER_COMBO( AA_ENABLE, aaEnabled );
  684. SET_DYNAMIC_PIXEL_SHADER_COMBO( COL_CORRECT_NUM_LOOKUPS, colCorrectNumLookups );
  685. SET_DYNAMIC_PIXEL_SHADER_COMBO( CONVERT_FROM_LINEAR, bConvertFromLinear );
  686. SET_DYNAMIC_PIXEL_SHADER_COMBO( CONVERT_TO_LINEAR, bConvertToLinear );
  687. SET_DYNAMIC_PIXEL_SHADER_COMBO( NOISE_ENABLE, bNoiseEnable ); // Always zero in Portal 2
  688. SET_DYNAMIC_PIXEL_SHADER_COMBO( VIGNETTE_ENABLE, bVignetteEnable ); // Always zero in Portal 2
  689. SET_DYNAMIC_PIXEL_SHADER_COMBO( LOCAL_CONTRAST_ENABLE, bLocalContrastEnable ); // Always zero in Portal 2
  690. SET_DYNAMIC_PIXEL_SHADER_COMBO( BLURRED_VIGNETTE_ENABLE, bBlurredVignetteEnable ); // Always zero in Portal 2
  691. SET_DYNAMIC_PIXEL_SHADER_COMBO( VOMIT_ENABLE, bVomitEnable );
  692. SET_DYNAMIC_PIXEL_SHADER_COMBO( FADE_TO_BLACK, bFadeToBlackEnable );
  693. SET_DYNAMIC_PIXEL_SHADER_COMBO( FADE_TYPE, nFadeType );
  694. #if !defined( _X360 ) && !defined( _PS3 )
  695. SET_DYNAMIC_PIXEL_SHADER_COMBO( TV_GAMMA, params[TV_GAMMA]->GetIntValue() && bToolMode ? 1 : 0 );
  696. SET_DYNAMIC_PIXEL_SHADER_COMBO( DESATURATEENABLE, bDesaturateEnable );
  697. #endif
  698. SET_DYNAMIC_PIXEL_SHADER( engine_post_ps20b );
  699. }
  700. else
  701. {
  702. DECLARE_DYNAMIC_PIXEL_SHADER( engine_post_ps20 );
  703. SET_DYNAMIC_PIXEL_SHADER_COMBO( AA_ENABLE, aaEnabled );
  704. SET_DYNAMIC_PIXEL_SHADER_COMBO( COL_CORRECT_NUM_LOOKUPS, colCorrectNumLookups );
  705. SET_DYNAMIC_PIXEL_SHADER_COMBO( VOMIT_ENABLE, bVomitEnable );
  706. SET_DYNAMIC_PIXEL_SHADER_COMBO( FADE_TO_BLACK, bFadeToBlackEnable );
  707. SET_DYNAMIC_PIXEL_SHADER_COMBO( FADE_TYPE, nFadeType );
  708. SET_DYNAMIC_PIXEL_SHADER( engine_post_ps20 );
  709. }
  710. #if !defined( _GAMECONSOLE )
  711. if ( g_pHardwareConfig->SupportsPixelShaders_3_0() )
  712. {
  713. DECLARE_DYNAMIC_VERTEX_SHADER( engine_post_vs30 );
  714. SET_DYNAMIC_VERTEX_SHADER( engine_post_vs30 );
  715. }
  716. else
  717. #endif
  718. {
  719. DECLARE_DYNAMIC_VERTEX_SHADER( engine_post_vs20 );
  720. SET_DYNAMIC_VERTEX_SHADER( engine_post_vs20 );
  721. }
  722. }
  723. Draw();
  724. }
  725. END_SHADER