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.

101 lines
2.8 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_pass1_ps20.inc"
  11. #include "hsl_filmgrain_pass1_ps20b.inc"
  12. // NOTE: This has to be the last file included!
  13. #include "tier0/memdbgon.h"
  14. //
  15. // First pass converts from RGB to HSL and tweaks with noise similar to After Effects
  16. //
  17. BEGIN_VS_SHADER( hsl_filmgrain_pass1, "Help for Film Grain" )
  18. BEGIN_SHADER_PARAMS
  19. // Input textures
  20. SHADER_PARAM( INPUT, SHADER_PARAM_TYPE_TEXTURE, "", "" )
  21. SHADER_PARAM( GRAIN, SHADER_PARAM_TYPE_TEXTURE, "", "" )
  22. // Grain parameters to control positioning and noise params
  23. SHADER_PARAM( SCALEBIAS, SHADER_PARAM_TYPE_VEC4, "", "Scale and bias for grain placement" )
  24. SHADER_PARAM( HSLNOISESCALE, SHADER_PARAM_TYPE_VEC4, "", "Strength of film grain" )
  25. END_SHADER_PARAMS
  26. SHADER_INIT
  27. {
  28. LoadTexture( INPUT );
  29. LoadTexture( GRAIN );
  30. }
  31. SHADER_FALLBACK
  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->PolyMode( SHADER_POLYMODEFACE_FRONT_AND_BACK, SHADER_POLYMODE_LINE );
  45. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  46. pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
  47. int fmt = VERTEX_POSITION;
  48. pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
  49. DECLARE_STATIC_VERTEX_SHADER( filmgrain_vs20 );
  50. SET_STATIC_VERTEX_SHADER( filmgrain_vs20 );
  51. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  52. {
  53. DECLARE_STATIC_PIXEL_SHADER( hsl_filmgrain_pass1_ps20b );
  54. SET_STATIC_PIXEL_SHADER( hsl_filmgrain_pass1_ps20b );
  55. }
  56. else
  57. {
  58. DECLARE_STATIC_PIXEL_SHADER( hsl_filmgrain_pass1_ps20 );
  59. SET_STATIC_PIXEL_SHADER( hsl_filmgrain_pass1_ps20 );
  60. }
  61. }
  62. DYNAMIC_STATE
  63. {
  64. BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, INPUT, -1 );
  65. BindTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_NONE, GRAIN, -1 );
  66. SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, SCALEBIAS );
  67. SetPixelShaderConstant( 0, HSLNOISESCALE );
  68. DECLARE_DYNAMIC_VERTEX_SHADER( filmgrain_vs20 );
  69. SET_DYNAMIC_VERTEX_SHADER( filmgrain_vs20 );
  70. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  71. {
  72. DECLARE_DYNAMIC_PIXEL_SHADER( hsl_filmgrain_pass1_ps20b );
  73. SET_DYNAMIC_PIXEL_SHADER( hsl_filmgrain_pass1_ps20b );
  74. }
  75. else
  76. {
  77. DECLARE_DYNAMIC_PIXEL_SHADER( hsl_filmgrain_pass1_ps20 );
  78. SET_DYNAMIC_PIXEL_SHADER( hsl_filmgrain_pass1_ps20 );
  79. }
  80. }
  81. Draw();
  82. }
  83. END_SHADER