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.

105 lines
3.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "BaseVSShader.h"
  8. #include "screenspaceeffect_vs20.inc"
  9. #include "IntroScreenSpaceEffect_ps20.inc"
  10. #include "IntroScreenSpaceEffect_ps20b.inc"
  11. // NOTE: This has to be the last file included!
  12. #include "tier0/memdbgon.h"
  13. BEGIN_VS_SHADER_FLAGS( IntroScreenSpaceEffect, "Help for IntroScreenSpaceEffect", SHADER_NOT_EDITABLE )
  14. BEGIN_SHADER_PARAMS
  15. SHADER_PARAM( MODE, SHADER_PARAM_TYPE_INTEGER, "0", "" )
  16. SHADER_PARAM( ENABLESRGB, SHADER_PARAM_TYPE_BOOL, "0", "" )
  17. END_SHADER_PARAMS
  18. SHADER_INIT_PARAMS()
  19. {
  20. SET_FLAGS2( MATERIAL_VAR2_NEEDS_FULL_FRAME_BUFFER_TEXTURE );
  21. if ( !params[ENABLESRGB]->IsDefined() )
  22. {
  23. params[ENABLESRGB]->SetIntValue( 0 );
  24. }
  25. }
  26. SHADER_INIT
  27. {
  28. }
  29. SHADER_FALLBACK
  30. {
  31. return 0;
  32. }
  33. SHADER_DRAW
  34. {
  35. SHADOW_STATE
  36. {
  37. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  38. pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
  39. // On OSX OpenGL, we MUST do sRGB reads from the bloom and full framebuffer textures AND sRGB writes on the way out to the framebuffer.
  40. if ( params[ENABLESRGB]->GetIntValue() || IsOSX() )
  41. {
  42. pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, true );
  43. pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, true );
  44. pShaderShadow->EnableSRGBWrite( true );
  45. }
  46. // Only need the adapter if the shader expects sRGB values and we're forced to do an sRGB read by the API/Hardware
  47. bool bNeedsSRGBAdapter = ( params[ENABLESRGB]->GetIntValue() == 0 ) && IsOSX() && !g_pHardwareConfig->FakeSRGBWrite() && g_pHardwareConfig->CanDoSRGBReadFromRTs();
  48. pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 1, 0, 0 );
  49. DECLARE_STATIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  50. SET_STATIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  51. if ( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() ) // GL always goes the ps2b way for this shader, even on "ps20" parts
  52. {
  53. DECLARE_STATIC_PIXEL_SHADER( introscreenspaceeffect_ps20b );
  54. SET_STATIC_PIXEL_SHADER_COMBO( LINEAR_TO_SRGB, bNeedsSRGBAdapter );
  55. SET_STATIC_PIXEL_SHADER( introscreenspaceeffect_ps20b );
  56. }
  57. else
  58. {
  59. DECLARE_STATIC_PIXEL_SHADER( introscreenspaceeffect_ps20 );
  60. SET_STATIC_PIXEL_SHADER( introscreenspaceeffect_ps20 );
  61. }
  62. pShaderShadow->EnableBlending( true );
  63. pShaderShadow->BlendFunc( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE );
  64. }
  65. DYNAMIC_STATE
  66. {
  67. pShaderAPI->BindStandardTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_SRGBREAD, TEXTURE_FRAME_BUFFER_FULL_TEXTURE_0 );
  68. pShaderAPI->BindStandardTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_SRGBREAD, TEXTURE_FRAME_BUFFER_FULL_TEXTURE_1 );
  69. DECLARE_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  70. SET_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  71. if ( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() ) // GL always goes the ps2b way for this shader, even on "ps20" parts
  72. {
  73. DECLARE_DYNAMIC_PIXEL_SHADER( introscreenspaceeffect_ps20b );
  74. SET_DYNAMIC_PIXEL_SHADER_COMBO( MODE, params[MODE]->GetIntValue() );
  75. SET_DYNAMIC_PIXEL_SHADER( introscreenspaceeffect_ps20b );
  76. }
  77. else
  78. {
  79. DECLARE_DYNAMIC_PIXEL_SHADER( introscreenspaceeffect_ps20 );
  80. SET_DYNAMIC_PIXEL_SHADER_COMBO( MODE, params[MODE]->GetIntValue() );
  81. SET_DYNAMIC_PIXEL_SHADER( introscreenspaceeffect_ps20 );
  82. }
  83. SetPixelShaderConstant( 0, ALPHA );
  84. }
  85. Draw();
  86. }
  87. END_SHADER