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.

78 lines
2.3 KiB

  1. //===================== Copyright (c) Valve Corporation. All Rights Reserved. ======================
  2. //
  3. // Object space motion blur shader c++ backing file
  4. //
  5. //==================================================================================================
  6. #include "BaseVSShader.h"
  7. #include "object_motion_blur_vs20.inc"
  8. #include "object_motion_blur_ps20.inc"
  9. #include "object_motion_blur_ps20b.inc"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. BEGIN_VS_SHADER_FLAGS( ObjectMotionBlur, "Object Motion Blur", SHADER_NOT_EDITABLE )
  13. BEGIN_SHADER_PARAMS
  14. SHADER_PARAM( FB_TEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_FullFrameFB", "Full-screen framebuffer to sample from." )
  15. SHADER_PARAM( VELOCITY_TEXTURE, SHADER_PARAM_TYPE_TEXTURE, "_rt_SmallHDR0", "Full-screen velocity buffer to sample from." )
  16. END_SHADER_PARAMS
  17. SHADER_FALLBACK
  18. {
  19. return 0;
  20. }
  21. SHADER_INIT
  22. {
  23. if( params[ FB_TEXTURE ]->IsDefined() )
  24. {
  25. LoadTexture( FB_TEXTURE );
  26. }
  27. if( params[ VELOCITY_TEXTURE ]->IsDefined() )
  28. {
  29. LoadTexture( VELOCITY_TEXTURE );
  30. }
  31. }
  32. SHADER_DRAW
  33. {
  34. SHADOW_STATE
  35. {
  36. pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 1, 0, 0 );
  37. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  38. pShaderShadow->EnableSRGBRead( SHADER_SAMPLER0, true );
  39. pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
  40. pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, false );
  41. DECLARE_STATIC_VERTEX_SHADER( object_motion_blur_vs20 );
  42. SET_STATIC_VERTEX_SHADER( object_motion_blur_vs20 );
  43. Assert( g_pHardwareConfig->SupportsPixelShaders_2_b() );
  44. DECLARE_STATIC_PIXEL_SHADER( object_motion_blur_ps20b );
  45. SET_STATIC_PIXEL_SHADER( object_motion_blur_ps20b );
  46. pShaderShadow->EnableDepthWrites( false );
  47. pShaderShadow->EnableAlphaWrites( false );
  48. pShaderShadow->EnableSRGBWrite( true );
  49. }
  50. DYNAMIC_STATE
  51. {
  52. // Bind textures
  53. BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_SRGBREAD, FB_TEXTURE );
  54. BindTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_NONE, VELOCITY_TEXTURE );
  55. DECLARE_DYNAMIC_VERTEX_SHADER( object_motion_blur_vs20 );
  56. SET_DYNAMIC_VERTEX_SHADER( object_motion_blur_vs20 );
  57. Assert( g_pHardwareConfig->SupportsPixelShaders_2_b() );
  58. DECLARE_DYNAMIC_PIXEL_SHADER( object_motion_blur_ps20b );
  59. SET_DYNAMIC_PIXEL_SHADER( object_motion_blur_ps20b );
  60. }
  61. Draw();
  62. }
  63. END_SHADER