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.

63 lines
1.7 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( DecalModulate, DecalModulate_DX6 )
  12. BEGIN_SHADER( DecalModulate_dx6,
  13. "Help for DecalModulate_dx6" )
  14. BEGIN_SHADER_PARAMS
  15. END_SHADER_PARAMS
  16. SHADER_INIT_PARAMS()
  17. {
  18. SET_FLAGS( MATERIAL_VAR_NO_DEBUG_OVERRIDE );
  19. }
  20. SHADER_INIT
  21. {
  22. LoadTexture( BASETEXTURE );
  23. }
  24. SHADER_DRAW
  25. {
  26. SHADOW_STATE
  27. {
  28. pShaderShadow->EnableAlphaTest( true );
  29. pShaderShadow->AlphaFunc( SHADER_ALPHAFUNC_GREATER, 0.0f );
  30. pShaderShadow->EnableDepthWrites( false );
  31. pShaderShadow->EnablePolyOffset( SHADER_POLYOFFSET_DECAL );
  32. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  33. pShaderShadow->EnableBlending( true );
  34. pShaderShadow->BlendFunc( SHADER_BLEND_DST_COLOR, SHADER_BLEND_SRC_COLOR );
  35. pShaderShadow->DrawFlags( SHADER_DRAW_POSITION | SHADER_DRAW_TEXCOORD0 );
  36. FogToGrey();
  37. }
  38. DYNAMIC_STATE
  39. {
  40. // This is kinda gross. We really don't want to render anything here for the flashlight
  41. // pass since we are multiplying by what is already flashlight lit in the framebuffer.
  42. // There is no easy way to draw nothing conditionally, so I'll bind grey and multiply
  43. // which shouldn't change the contents of the framebuffer much.
  44. if( pShaderAPI->InFlashlightMode() )
  45. {
  46. pShaderAPI->BindStandardTexture( SHADER_SAMPLER0, TEXTURE_GREY );
  47. }
  48. else
  49. {
  50. BindTexture( SHADER_SAMPLER0, BASETEXTURE, FRAME );
  51. }
  52. }
  53. Draw( );
  54. }
  55. END_SHADER