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.

67 lines
1.6 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( FilmDust, FilmDust_DX7 )
  12. BEGIN_SHADER( FilmDust_DX7, "Help for FilmDust_DX7" )
  13. BEGIN_SHADER_PARAMS
  14. SHADER_PARAM( DUST_TEXTURE, SHADER_PARAM_TYPE_TEXTURE, "0", "Film grain texture" )
  15. SHADER_PARAM( CHANNEL_SELECT, SHADER_PARAM_TYPE_VEC4, "", "Select which color channel to use" )
  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( DUST_TEXTURE );
  33. }
  34. SHADER_DRAW
  35. {
  36. SHADOW_STATE
  37. {
  38. pShaderShadow->EnableConstantColor( true );
  39. pShaderShadow->EnableBlending( true );
  40. pShaderShadow->BlendFunc( SHADER_BLEND_ZERO, SHADER_BLEND_ONE_MINUS_SRC_COLOR );
  41. pShaderShadow->EnableCustomPixelPipe( true );
  42. pShaderShadow->CustomTextureStages( 1 );
  43. pShaderShadow->CustomTextureOperation( SHADER_TEXTURE_STAGE0, SHADER_TEXCHANNEL_COLOR, SHADER_TEXOP_DOTPRODUCT3, SHADER_TEXARG_CONSTANTCOLOR, SHADER_TEXARG_TEXTURE );
  44. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  45. }
  46. DYNAMIC_STATE
  47. {
  48. float color[4];
  49. params[CHANNEL_SELECT]->GetVecValue( color, 4 );
  50. s_pShaderAPI->Color4fv( color );
  51. BindTexture( SHADER_SAMPLER0, DUST_TEXTURE, -1 );
  52. }
  53. Draw();
  54. }
  55. END_SHADER