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.

90 lines
2.2 KiB

  1. //========= Copyright � 1996-2005, Valve LLC, All rights reserved. ============
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #include "BaseVSShader.h"
  8. #include "convar.h"
  9. #include "filmgrain_vs20.inc"
  10. #include "hsl_filmgrain_pass2_ps20.inc"
  11. #include "hsl_filmgrain_pass2_ps20b.inc"
  12. // NOTE: This has to be the last file included!
  13. #include "tier0/memdbgon.h"
  14. //
  15. // Second pass merely converts from HSL back to RGB space, noise was already applied in first pass
  16. //
  17. BEGIN_VS_SHADER( hsl_filmgrain_pass2, "Help for Film Grain" )
  18. BEGIN_SHADER_PARAMS
  19. SHADER_PARAM( INPUT, SHADER_PARAM_TYPE_TEXTURE, "", "" )
  20. END_SHADER_PARAMS
  21. SHADER_INIT
  22. {
  23. LoadTexture( INPUT );
  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( false );
  36. pShaderShadow->EnableBlending( false );
  37. pShaderShadow->EnableCulling( false );
  38. // pShaderShadow->PolyMode( SHADER_POLYMODEFACE_FRONT_AND_BACK, SHADER_POLYMODE_LINE );
  39. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  40. int fmt = VERTEX_POSITION;
  41. pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
  42. DECLARE_STATIC_VERTEX_SHADER( filmgrain_vs20 );
  43. SET_STATIC_VERTEX_SHADER( filmgrain_vs20 );
  44. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  45. {
  46. DECLARE_STATIC_PIXEL_SHADER( hsl_filmgrain_pass2_ps20b );
  47. SET_STATIC_PIXEL_SHADER( hsl_filmgrain_pass2_ps20b );
  48. }
  49. else
  50. {
  51. DECLARE_STATIC_PIXEL_SHADER( hsl_filmgrain_pass2_ps20 );
  52. SET_STATIC_PIXEL_SHADER( hsl_filmgrain_pass2_ps20 );
  53. }
  54. }
  55. DYNAMIC_STATE
  56. {
  57. BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, INPUT, -1 );
  58. DECLARE_DYNAMIC_VERTEX_SHADER( filmgrain_vs20 );
  59. SET_DYNAMIC_VERTEX_SHADER( filmgrain_vs20 );
  60. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  61. {
  62. DECLARE_DYNAMIC_PIXEL_SHADER( hsl_filmgrain_pass2_ps20b );
  63. SET_DYNAMIC_PIXEL_SHADER( hsl_filmgrain_pass2_ps20b );
  64. }
  65. else
  66. {
  67. DECLARE_DYNAMIC_PIXEL_SHADER( hsl_filmgrain_pass2_ps20 );
  68. SET_DYNAMIC_PIXEL_SHADER( hsl_filmgrain_pass2_ps20 );
  69. }
  70. }
  71. Draw();
  72. }
  73. END_SHADER