Team Fortress 2 Source Code as on 22/4/2020
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.

90 lines
2.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #include "BaseVSShader.h"
  8. #include "screenspaceeffect_vs20.inc"
  9. #include "Bloom_ps20.inc"
  10. #include "Bloom_ps20b.inc"
  11. BEGIN_VS_SHADER_FLAGS( Bloom, "Help for Bloom", SHADER_NOT_EDITABLE )
  12. BEGIN_SHADER_PARAMS
  13. SHADER_PARAM( FBTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_FullFrameFB", "" )
  14. SHADER_PARAM( BLURTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_SmallHDR0", "" )
  15. END_SHADER_PARAMS
  16. SHADER_INIT
  17. {
  18. if( params[FBTEXTURE]->IsDefined() )
  19. {
  20. LoadTexture( FBTEXTURE );
  21. }
  22. if( params[BLURTEXTURE]->IsDefined() )
  23. {
  24. LoadTexture( BLURTEXTURE );
  25. }
  26. }
  27. SHADER_FALLBACK
  28. {
  29. // Requires DX9 + above
  30. if ( g_pHardwareConfig->GetDXSupportLevel() < 90 )
  31. {
  32. Assert( 0 );
  33. return "Wireframe";
  34. }
  35. return 0;
  36. }
  37. SHADER_DRAW
  38. {
  39. SHADOW_STATE
  40. {
  41. pShaderShadow->EnableDepthWrites( false );
  42. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  43. pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
  44. int fmt = VERTEX_POSITION;
  45. pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
  46. // Pre-cache shaders
  47. DECLARE_STATIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  48. SET_STATIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  49. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  50. {
  51. DECLARE_STATIC_PIXEL_SHADER( bloom_ps20b );
  52. SET_STATIC_PIXEL_SHADER( bloom_ps20b );
  53. }
  54. else
  55. {
  56. DECLARE_STATIC_PIXEL_SHADER( bloom_ps20 );
  57. SET_STATIC_PIXEL_SHADER( bloom_ps20 );
  58. }
  59. }
  60. DYNAMIC_STATE
  61. {
  62. BindTexture( SHADER_SAMPLER0, FBTEXTURE, -1 );
  63. BindTexture( SHADER_SAMPLER1, BLURTEXTURE, -1 );
  64. DECLARE_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  65. SET_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  66. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  67. {
  68. DECLARE_DYNAMIC_PIXEL_SHADER( bloom_ps20b );
  69. SET_DYNAMIC_PIXEL_SHADER( bloom_ps20b );
  70. }
  71. else
  72. {
  73. DECLARE_DYNAMIC_PIXEL_SHADER( bloom_ps20 );
  74. SET_DYNAMIC_PIXEL_SHADER( bloom_ps20 );
  75. }
  76. }
  77. Draw();
  78. }
  79. END_SHADER