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.

93 lines
2.2 KiB

  1. //========= Copyright Valve Corporation, 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. //
  13. // Second pass merely converts from HSL back to RGB space, noise was already applied in first pass
  14. //
  15. BEGIN_VS_SHADER( hsl_filmgrain_pass2, "Help for Film Grain" )
  16. BEGIN_SHADER_PARAMS
  17. SHADER_PARAM( INPUT, SHADER_PARAM_TYPE_TEXTURE, "", "" )
  18. END_SHADER_PARAMS
  19. SHADER_INIT
  20. {
  21. LoadTexture( INPUT );
  22. }
  23. SHADER_FALLBACK
  24. {
  25. // Requires DX9 + above
  26. if (!g_pHardwareConfig->SupportsVertexAndPixelShaders())
  27. {
  28. Assert( 0 );
  29. return "Wireframe";
  30. }
  31. return 0;
  32. }
  33. SHADER_DRAW
  34. {
  35. SHADOW_STATE
  36. {
  37. pShaderShadow->EnableDepthWrites( false );
  38. pShaderShadow->EnableDepthTest( false );
  39. pShaderShadow->EnableAlphaWrites( false );
  40. pShaderShadow->EnableBlending( false );
  41. pShaderShadow->EnableCulling( false );
  42. // pShaderShadow->PolyMode( SHADER_POLYMODEFACE_FRONT_AND_BACK, SHADER_POLYMODE_LINE );
  43. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  44. int fmt = VERTEX_POSITION;
  45. pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
  46. DECLARE_STATIC_VERTEX_SHADER( filmgrain_vs20 );
  47. SET_STATIC_VERTEX_SHADER( filmgrain_vs20 );
  48. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  49. {
  50. DECLARE_STATIC_PIXEL_SHADER( hsl_filmgrain_pass2_ps20b );
  51. SET_STATIC_PIXEL_SHADER( hsl_filmgrain_pass2_ps20b );
  52. }
  53. else
  54. {
  55. DECLARE_STATIC_PIXEL_SHADER( hsl_filmgrain_pass2_ps20 );
  56. SET_STATIC_PIXEL_SHADER( hsl_filmgrain_pass2_ps20 );
  57. }
  58. }
  59. DYNAMIC_STATE
  60. {
  61. BindTexture( SHADER_SAMPLER0, INPUT, -1 );
  62. DECLARE_DYNAMIC_VERTEX_SHADER( filmgrain_vs20 );
  63. SET_DYNAMIC_VERTEX_SHADER( filmgrain_vs20 );
  64. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  65. {
  66. DECLARE_DYNAMIC_PIXEL_SHADER( hsl_filmgrain_pass2_ps20b );
  67. SET_DYNAMIC_PIXEL_SHADER( hsl_filmgrain_pass2_ps20b );
  68. }
  69. else
  70. {
  71. DECLARE_DYNAMIC_PIXEL_SHADER( hsl_filmgrain_pass2_ps20 );
  72. SET_DYNAMIC_PIXEL_SHADER( hsl_filmgrain_pass2_ps20 );
  73. }
  74. }
  75. Draw();
  76. }
  77. END_SHADER