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.

84 lines
2.5 KiB

  1. //===== Copyright � 1996-2007, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #include "BaseVSShader.h"
  8. #include "sfm_ao_blur_vs30.inc"
  9. #include "sfm_ao_blur_ps30.inc"
  10. // NOTE: This has to be the last file included!
  11. #include "tier0/memdbgon.h"
  12. BEGIN_VS_SHADER_FLAGS( sfm_ao_blur_shader, "Help for SFM ambient occlusion blur pass", SHADER_NOT_EDITABLE )
  13. BEGIN_SHADER_PARAMS
  14. SHADER_PARAM( FRONTNDTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "" )
  15. SHADER_PARAM( AOTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "", "" )
  16. SHADER_PARAM( JITTERSEED, SHADER_PARAM_TYPE_VEC4, "", "" )
  17. END_SHADER_PARAMS
  18. SHADER_INIT
  19. {
  20. LoadTexture( FRONTNDTEXTURE );
  21. LoadTexture( AOTEXTURE );
  22. }
  23. SHADER_FALLBACK
  24. {
  25. return 0;
  26. }
  27. SHADER_DRAW
  28. {
  29. SHADOW_STATE
  30. {
  31. pShaderShadow->EnableDepthWrites( false );
  32. pShaderShadow->EnableDepthTest( false );
  33. pShaderShadow->EnableAlphaWrites( false );
  34. pShaderShadow->EnableBlending( false );
  35. pShaderShadow->EnableCulling( false );
  36. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  37. pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
  38. pShaderShadow->EnableTexture( SHADER_SAMPLER2, true ); // Noise map
  39. int fmt = VERTEX_POSITION;
  40. pShaderShadow->VertexShaderVertexFormat( fmt, 1, NULL, 0 );
  41. DECLARE_STATIC_VERTEX_SHADER( sfm_ao_blur_vs30 );
  42. SET_STATIC_VERTEX_SHADER( sfm_ao_blur_vs30 );
  43. DECLARE_STATIC_PIXEL_SHADER( sfm_ao_blur_ps30 );
  44. SET_STATIC_PIXEL_SHADER( sfm_ao_blur_ps30 );
  45. }
  46. DYNAMIC_STATE
  47. {
  48. BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, FRONTNDTEXTURE, -1 );
  49. BindTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_NONE, AOTEXTURE, -1 );
  50. // Dimensions of screen, used for screen-space noise map sampling
  51. float vScreenScale[4] = {1280.0f / 32.0f, 720.0f / 32.0f, 0, 0};
  52. int nWidth, nHeight;
  53. pShaderAPI->GetBackBufferDimensions( nWidth, nHeight );
  54. vScreenScale[0] = (float) nWidth / 32.0f;
  55. vScreenScale[1] = (float) nHeight / 32.0f;
  56. pShaderAPI->SetPixelShaderConstant( 0, vScreenScale, 1 );
  57. float vNoiseOffset[4];
  58. HashShadow2DJitter( params[JITTERSEED]->GetFloatValue(), vNoiseOffset, vNoiseOffset+1 );
  59. pShaderAPI->SetPixelShaderConstant( 1, vNoiseOffset, 1 );
  60. DECLARE_DYNAMIC_VERTEX_SHADER( sfm_ao_blur_vs30 );
  61. SET_DYNAMIC_VERTEX_SHADER( sfm_ao_blur_vs30 );
  62. DECLARE_DYNAMIC_PIXEL_SHADER( sfm_ao_blur_ps30 );
  63. SET_DYNAMIC_PIXEL_SHADER( sfm_ao_blur_ps30 );
  64. }
  65. Draw();
  66. }
  67. END_SHADER