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.

62 lines
1.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Header: $
  6. // $NoKeywords: $
  7. //=============================================================================//
  8. #include "shaderlib/cshader.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. DEFINE_FALLBACK_SHADER( FilmGrain, FilmGrain_DX7 )
  12. BEGIN_SHADER( FilmGrain_DX7, "Help for FilmGrain_DX7" )
  13. BEGIN_SHADER_PARAMS
  14. SHADER_PARAM( GRAIN_TEXTURE, SHADER_PARAM_TYPE_TEXTURE, "0", "Film grain texture" )
  15. SHADER_PARAM( NOISESCALE, SHADER_PARAM_TYPE_VEC4, "", "Strength of film grain" )
  16. END_SHADER_PARAMS
  17. SHADER_INIT_PARAMS()
  18. {
  19. }
  20. SHADER_FALLBACK
  21. {
  22. // Requires DX9 + above
  23. if ( g_pHardwareConfig->GetDXSupportLevel() < 70 )
  24. {
  25. Assert( 0 );
  26. return "Wireframe";
  27. }
  28. return 0;
  29. }
  30. SHADER_INIT
  31. {
  32. LoadTexture( GRAIN_TEXTURE );
  33. }
  34. SHADER_DRAW
  35. {
  36. SHADOW_STATE
  37. {
  38. pShaderShadow->EnableConstantColor( true );
  39. pShaderShadow->EnableBlending( true );
  40. pShaderShadow->BlendFunc( SHADER_BLEND_ONE_MINUS_DST_COLOR, SHADER_BLEND_ONE_MINUS_SRC_COLOR );
  41. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  42. pShaderShadow->DrawFlags( SHADER_DRAW_POSITION | SHADER_DRAW_TEXCOORD0 );
  43. }
  44. DYNAMIC_STATE
  45. {
  46. float color[4];
  47. params[NOISESCALE]->GetVecValue( color, 4 );
  48. s_pShaderAPI->Color4fv( color );
  49. BindTexture( SHADER_SAMPLER0, GRAIN_TEXTURE, -1 );
  50. }
  51. Draw();
  52. }
  53. END_SHADER