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.

116 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 "floatcombine_ps20.inc"
  10. #include "floatcombine_ps20b.inc"
  11. // NOTE: This has to be the last file included!
  12. #include "tier0/memdbgon.h"
  13. BEGIN_VS_SHADER_FLAGS( floatcombine, "Help for floatcombine", SHADER_NOT_EDITABLE )
  14. BEGIN_SHADER_PARAMS
  15. SHADER_PARAM( BLOOMTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "" )
  16. SHADER_PARAM( SHARPNESS, SHADER_PARAM_TYPE_FLOAT, "1", "" )
  17. SHADER_PARAM( WOODCUT, SHADER_PARAM_TYPE_FLOAT, "0", "" )
  18. SHADER_PARAM( VIGNETTE_MIN_BRIGHT,SHADER_PARAM_TYPE_FLOAT,"1","")
  19. SHADER_PARAM( VIGNETTE_POWER,SHADER_PARAM_TYPE_FLOAT,"4","")
  20. SHADER_PARAM( EDGE_SOFTNESS,SHADER_PARAM_TYPE_FLOAT,"0","")
  21. SHADER_PARAM( BLOOMAMOUNT, SHADER_PARAM_TYPE_FLOAT, "1.0", "" )
  22. SHADER_PARAM( BLOOMEXPONENT, SHADER_PARAM_TYPE_FLOAT, "2.0", "" )
  23. SHADER_PARAM( ALPHASHARPENFACTOR, SHADER_PARAM_TYPE_FLOAT, "0.0", "" )
  24. END_SHADER_PARAMS
  25. SHADER_INIT
  26. {
  27. if( params[BASETEXTURE]->IsDefined() )
  28. {
  29. LoadTexture( BASETEXTURE );
  30. }
  31. if( params[BLOOMTEXTURE]->IsDefined() )
  32. {
  33. LoadTexture( BLOOMTEXTURE );
  34. }
  35. }
  36. SHADER_FALLBACK
  37. {
  38. return 0;
  39. }
  40. SHADER_DRAW
  41. {
  42. SHADOW_STATE
  43. {
  44. pShaderShadow->EnableDepthWrites( false );
  45. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  46. pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
  47. int fmt = VERTEX_POSITION;
  48. pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
  49. // convert from linear to gamma on write.
  50. pShaderShadow->EnableSRGBWrite( true );
  51. // Pre-cache shaders
  52. DECLARE_STATIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  53. SET_STATIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  54. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  55. {
  56. DECLARE_STATIC_PIXEL_SHADER( floatcombine_ps20b );
  57. SET_STATIC_PIXEL_SHADER( floatcombine_ps20b );
  58. }
  59. else
  60. {
  61. DECLARE_STATIC_PIXEL_SHADER( floatcombine_ps20 );
  62. SET_STATIC_PIXEL_SHADER( floatcombine_ps20 );
  63. }
  64. }
  65. DYNAMIC_STATE
  66. {
  67. float c0[4]={params[SHARPNESS]->GetFloatValue(),
  68. params[WOODCUT]->GetFloatValue(),
  69. params[BLOOMAMOUNT]->GetFloatValue(),
  70. params[ALPHASHARPENFACTOR]->GetFloatValue()};
  71. float c1[4]={params[BLOOMEXPONENT]->GetFloatValue(),
  72. params[VIGNETTE_MIN_BRIGHT]->GetFloatValue(),
  73. params[VIGNETTE_POWER]->GetFloatValue(),
  74. params[EDGE_SOFTNESS]->GetFloatValue()};
  75. pShaderAPI->SetPixelShaderConstant( 0, c0, 1 );
  76. pShaderAPI->SetPixelShaderConstant( 1, c1, 1 );
  77. BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, BASETEXTURE, -1 );
  78. BindTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_NONE, BLOOMTEXTURE, -1 );
  79. ITexture *base_texture=params[BASETEXTURE]->GetTextureValue();
  80. ITexture *bloom_texture=params[BLOOMTEXTURE]->GetTextureValue();
  81. float v0[4]={1.0/base_texture->GetActualWidth(),1.0/base_texture->GetActualHeight(),
  82. 1.0/bloom_texture->GetActualWidth(),1.0/bloom_texture->GetActualHeight()};
  83. pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, v0, 1 );
  84. DECLARE_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  85. SET_DYNAMIC_VERTEX_SHADER( screenspaceeffect_vs20 );
  86. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  87. {
  88. DECLARE_DYNAMIC_PIXEL_SHADER( floatcombine_ps20b );
  89. SET_DYNAMIC_PIXEL_SHADER( floatcombine_ps20b );
  90. }
  91. else
  92. {
  93. DECLARE_DYNAMIC_PIXEL_SHADER( floatcombine_ps20 );
  94. SET_DYNAMIC_PIXEL_SHADER( floatcombine_ps20 );
  95. }
  96. }
  97. Draw();
  98. }
  99. END_SHADER