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.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Clears color/depth, but obeys stencil while doing so
  4. //
  5. //=============================================================================//
  6. #include "BaseVSShader.h"
  7. #include "BufferClearObeyStencil_vs11.inc"
  8. // memdbgon must be the last include file in a .cpp file!!!
  9. #include "tier0/memdbgon.h"
  10. DEFINE_FALLBACK_SHADER( BufferClearObeyStencil, BufferClearObeyStencil_DX8 )
  11. BEGIN_VS_SHADER_FLAGS( BufferClearObeyStencil_DX8, "", SHADER_NOT_EDITABLE )
  12. BEGIN_SHADER_PARAMS
  13. SHADER_PARAM( CLEARCOLOR, SHADER_PARAM_TYPE_INTEGER, "1", "activates clearing of color" )
  14. SHADER_PARAM( CLEARDEPTH, SHADER_PARAM_TYPE_INTEGER, "1", "activates clearing of depth" )
  15. END_SHADER_PARAMS
  16. SHADER_INIT_PARAMS()
  17. {
  18. }
  19. SHADER_FALLBACK
  20. {
  21. if ( g_pHardwareConfig->GetDXSupportLevel() < 80 )
  22. {
  23. return "BufferClearObeyStencil_DX6";
  24. }
  25. return 0;
  26. }
  27. SHADER_INIT
  28. {
  29. }
  30. SHADER_DRAW
  31. {
  32. SHADOW_STATE
  33. {
  34. pShaderShadow->DepthFunc( SHADER_DEPTHFUNC_ALWAYS );
  35. bool bEnableDepthWrites = params[CLEARDEPTH]->GetIntValue() != 0;
  36. pShaderShadow->EnableDepthWrites( bEnableDepthWrites );
  37. bool bEnableColorWrites = params[CLEARCOLOR]->GetIntValue() != 0;
  38. pShaderShadow->EnableColorWrites( bEnableColorWrites );
  39. pShaderShadow->EnableAlphaWrites( bEnableColorWrites );
  40. pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION|VERTEX_COLOR, 1, 0, 0 );
  41. bufferclearobeystencil_vs11_Static_Index vshIndex;
  42. pShaderShadow->SetVertexShader( "BufferClearObeyStencil_vs11", vshIndex.GetIndex() );
  43. pShaderShadow->SetPixelShader( "BufferClearObeyStencil_ps11", 0 );
  44. }
  45. DYNAMIC_STATE
  46. {
  47. pShaderAPI->SetVertexShaderIndex( 0 );
  48. pShaderAPI->SetPixelShaderIndex( 0 );
  49. }
  50. Draw( );
  51. }
  52. END_SHADER