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.

110 lines
3.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #include "BaseVSShader.h"
  8. #include "common_hlsl_cpp_consts.h"
  9. #include "screenspaceeffect_vs20.inc"
  10. #include "accumbuff5sample_ps20.inc"
  11. #include "accumbuff5sample_ps20b.inc"
  12. #include "convar.h"
  13. BEGIN_VS_SHADER_FLAGS( accumbuff5sample, "Help for AccumBuff5Sample", SHADER_NOT_EDITABLE )
  14. BEGIN_SHADER_PARAMS
  15. // Four textures to sample
  16. SHADER_PARAM( TEXTURE0, SHADER_PARAM_TYPE_TEXTURE, "", "" )
  17. SHADER_PARAM( TEXTURE1, SHADER_PARAM_TYPE_TEXTURE, "", "" )
  18. SHADER_PARAM( TEXTURE2, SHADER_PARAM_TYPE_TEXTURE, "", "" )
  19. SHADER_PARAM( TEXTURE3, SHADER_PARAM_TYPE_TEXTURE, "", "" )
  20. SHADER_PARAM( TEXTURE4, SHADER_PARAM_TYPE_TEXTURE, "", "" )
  21. // Corresponding weights for the four input textures
  22. SHADER_PARAM( WEIGHTS, SHADER_PARAM_TYPE_VEC4, "", "Weight for Samples" )
  23. END_SHADER_PARAMS
  24. SHADER_INIT
  25. {
  26. LoadTexture( TEXTURE0 );
  27. LoadTexture( TEXTURE1 );
  28. LoadTexture( TEXTURE2 );
  29. LoadTexture( TEXTURE3 );
  30. LoadTexture( TEXTURE4 );
  31. }
  32. SHADER_FALLBACK
  33. {
  34. // Requires DX9 + above
  35. if (!g_pHardwareConfig->SupportsVertexAndPixelShaders())
  36. {
  37. Assert( 0 );
  38. return "Wireframe";
  39. }
  40. return 0;
  41. }
  42. SHADER_DRAW
  43. {
  44. SHADOW_STATE
  45. {
  46. pShaderShadow->EnableDepthWrites( false );
  47. pShaderShadow->EnableDepthTest( false );
  48. pShaderShadow->EnableAlphaWrites( false );
  49. pShaderShadow->EnableBlending( false );
  50. pShaderShadow->EnableCulling( false );
  51. // pShaderShadow->PolyMode( SHADER_POLYMODEFACE_FRONT_AND_BACK, SHADER_POLYMODE_LINE );
  52. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  53. pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
  54. pShaderShadow->EnableTexture( SHADER_SAMPLER2, true );
  55. pShaderShadow->EnableTexture( SHADER_SAMPLER3, true );
  56. pShaderShadow->EnableTexture( SHADER_SAMPLER4, true );
  57. int fmt = VERTEX_POSITION;
  58. pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
  59. DECLARE_STATIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  60. SET_STATIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  61. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  62. {
  63. DECLARE_STATIC_PIXEL_SHADER( accumbuff5sample_ps20b );
  64. SET_STATIC_PIXEL_SHADER( accumbuff5sample_ps20b );
  65. }
  66. else
  67. {
  68. DECLARE_STATIC_PIXEL_SHADER( accumbuff5sample_ps20 );
  69. SET_STATIC_PIXEL_SHADER( accumbuff5sample_ps20 );
  70. }
  71. }
  72. DYNAMIC_STATE
  73. {
  74. BindTexture( SHADER_SAMPLER0, TEXTURE0, -1 );
  75. BindTexture( SHADER_SAMPLER1, TEXTURE1, -1 );
  76. BindTexture( SHADER_SAMPLER2, TEXTURE2, -1 );
  77. BindTexture( SHADER_SAMPLER3, TEXTURE3, -1 );
  78. BindTexture( SHADER_SAMPLER4, TEXTURE4, -1 );
  79. SetPixelShaderConstant( 0, WEIGHTS );
  80. DECLARE_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  81. SET_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  82. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  83. {
  84. DECLARE_DYNAMIC_PIXEL_SHADER( accumbuff5sample_ps20b );
  85. SET_DYNAMIC_PIXEL_SHADER( accumbuff5sample_ps20b );
  86. }
  87. else
  88. {
  89. DECLARE_DYNAMIC_PIXEL_SHADER( accumbuff5sample_ps20 );
  90. SET_DYNAMIC_PIXEL_SHADER( accumbuff5sample_ps20 );
  91. }
  92. }
  93. Draw();
  94. }
  95. END_SHADER