Advertisement
Guest User

qUINT_common.fxh

a guest
May 31st, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. /*
  2. DO NOT EDIT
  3. DO NOT EDIT
  4. DO NOT EDIT
  5.  
  6. I cannot stress this enough - if you don't want to break
  7. EVERY shader that depends on this file, do not edit.
  8.  
  9. */
  10.  
  11. #pragma once
  12.  
  13. #if !defined(__RESHADE__) || __RESHADE__ < 40000
  14. #error "ReShade 4.0+ is required to use this header file"
  15. #endif
  16.  
  17. #ifndef RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN
  18. #define RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN 0
  19. #endif
  20. #ifndef RESHADE_DEPTH_INPUT_IS_REVERSED
  21. #define RESHADE_DEPTH_INPUT_IS_REVERSED 0
  22. #endif
  23. #ifndef RESHADE_DEPTH_INPUT_IS_LOGARITHMIC
  24. #define RESHADE_DEPTH_INPUT_IS_LOGARITHMIC 0
  25. #endif
  26. #ifndef RESHADE_DEPTH_LINEARIZATION_FAR_PLANE
  27. #define RESHADE_DEPTH_LINEARIZATION_FAR_PLANE 1000.0
  28. #endif
  29.  
  30. namespace qUINT
  31. {
  32. uniform float FRAME_TIME <source = "frametime";>;
  33.  
  34. static const float2 ASPECT_RATIO = float2(1.0, BUFFER_WIDTH * BUFFER_RCP_HEIGHT);
  35. static const float2 PIXEL_SIZE = float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT);
  36. static const float2 SCREEN_SIZE = float2(BUFFER_WIDTH, BUFFER_HEIGHT);
  37.  
  38. // Global textures and samplers
  39. texture BackBufferTex : COLOR;
  40. texture DepthBufferTex : DEPTH;
  41.  
  42. sampler sBackBufferTex { Texture = BackBufferTex; };
  43. sampler sDepthBufferTex { Texture = DepthBufferTex; };
  44.  
  45. //reusable textures for the shaders
  46. texture2D CommonTex0 { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; };
  47. texture2D CommonTex1 { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; };
  48.  
  49. sampler2D sCommonTex0 { Texture = CommonTex0; };
  50. sampler2D sCommonTex1 { Texture = CommonTex1; };
  51.  
  52. // Helper functions
  53. float linear_depth(float2 uv)
  54. {
  55. #if RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN
  56. uv.y = 1.0 - uv.y;
  57. #endif
  58. float depth = tex2Dlod(sDepthBufferTex, float4(uv, 0, 0)).x * 1600;
  59.  
  60. #if RESHADE_DEPTH_INPUT_IS_LOGARITHMIC
  61. const float C = 0.01;
  62. depth = (exp(depth * log(C + 1.0)) - 1.0) / C;
  63. #endif
  64. #if RESHADE_DEPTH_INPUT_IS_REVERSED
  65. depth = 1.0 - depth;
  66. #endif
  67. const float nearZ = 300.0;
  68. const float farZ = 400.0;
  69. return rcp(depth * ((farZ - nearZ) / (-farZ * nearZ)) + farZ / (farZ * nearZ));
  70. }
  71. }
  72.  
  73. // Vertex shader generating a triangle covering the entire screen
  74. void PostProcessVS(in uint id : SV_VertexID, out float4 vpos : SV_Position, out float2 uv : TEXCOORD)
  75. {
  76. uv.x = (id == 2) ? 2.0 : 0.0;
  77. uv.y = (id == 1) ? 2.0 : 0.0;
  78. vpos = float4(uv * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement