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.

97 lines
2.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #include "BaseVSShader.h"
  8. #include "sfm_combine_vs20.inc"
  9. #include "sfm_integercombine_ps20.inc"
  10. #include "sfm_integercombine_ps20b.inc"
  11. BEGIN_VS_SHADER_FLAGS( sfm_integercombine_shader, "Help for SFM integer HDR combine pass", SHADER_NOT_EDITABLE )
  12. BEGIN_SHADER_PARAMS
  13. // Original full resolution texture
  14. SHADER_PARAM( ORIGINALTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "" )
  15. // Blurred quarter-resolution texture
  16. SHADER_PARAM( BLURREDTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "" )
  17. // How much bloom gets added in
  18. SHADER_PARAM( BLOOMAMOUNT, SHADER_PARAM_TYPE_VEC4, "", "" )
  19. END_SHADER_PARAMS
  20. SHADER_INIT
  21. {
  22. LoadTexture( ORIGINALTEXTURE );
  23. LoadTexture( BLURREDTEXTURE );
  24. }
  25. SHADER_FALLBACK
  26. {
  27. // Requires DX9 + above
  28. if ( g_pHardwareConfig->GetDXSupportLevel() < 90 )
  29. {
  30. Assert( 0 );
  31. return "Wireframe";
  32. }
  33. return 0;
  34. }
  35. SHADER_DRAW
  36. {
  37. SHADOW_STATE
  38. {
  39. pShaderShadow->EnableDepthWrites( false );
  40. pShaderShadow->EnableDepthTest( false );
  41. pShaderShadow->EnableAlphaWrites( false );
  42. pShaderShadow->EnableBlending( false );
  43. pShaderShadow->EnableCulling( false );
  44. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  45. pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
  46. int fmt = VERTEX_POSITION;
  47. pShaderShadow->VertexShaderVertexFormat( fmt, 2, 0, 0 ); // Two texture coordinates (first for high res, second for low res)
  48. DECLARE_STATIC_VERTEX_SHADER( sfm_combine_vs20 );
  49. SET_STATIC_VERTEX_SHADER( sfm_combine_vs20 );
  50. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  51. {
  52. DECLARE_STATIC_PIXEL_SHADER( sfm_integercombine_ps20b );
  53. SET_STATIC_PIXEL_SHADER( sfm_integercombine_ps20b );
  54. }
  55. else
  56. {
  57. DECLARE_STATIC_PIXEL_SHADER( sfm_integercombine_ps20 );
  58. SET_STATIC_PIXEL_SHADER( sfm_integercombine_ps20 );
  59. }
  60. }
  61. DYNAMIC_STATE
  62. {
  63. BindTexture( SHADER_SAMPLER0, ORIGINALTEXTURE, -1 );
  64. BindTexture( SHADER_SAMPLER1, BLURREDTEXTURE, -1 );
  65. SetPixelShaderConstant( 0, BLOOMAMOUNT );
  66. DECLARE_DYNAMIC_VERTEX_SHADER( sfm_combine_vs20 );
  67. SET_DYNAMIC_VERTEX_SHADER( sfm_combine_vs20 );
  68. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  69. {
  70. DECLARE_DYNAMIC_PIXEL_SHADER( sfm_integercombine_ps20b );
  71. SET_DYNAMIC_PIXEL_SHADER( sfm_integercombine_ps20b );
  72. }
  73. else
  74. {
  75. DECLARE_DYNAMIC_PIXEL_SHADER( sfm_integercombine_ps20 );
  76. SET_DYNAMIC_PIXEL_SHADER( sfm_integercombine_ps20 );
  77. }
  78. }
  79. Draw();
  80. }
  81. END_SHADER