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.

88 lines
2.3 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #include "BaseVSShader.h"
  8. #include "common_hlsl_cpp_consts.h"
  9. #include "downsample_nohdr_ps20.inc"
  10. #include "downsample_nohdr_ps20b.inc"
  11. // NOTE: This has to be the last file included!
  12. #include "tier0/memdbgon.h"
  13. BEGIN_VS_SHADER_FLAGS( sfm_downsample_shader, "Help for Downsample", SHADER_NOT_EDITABLE )
  14. BEGIN_SHADER_PARAMS
  15. END_SHADER_PARAMS
  16. SHADER_INIT
  17. {
  18. LoadTexture( BASETEXTURE );
  19. }
  20. SHADER_FALLBACK
  21. {
  22. return 0;
  23. }
  24. SHADER_DRAW
  25. {
  26. SHADOW_STATE
  27. {
  28. pShaderShadow->EnableDepthWrites( false );
  29. pShaderShadow->EnableAlphaWrites( true );
  30. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  31. pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, false );
  32. pShaderShadow->EnableSRGBWrite( false );
  33. pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 1, 0, 0 );
  34. pShaderShadow->SetVertexShader( "downsample_vs20", 0 );
  35. DECLARE_STATIC_PIXEL_SHADER( downsample_nohdr_ps20b );
  36. SET_STATIC_PIXEL_SHADER_COMBO( BLOOMTYPE, 0 );
  37. SET_STATIC_PIXEL_SHADER_COMBO( PS3REGCOUNT48, 0 );
  38. SET_STATIC_PIXEL_SHADER_COMBO( SRGB_INPUT_ADAPTER, 0 ); // Mac sRGB insanity
  39. SET_STATIC_PIXEL_SHADER( downsample_nohdr_ps20b );
  40. }
  41. DYNAMIC_STATE
  42. {
  43. BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, BASETEXTURE, -1 );
  44. int width, height;
  45. pShaderAPI->GetCurrentRenderTargetDimensions( width, height );
  46. float v[4][4];
  47. float dX = 1.0f / (float) width;
  48. float dY = 1.0f / (float) height;
  49. v[0][0] = 0.5 * dX;
  50. v[0][1] = 0.5 * dY;
  51. v[1][0] = 2.5 * dX;
  52. v[1][1] = 0.5 * dY;
  53. v[2][0] = 0.5 * dX;
  54. v[2][1] = 2.5 * dY;
  55. v[3][0] = 2.5 * dX;
  56. v[3][1] = 2.5 * dY;
  57. pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, &v[0][0], 4 );
  58. pShaderAPI->SetVertexShaderIndex( 0 );
  59. float flPixelShaderParams[4] = { 1.0f, 1.0f, 1.0f, 2.2f };
  60. pShaderAPI->SetPixelShaderConstant( 0, flPixelShaderParams, 1 );
  61. float vPsConst1[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
  62. pShaderAPI->SetPixelShaderConstant( 1, vPsConst1, 1 );
  63. DECLARE_DYNAMIC_PIXEL_SHADER( downsample_nohdr_ps20b );
  64. SET_DYNAMIC_PIXEL_SHADER_COMBO( FLOAT_BACK_BUFFER, 1 );
  65. SET_DYNAMIC_PIXEL_SHADER( downsample_nohdr_ps20b );
  66. }
  67. Draw();
  68. }
  69. END_SHADER