Counter Strike : Global Offensive Source Code
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.

103 lines
2.7 KiB

  1. //========= Copyright � 1996-2005, 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. return NULL;
  26. }
  27. SHADER_INIT
  28. {
  29. LoadCubeMap( ENVMAP );
  30. }
  31. SHADER_DRAW
  32. {
  33. SHADOW_STATE
  34. {
  35. if( g_pHardwareConfig->GetHDRType() != HDR_TYPE_NONE )
  36. pShaderShadow->EnableSRGBWrite( true );
  37. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  38. DECLARE_STATIC_VERTEX_SHADER( windowimposter_vs20 );
  39. SET_STATIC_VERTEX_SHADER( windowimposter_vs20 );
  40. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  41. {
  42. DECLARE_STATIC_PIXEL_SHADER( windowimposter_ps20b );
  43. SET_STATIC_PIXEL_SHADER( windowimposter_ps20b );
  44. }
  45. else
  46. {
  47. DECLARE_STATIC_PIXEL_SHADER( windowimposter_ps20 );
  48. SET_STATIC_PIXEL_SHADER( windowimposter_ps20 );
  49. }
  50. pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 1, 0, 0 );
  51. pShaderShadow->EnableBlending( true );
  52. pShaderShadow->BlendFunc( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE_MINUS_SRC_ALPHA );
  53. pShaderShadow->EnableDepthWrites( false );
  54. FogToFogColor();
  55. PI_BeginCommandBuffer();
  56. PI_SetModulationVertexShaderDynamicState();
  57. PI_EndCommandBuffer();
  58. }
  59. DYNAMIC_STATE
  60. {
  61. DECLARE_DYNAMIC_VERTEX_SHADER( windowimposter_vs20 );
  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( windowimposter_ps20b );
  67. }
  68. else
  69. {
  70. DECLARE_DYNAMIC_PIXEL_SHADER( windowimposter_ps20 );
  71. SET_DYNAMIC_PIXEL_SHADER( windowimposter_ps20 );
  72. }
  73. pShaderAPI->SetPixelShaderFogParams( PSREG_FOG_PARAMS );
  74. float vEyePos_SpecExponent[4];
  75. pShaderAPI->GetWorldSpaceCameraPosition( vEyePos_SpecExponent );
  76. vEyePos_SpecExponent[3] = 0.0f;
  77. pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, vEyePos_SpecExponent, 1 );
  78. BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, ENVMAP, -1 );
  79. }
  80. Draw();
  81. }
  82. END_SHADER