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.

133 lines
4.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Header: $
  6. // $NoKeywords: $
  7. //=============================================================================//
  8. #include "shaderlib/cshader.h"
  9. #define USE_NEW_SHADER //Updating assembly shaders to fxc, this is for A/B testing.
  10. #ifdef USE_NEW_SHADER
  11. #include "debugtangentspace_vs11.inc"
  12. #include "debugtangentspace_vs20.inc"
  13. #include "unlitgeneric_notexture_ps11.inc"
  14. #include "unlitgeneric_notexture_ps20.inc"
  15. #include "unlitgeneric_notexture_ps20b.inc"
  16. #else
  17. #include "debugtangentspace.inc"
  18. #endif
  19. // memdbgon must be the last include file in a .cpp file!!!
  20. #include "tier0/memdbgon.h"
  21. BEGIN_SHADER( DebugTangentSpace, "Help for DebugTangentSpace" )
  22. BEGIN_SHADER_PARAMS
  23. SHADER_PARAM_OVERRIDE( BASETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/basetexture", "unused", SHADER_PARAM_NOT_EDITABLE )
  24. SHADER_PARAM_OVERRIDE( FRAME, SHADER_PARAM_TYPE_INTEGER, "0", "unused", SHADER_PARAM_NOT_EDITABLE )
  25. SHADER_PARAM_OVERRIDE( BASETEXTURETRANSFORM, SHADER_PARAM_TYPE_MATRIX, "center .5 .5 scale 1 1 rotate 0 translate 0 0", "unused", SHADER_PARAM_NOT_EDITABLE )
  26. SHADER_PARAM_OVERRIDE( COLOR, SHADER_PARAM_TYPE_COLOR, "{255 255 255}", "unused", SHADER_PARAM_NOT_EDITABLE )
  27. SHADER_PARAM_OVERRIDE( ALPHA, SHADER_PARAM_TYPE_FLOAT, "1.0", "unused", SHADER_PARAM_NOT_EDITABLE )
  28. END_SHADER_PARAMS
  29. SHADER_INIT_PARAMS()
  30. {
  31. SET_FLAGS2( MATERIAL_VAR2_SUPPORTS_HW_SKINNING );
  32. }
  33. SHADER_INIT
  34. {
  35. }
  36. SHADER_DRAW
  37. {
  38. if (g_pHardwareConfig->SupportsVertexAndPixelShaders())
  39. {
  40. SHADOW_STATE
  41. {
  42. // Set stream format (note that this shader supports compression)
  43. unsigned int flags = VERTEX_POSITION | VERTEX_NORMAL | VERTEX_FORMAT_COMPRESSED;
  44. int nTexCoordCount = 0;
  45. int userDataSize = 4;
  46. pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, NULL, userDataSize );
  47. #ifdef USE_NEW_SHADER
  48. if( g_pHardwareConfig->GetDXSupportLevel() >= 90 )
  49. {
  50. DECLARE_STATIC_VERTEX_SHADER( debugtangentspace_vs20 );
  51. SET_STATIC_VERTEX_SHADER( debugtangentspace_vs20 );
  52. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  53. {
  54. DECLARE_STATIC_PIXEL_SHADER( unlitgeneric_notexture_ps20b );
  55. SET_STATIC_PIXEL_SHADER( unlitgeneric_notexture_ps20b );
  56. }
  57. else
  58. {
  59. DECLARE_STATIC_PIXEL_SHADER( unlitgeneric_notexture_ps20 );
  60. SET_STATIC_PIXEL_SHADER( unlitgeneric_notexture_ps20 );
  61. }
  62. }
  63. else
  64. {
  65. DECLARE_STATIC_VERTEX_SHADER( debugtangentspace_vs11 );
  66. SET_STATIC_VERTEX_SHADER( debugtangentspace_vs11 );
  67. DECLARE_STATIC_PIXEL_SHADER( unlitgeneric_notexture_ps11 );
  68. SET_STATIC_PIXEL_SHADER( unlitgeneric_notexture_ps11 );
  69. }
  70. #else
  71. debugtangentspace_Static_Index vshIndex;
  72. pShaderShadow->SetVertexShader( "DebugTangentSpace", vshIndex.GetIndex() );
  73. pShaderShadow->SetPixelShader( "UnlitGeneric_NoTexture" );
  74. #endif
  75. }
  76. DYNAMIC_STATE
  77. {
  78. #ifdef USE_NEW_SHADER
  79. if( g_pHardwareConfig->GetDXSupportLevel() >= 90 )
  80. {
  81. DECLARE_DYNAMIC_VERTEX_SHADER( debugtangentspace_vs20 );
  82. SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z );
  83. SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 );
  84. SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression );
  85. SET_DYNAMIC_VERTEX_SHADER( debugtangentspace_vs20 );
  86. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  87. {
  88. DECLARE_DYNAMIC_PIXEL_SHADER( unlitgeneric_notexture_ps20b );
  89. SET_DYNAMIC_PIXEL_SHADER( unlitgeneric_notexture_ps20b );
  90. }
  91. else
  92. {
  93. DECLARE_DYNAMIC_PIXEL_SHADER( unlitgeneric_notexture_ps20 );
  94. SET_DYNAMIC_PIXEL_SHADER( unlitgeneric_notexture_ps20 );
  95. }
  96. }
  97. else // legacy hardware
  98. {
  99. DECLARE_DYNAMIC_VERTEX_SHADER( debugtangentspace_vs11 );
  100. SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z );
  101. SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 );
  102. SET_DYNAMIC_VERTEX_SHADER( debugtangentspace_vs11 );
  103. DECLARE_DYNAMIC_PIXEL_SHADER( unlitgeneric_notexture_ps11 );
  104. SET_DYNAMIC_PIXEL_SHADER( unlitgeneric_notexture_ps11 );
  105. }
  106. #else
  107. debugtangentspace_Dynamic_Index vshIndex;
  108. vshIndex.SetDOWATERFOG( pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z );
  109. vshIndex.SetSKINNING( pShaderAPI->GetCurrentNumBones() > 0 );
  110. pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() );
  111. #endif
  112. }
  113. Draw();
  114. }
  115. }
  116. END_SHADER