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.

111 lines
2.9 KiB

  1. //========= Copyright � 1996-2002, Valve LLC, All rights reserved. ============
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #include "basevsshader.h"
  8. #ifdef STDSHADER_DX9_DLL_EXPORT
  9. #include "screenspaceeffect_vs20.inc"
  10. #include "filmdust_ps20.inc"
  11. #else
  12. #include "screenspaceeffect_vs11.inc"
  13. #include "filmdust_ps11.inc"
  14. #endif
  15. #include "../materialsystem_global.h"
  16. // memdbgon must be the last include file in a .cpp file!!!
  17. #include "tier0/memdbgon.h"
  18. #ifdef STDSHADER_DX9_DLL_EXPORT
  19. DEFINE_FALLBACK_SHADER( FilmDust, FilmDust_dx9 )
  20. BEGIN_VS_SHADER_FLAGS( FilmDust_dx9, "Help for FilmDust", SHADER_NOT_EDITABLE )
  21. #else
  22. DEFINE_FALLBACK_SHADER( FilmDust, FilmDust_dx8 )
  23. BEGIN_VS_SHADER_FLAGS( FilmDust_dx8, "Help for FilmDust", SHADER_NOT_EDITABLE )
  24. #endif
  25. BEGIN_SHADER_PARAMS
  26. SHADER_PARAM( DUST_TEXTURE, SHADER_PARAM_TYPE_TEXTURE, "0", "Film dust texture" )
  27. SHADER_PARAM( CHANNEL_SELECT, SHADER_PARAM_TYPE_VEC4, "", "Select which color channel to use" )
  28. END_SHADER_PARAMS
  29. SHADER_INIT_PARAMS()
  30. {
  31. SET_FLAGS2( MATERIAL_VAR2_NEEDS_FULL_FRAME_BUFFER_TEXTURE );
  32. }
  33. SHADER_FALLBACK
  34. {
  35. #ifdef STDSHADER_DX9_DLL_EXPORT
  36. // Requires DX9 + above
  37. if ( g_pHardwareConfig->GetDXSupportLevel() < 90)
  38. {
  39. return "FilmDust_DX8";
  40. }
  41. #else // We're DX8
  42. // Requires DX8 + above
  43. if ( g_pHardwareConfig->GetDXSupportLevel() < 80)
  44. {
  45. return "FilmDust_DX7";
  46. }
  47. #endif
  48. return 0;
  49. }
  50. SHADER_INIT
  51. {
  52. LoadTexture( DUST_TEXTURE );
  53. }
  54. SHADER_DRAW
  55. {
  56. SHADOW_STATE
  57. {
  58. pShaderShadow->EnableCulling( false );
  59. pShaderShadow->EnableBlending( true );
  60. pShaderShadow->BlendFunc( SHADER_BLEND_ZERO, SHADER_BLEND_SRC_COLOR );
  61. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  62. int fmt = VERTEX_POSITION;
  63. pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
  64. #ifdef STDSHADER_DX9_DLL_EXPORT
  65. DECLARE_STATIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  66. SET_STATIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  67. DECLARE_STATIC_PIXEL_SHADER( filmdust_ps20 );
  68. SET_STATIC_PIXEL_SHADER( filmdust_ps20 );
  69. #else
  70. DECLARE_STATIC_VERTEX_SHADER( screenspaceeffect_vs11 );
  71. SET_STATIC_VERTEX_SHADER( screenspaceeffect_vs11 );
  72. DECLARE_STATIC_PIXEL_SHADER( filmdust_ps11 );
  73. SET_STATIC_PIXEL_SHADER( filmdust_ps11 );
  74. #endif
  75. }
  76. DYNAMIC_STATE
  77. {
  78. BindTexture( SHADER_SAMPLER0, false, DUST_TEXTURE, -1 );
  79. SetPixelShaderConstant( 0, CHANNEL_SELECT );
  80. #ifdef STDSHADER_DX9_DLL_EXPORT
  81. DECLARE_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  82. SET_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  83. DECLARE_DYNAMIC_PIXEL_SHADER( filmdust_ps20 );
  84. SET_DYNAMIC_PIXEL_SHADER( filmdust_ps20 );
  85. #else
  86. DECLARE_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs11 );
  87. SET_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs11 );
  88. DECLARE_DYNAMIC_PIXEL_SHADER( filmdust_ps11 );
  89. SET_DYNAMIC_PIXEL_SHADER( filmdust_ps11 );
  90. #endif
  91. }
  92. Draw();
  93. }
  94. END_SHADER