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.

67 lines
1.7 KiB

  1. //========= Copyright � 1996-2002, Valve LLC, All rights reserved. ============
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #include "BaseVSShader.h"
  8. #include "screenspaceeffect_vs20.inc"
  9. #include "filmgrain_ps20.inc"
  10. #include "../materialsystem_global.h"
  11. // memdbgon must be the last include file in a .cpp file!!!
  12. #include "tier0/memdbgon.h"
  13. BEGIN_VS_SHADER_FLAGS( FilmGrain, "Help for FilmGrain", SHADER_NOT_EDITABLE )
  14. BEGIN_SHADER_PARAMS
  15. SHADER_PARAM( GRAIN_TEXTURE, SHADER_PARAM_TYPE_TEXTURE, "0", "Film grain texture" )
  16. SHADER_PARAM( NOISESCALE, SHADER_PARAM_TYPE_VEC4, "", "Strength of film grain" )
  17. END_SHADER_PARAMS
  18. SHADER_INIT_PARAMS()
  19. {
  20. SET_FLAGS2( MATERIAL_VAR2_NEEDS_FULL_FRAME_BUFFER_TEXTURE );
  21. }
  22. SHADER_FALLBACK
  23. {
  24. return 0;
  25. }
  26. SHADER_INIT
  27. {
  28. LoadTexture( GRAIN_TEXTURE );
  29. }
  30. SHADER_DRAW
  31. {
  32. SHADOW_STATE
  33. {
  34. pShaderShadow->EnableBlending( true );
  35. pShaderShadow->BlendFunc( SHADER_BLEND_ONE, SHADER_BLEND_SRC_ALPHA );
  36. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  37. int fmt = VERTEX_POSITION;
  38. pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
  39. DECLARE_STATIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  40. SET_STATIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  41. DECLARE_STATIC_PIXEL_SHADER( filmgrain_ps20 );
  42. SET_STATIC_PIXEL_SHADER( filmgrain_ps20 );
  43. }
  44. DYNAMIC_STATE
  45. {
  46. BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, GRAIN_TEXTURE, -1 );
  47. SetPixelShaderConstant( 0, NOISESCALE );
  48. DECLARE_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  49. SET_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  50. }
  51. Draw();
  52. }
  53. END_SHADER