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.

107 lines
2.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "BaseVSShader.h"
  7. #include "cpp_shader_constant_register_map.h"
  8. #include "windowimposter_vs20.inc"
  9. #include "windowimposter_ps20.inc"
  10. #include "windowimposter_ps20b.inc"
  11. // memdbgon must be the last include file in a .cpp file!!!
  12. #include "tier0/memdbgon.h"
  13. DEFINE_FALLBACK_SHADER( WindowImposter, WindowImposter_DX90 )
  14. BEGIN_VS_SHADER( WindowImposter_DX90,
  15. "Help for WindowImposter_DX90" )
  16. BEGIN_SHADER_PARAMS
  17. SHADER_PARAM( ENVMAP, SHADER_PARAM_TYPE_TEXTURE, "shadertest/shadertest_env", "envmap" )
  18. END_SHADER_PARAMS
  19. // Set up anything that is necessary to make decisions in SHADER_FALLBACK.
  20. SHADER_INIT_PARAMS()
  21. {
  22. }
  23. SHADER_FALLBACK
  24. {
  25. if ( g_pHardwareConfig->GetDXSupportLevel() < 90)
  26. return "WindowImposter_DX80";
  27. return NULL;
  28. }
  29. SHADER_INIT
  30. {
  31. LoadCubeMap( ENVMAP );
  32. }
  33. SHADER_DRAW
  34. {
  35. SHADOW_STATE
  36. {
  37. if( g_pHardwareConfig->GetHDRType() != HDR_TYPE_NONE )
  38. pShaderShadow->EnableSRGBWrite( true );
  39. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  40. DECLARE_STATIC_VERTEX_SHADER( windowimposter_vs20 );
  41. SET_STATIC_VERTEX_SHADER( windowimposter_vs20 );
  42. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  43. {
  44. DECLARE_STATIC_PIXEL_SHADER( windowimposter_ps20b );
  45. SET_STATIC_PIXEL_SHADER( windowimposter_ps20b );
  46. }
  47. else
  48. {
  49. DECLARE_STATIC_PIXEL_SHADER( windowimposter_ps20 );
  50. SET_STATIC_PIXEL_SHADER( windowimposter_ps20 );
  51. }
  52. pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 1, 0, 0 );
  53. pShaderShadow->EnableBlending( true );
  54. pShaderShadow->BlendFunc( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE_MINUS_SRC_ALPHA );
  55. pShaderShadow->EnableDepthWrites( false );
  56. FogToFogColor();
  57. }
  58. DYNAMIC_STATE
  59. {
  60. DECLARE_DYNAMIC_VERTEX_SHADER( windowimposter_vs20 );
  61. SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z );
  62. SET_DYNAMIC_VERTEX_SHADER( windowimposter_vs20 );
  63. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  64. {
  65. DECLARE_DYNAMIC_PIXEL_SHADER( windowimposter_ps20b );
  66. SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() );
  67. SET_DYNAMIC_PIXEL_SHADER( windowimposter_ps20b );
  68. }
  69. else
  70. {
  71. DECLARE_DYNAMIC_PIXEL_SHADER( windowimposter_ps20 );
  72. SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() );
  73. SET_DYNAMIC_PIXEL_SHADER( windowimposter_ps20 );
  74. }
  75. pShaderAPI->SetPixelShaderFogParams( PSREG_FOG_PARAMS );
  76. float vEyePos_SpecExponent[4];
  77. pShaderAPI->GetWorldSpaceCameraPosition( vEyePos_SpecExponent );
  78. vEyePos_SpecExponent[3] = 0.0f;
  79. pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, vEyePos_SpecExponent, 1 );
  80. BindTexture( SHADER_SAMPLER0, ENVMAP, -1 );
  81. SetModulationVertexShaderDynamicState();
  82. }
  83. Draw();
  84. }
  85. END_SHADER