Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. #if !defined(__RESHADE__) || __RESHADE__ < 20000
  2. #error "ReShade 2.0+ is required to use these shaders"
  3. #endif
  4.  
  5. #define STR(value) #value
  6. #define STE(value) STR(value)
  7.  
  8. #include "ReShade\KeyCodes.h"
  9.  
  10. // Global Settings
  11. #if exists(STE(ReShade/Profiles/__APPLICATION_NAME__/Global.cfg))
  12. #include STE(ReShade/Profiles/__APPLICATION_NAME__/Global.cfg)
  13. #else
  14. #warning "Could not find application profile, falling back to default"
  15. #include "ReShade/Profiles/Default/Global.cfg"
  16. #endif
  17.  
  18. #pragma reshade screenshot_key RESHADE_SCREENSHOT_KEY
  19. #pragma reshade screenshot_format RESHADE_SCREENSHOT_FORMAT
  20.  
  21. #if RESHADE_SHOW_FPS
  22. #pragma reshade showfps
  23. #endif
  24. #if RESHADE_SHOW_CLOCK
  25. #pragma reshade showclock
  26. #endif
  27. #if RESHADE_SHOW_STATISTICS
  28. #pragma reshade showstatistics
  29. #endif
  30. #if RESHADE_SHOW_TOGGLE_MESSAGES
  31. #pragma reshade showtogglemessage
  32. #endif
  33.  
  34. namespace ReShade
  35. {
  36. // Global Variables
  37. static const float AspectRatio = BUFFER_WIDTH * BUFFER_RCP_HEIGHT;
  38. static const float2 PixelSize = float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT);
  39. static const float2 ScreenSize = float2(BUFFER_WIDTH, BUFFER_HEIGHT);
  40. uniform float Timer < source = "timer"; >;
  41. uniform float FrameTime < source = "frametime"; >;
  42. uniform float2 MouseCoords < source = "mousepoint"; >;
  43.  
  44. // Global Textures and Samplers
  45. texture BackBufferTex : COLOR;
  46. texture DepthBufferTex : DEPTH;
  47.  
  48. texture OriginalColorTex { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; };
  49. #if RESHADE_DEPTH_LINEARIZATION
  50. texture LinearizedDepthTex { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = R32F; };
  51. #else
  52. texture LinearizedDepthTex : DEPTH;
  53. #endif
  54.  
  55. sampler BackBuffer { Texture = BackBufferTex; };
  56. sampler OriginalColor { Texture = OriginalColorTex; };
  57. sampler OriginalDepth { Texture = DepthBufferTex; };
  58. sampler LinearizedDepth { Texture = LinearizedDepthTex; };
  59.  
  60. // Full-screen triangle vertex shader
  61. void VS_PostProcess(in uint id : SV_VertexID, out float4 pos : SV_Position, out float2 texcoord : TEXCOORD)
  62. {
  63. texcoord.x = (id == 2) ? 2.0 : 0.0;
  64. texcoord.y = (id == 1) ? 2.0 : 0.0;
  65. pos = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
  66. }
  67.  
  68. // Color and depth buffer copy and linearization shaders
  69. float4 PS_CopyBackBuffer(float4 vpos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
  70. {
  71. return tex2D(BackBuffer, texcoord);
  72. }
  73. #if RESHADE_DEPTH_LINEARIZATION
  74. void PS_DepthLinearization(float4 vpos : SV_Position, float2 texcoord : TEXCOORD0, out float depth : SV_Target)
  75. {
  76. #if RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN
  77. texcoord.y = 1.0 - texcoord.y;
  78. #endif
  79. depth = tex2D(OriginalDepth, texcoord).x;
  80.  
  81. #if RESHADE_DEPTH_INPUT_IS_LOGARITHMIC
  82. const float C = 0.01;
  83. depth = (exp(depth * log(C + 1.0)) - 1.0) / C;
  84. #endif
  85. #if RESHADE_DEPTH_INPUT_IS_REVERSED
  86. depth = 1.0 - depth;
  87. #endif
  88. const float N = 1.0;
  89. depth /= RESHADE_DEPTH_LINEARIZATION_FAR_PLANE - depth * (RESHADE_DEPTH_LINEARIZATION_FAR_PLANE - N);
  90. }
  91. #endif
  92. }
  93.  
  94. technique Setup < enabled = true; >
  95. {
  96. pass ColorBackup
  97. {
  98. VertexShader = ReShade::VS_PostProcess;
  99. PixelShader = ReShade::PS_CopyBackBuffer;
  100. RenderTarget = ReShade::OriginalColorTex;
  101. }
  102. #if RESHADE_DEPTH_LINEARIZATION
  103. pass DepthLinearization
  104. {
  105. VertexShader = ReShade::VS_PostProcess;
  106. PixelShader = ReShade::PS_DepthLinearization;
  107. RenderTarget = ReShade::LinearizedDepthTex;
  108. }
  109. #endif
  110. }
  111.  
  112. // Preset Settings
  113. #if !defined(RESHADE_PRESET) || !exists(STE(ReShade/Presets/RESHADE_PRESET))
  114. #warning "Could not find preset, falling back to default"
  115. #undef RESHADE_PRESET
  116. #define RESHADE_PRESET Default
  117. #endif
  118.  
  119. #define EFFECT(author, name) STE(ReShade/Shaders/author/name.fx)
  120. #define EFFECT_CONFIG(author) STE(ReShade/Presets/RESHADE_PRESET/Shaders_by_##author.cfg)
  121. #define EFFECT_CONFIG_UNDEF(author) STE(ReShade/Shaders/author.undef)
  122.  
  123. #include STE(ReShade/Presets/RESHADE_PRESET/Pipeline.cfg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement