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.

81 lines
2.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "BaseVSShader.h"
  7. #include "common_hlsl_cpp_consts.h"
  8. #include "convar.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. DEFINE_FALLBACK_SHADER( Downsample_nohdr, Downsample_nohdr_DX80 )
  12. BEGIN_VS_SHADER_FLAGS( Downsample_nohdr_DX80, "Help for Downsample_nohdr_DX80", SHADER_NOT_EDITABLE )
  13. BEGIN_SHADER_PARAMS
  14. END_SHADER_PARAMS
  15. SHADER_INIT
  16. {
  17. LoadTexture( BASETEXTURE );
  18. }
  19. SHADER_FALLBACK
  20. {
  21. if ( g_pHardwareConfig->GetDXSupportLevel() < 80 )
  22. {
  23. return "Wireframe";
  24. }
  25. return 0;
  26. }
  27. SHADER_DRAW
  28. {
  29. SHADOW_STATE
  30. {
  31. pShaderShadow->EnableDepthWrites( false );
  32. pShaderShadow->EnableAlphaWrites( true );
  33. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  34. pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
  35. pShaderShadow->EnableTexture( SHADER_SAMPLER2, true );
  36. pShaderShadow->EnableTexture( SHADER_SAMPLER3, true );
  37. pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 1, 0, 0 );
  38. pShaderShadow->SetVertexShader( "Downsample_vs11", 0 );
  39. pShaderShadow->SetPixelShader( "Downsample_nohdr_ps11" );
  40. }
  41. DYNAMIC_STATE
  42. {
  43. BindTexture( SHADER_SAMPLER0, BASETEXTURE, -1 );
  44. BindTexture( SHADER_SAMPLER1, BASETEXTURE, -1 );
  45. BindTexture( SHADER_SAMPLER2, BASETEXTURE, -1 );
  46. BindTexture( SHADER_SAMPLER3, BASETEXTURE, -1 );
  47. int width, height;
  48. pShaderAPI->GetBackBufferDimensions( width, height );
  49. float v[4][4];
  50. float dX = 1.0f/width;
  51. float dY = 1.0f/height;
  52. v[0][0] = .5*dX;
  53. v[0][1] = .5*dY;
  54. v[1][0] = 2.5*dX;
  55. v[1][1] = .5*dY;
  56. v[2][0] = .5*dX;
  57. v[2][1] = 2.5*dY;
  58. v[3][0] = 2.5*dX;
  59. v[3][1] = 2.5*dY;
  60. pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, &v[0][0], 4 );
  61. pShaderAPI->SetVertexShaderIndex( 0 );
  62. pShaderAPI->SetPixelShaderIndex( 0 );
  63. }
  64. Draw();
  65. }
  66. END_SHADER