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.

95 lines
2.8 KiB

  1. //===== Copyright � 1996-2005, 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. // NOTE: This has to be the last file included!
  12. #include "tier0/memdbgon.h"
  13. BEGIN_VS_SHADER_FLAGS( sfm_integercombine_shader, "Help for SFM integer HDR combine pass", SHADER_NOT_EDITABLE )
  14. BEGIN_SHADER_PARAMS
  15. SHADER_PARAM( ORIGINALTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "" ) // Original full resolution texture
  16. SHADER_PARAM( BLURREDTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "" ) // Blurred quarter-resolution texture
  17. SHADER_PARAM( BLOOMAMOUNT, SHADER_PARAM_TYPE_VEC4, "", "" ) // How much bloom gets added in
  18. SHADER_PARAM( ISFLOAT, SHADER_PARAM_TYPE_INTEGER, "", "" ) // Float or integer?
  19. END_SHADER_PARAMS
  20. SHADER_INIT
  21. {
  22. LoadTexture( ORIGINALTEXTURE );
  23. LoadTexture( BLURREDTEXTURE );
  24. }
  25. SHADER_FALLBACK
  26. {
  27. return 0;
  28. }
  29. SHADER_DRAW
  30. {
  31. SHADOW_STATE
  32. {
  33. pShaderShadow->EnableDepthWrites( false );
  34. pShaderShadow->EnableDepthTest( false );
  35. pShaderShadow->EnableAlphaWrites( true );
  36. pShaderShadow->EnableBlending( false );
  37. pShaderShadow->EnableCulling( false );
  38. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  39. pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
  40. int fmt = VERTEX_POSITION;
  41. pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
  42. DECLARE_STATIC_VERTEX_SHADER( sfm_combine_vs20 );
  43. SET_STATIC_VERTEX_SHADER( sfm_combine_vs20 );
  44. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  45. {
  46. DECLARE_STATIC_PIXEL_SHADER( sfm_integercombine_ps20b );
  47. SET_STATIC_PIXEL_SHADER( sfm_integercombine_ps20b );
  48. }
  49. else
  50. {
  51. DECLARE_STATIC_PIXEL_SHADER( sfm_integercombine_ps20 );
  52. SET_STATIC_PIXEL_SHADER( sfm_integercombine_ps20 );
  53. }
  54. }
  55. DYNAMIC_STATE
  56. {
  57. BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, ORIGINALTEXTURE, -1 );
  58. BindTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_NONE, BLURREDTEXTURE, -1 );
  59. SetPixelShaderConstant( 0, BLOOMAMOUNT );
  60. bool bIsFloat = params[ISFLOAT]->GetIntValue() != 0;
  61. DECLARE_DYNAMIC_VERTEX_SHADER( sfm_combine_vs20 );
  62. SET_DYNAMIC_VERTEX_SHADER( sfm_combine_vs20 );
  63. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  64. {
  65. DECLARE_DYNAMIC_PIXEL_SHADER( sfm_integercombine_ps20b );
  66. SET_DYNAMIC_PIXEL_SHADER_COMBO( ISFLOAT, bIsFloat );
  67. SET_DYNAMIC_PIXEL_SHADER( sfm_integercombine_ps20b );
  68. }
  69. else
  70. {
  71. DECLARE_DYNAMIC_PIXEL_SHADER( sfm_integercombine_ps20 );
  72. SET_DYNAMIC_PIXEL_SHADER_COMBO( ISFLOAT, bIsFloat );
  73. SET_DYNAMIC_PIXEL_SHADER( sfm_integercombine_ps20 );
  74. }
  75. }
  76. Draw();
  77. }
  78. END_SHADER