Advertisement
lordbean

FXAA for PCMASTERRACE ReShade3+

Nov 7th, 2021 (edited)
1,011
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.61 KB | None | 0 0
  1. /**
  2. * FXAA 3.11
  3. *
  4. * for ReShade 3.0+
  5. *
  6. * Ultra Extreme quality mod by lordbean
  7. */
  8.  
  9. #include "ReShadeUI.fxh"
  10.  
  11. uniform float Subpix < __UNIFORM_SLIDER_FLOAT1
  12. ui_min = 0.0; ui_max = 1.0;
  13. ui_tooltip = "Amount of sub-pixel aliasing removal. Higher values makes the image softer/blurrier.";
  14. > = 0.4;
  15.  
  16. uniform float EdgeThreshold < __UNIFORM_SLIDER_FLOAT1
  17. ui_min = 0.0; ui_max = 1.0;
  18. ui_label = "Edge Detection Threshold";
  19. ui_tooltip = "The minimum amount of local contrast required to apply algorithm.";
  20. > = 0.0625;
  21. uniform float EdgeThresholdMin < __UNIFORM_SLIDER_FLOAT1
  22. ui_min = 0.0; ui_max = 1.0;
  23. ui_label = "Darkness Threshold";
  24. ui_tooltip = "Pixels darker than this are not processed in order to increase performance.";
  25. > = 0.0;
  26.  
  27. //------------------------------ Non-GUI-settings -------------------------------------------------
  28.  
  29. #ifndef FXAA_QUALITY__PRESET
  30. // Valid Quality Presets
  31. // 10 to 15 - default medium dither (10=fastest, 15=highest quality)
  32. // 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)
  33. // 39 - no dither, very expensive - but not expensive ENOUGH. we're redefining it
  34. #define FXAA_QUALITY__PRESET 39
  35. #endif
  36.  
  37. #ifndef FXAA_GREEN_AS_LUMA
  38. #define FXAA_GREEN_AS_LUMA 0
  39. #endif
  40.  
  41. #ifndef FXAA_LINEAR_LIGHT
  42. #define FXAA_LINEAR_LIGHT 0
  43. #endif
  44.  
  45. //-------------------------------------------------------------------------------------------------
  46.  
  47. #if (__RENDERER__ == 0xb000 || __RENDERER__ == 0xb100)
  48. #define FXAA_GATHER4_ALPHA 1
  49. #define FxaaTexAlpha4(t, p) tex2Dgather(t, p, 3)
  50. #define FxaaTexOffAlpha4(t, p, o) tex2Dgatheroffset(t, p, o, 3)
  51. #define FxaaTexGreen4(t, p) tex2Dgather(t, p, 1)
  52. #define FxaaTexOffGreen4(t, p, o) tex2Dgatheroffset(t, p, o, 1)
  53. #endif
  54.  
  55. #define FXAA_PC 1
  56. #define FXAA_HLSL_3 1
  57.  
  58. // Green as luma requires non-linear colorspace
  59. #if FXAA_GREEN_AS_LUMA
  60. #undef FXAA_LINEAR_LIGHT
  61. #endif
  62.  
  63. #include "FXAA.fxh"
  64. #include "ReShade.fxh"
  65.  
  66. // Redefine extreme quality preset because extreme isn't extreme enough
  67. // The header code actually includes an extra step above the baseline
  68. // extreme preset activated by setting FXAA_QUALITY__PS to 13 and adding
  69. // the extra define for FXAA_QUALITY__P12 below
  70. #if FXAA_QUALITY__PRESET == 39
  71. #undef FXAA_QUALITY__PS
  72. #undef FXAA_QUALITY__P0
  73. #undef FXAA_QUALITY__P1
  74. #undef FXAA_QUALITY__P2
  75. #undef FXAA_QUALITY__P3
  76. #undef FXAA_QUALITY__P4
  77. #undef FXAA_QUALITY__P5
  78. #undef FXAA_QUALITY__P6
  79. #undef FXAA_QUALITY__P7
  80. #undef FXAA_QUALITY__P8
  81. #undef FXAA_QUALITY__P9
  82. #undef FXAA_QUALITY__P10
  83. #undef FXAA_QUALITY__P11
  84. #define FXAA_QUALITY__PS 13
  85. #define FXAA_QUALITY__P0 1.0
  86. #define FXAA_QUALITY__P1 1.0
  87. #define FXAA_QUALITY__P2 1.0
  88. #define FXAA_QUALITY__P3 1.0
  89. #define FXAA_QUALITY__P4 1.0
  90. #define FXAA_QUALITY__P5 1.0
  91. #define FXAA_QUALITY__P6 1.0
  92. #define FXAA_QUALITY__P7 1.0
  93. #define FXAA_QUALITY__P8 1.0
  94. #define FXAA_QUALITY__P9 1.0
  95. #define FXAA_QUALITY__P10 1.0
  96. #define FXAA_QUALITY__P11 1.0
  97. #define FXAA_QUALITY__P12 1.0
  98. #endif
  99.  
  100. // Samplers
  101.  
  102. sampler FXAATexture
  103. {
  104. Texture = ReShade::BackBufferTex;
  105. MinFilter = Linear; MagFilter = Linear;
  106. #if FXAA_LINEAR_LIGHT
  107. SRGBTexture = true;
  108. #endif
  109. };
  110.  
  111. // Pixel shaders
  112.  
  113. #if !FXAA_GREEN_AS_LUMA
  114. float4 FXAALumaPass(float4 vpos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
  115. {
  116. float4 color = tex2D(ReShade::BackBuffer, texcoord.xy);
  117. color.a = sqrt(dot(color.rgb * color.rgb, float3(0.299, 0.587, 0.114)));
  118. return color;
  119. }
  120. #endif
  121.  
  122. float4 FXAAPixelShader(float4 vpos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
  123. {
  124. return FxaaPixelShader(
  125. texcoord, // pos
  126. 0, // fxaaConsolePosPos
  127. FXAATexture, // tex
  128. FXAATexture, // fxaaConsole360TexExpBiasNegOne
  129. FXAATexture, // fxaaConsole360TexExpBiasNegTwo
  130. BUFFER_PIXEL_SIZE, // fxaaQualityRcpFrame
  131. 0, // fxaaConsoleRcpFrameOpt
  132. 0, // fxaaConsoleRcpFrameOpt2
  133. 0, // fxaaConsole360RcpFrameOpt2
  134. Subpix, // fxaaQualitySubpix
  135. EdgeThreshold, // fxaaQualityEdgeThreshold
  136. EdgeThresholdMin, // fxaaQualityEdgeThresholdMin
  137. 0, // fxaaConsoleEdgeSharpness
  138. 0, // fxaaConsoleEdgeThreshold
  139. 0, // fxaaConsoleEdgeThresholdMin
  140. 0 // fxaaConsole360ConstDir
  141. );
  142. }
  143.  
  144. // Rendering passes
  145.  
  146. technique FXAA
  147. {
  148. #if !FXAA_GREEN_AS_LUMA
  149. pass
  150. {
  151. VertexShader = PostProcessVS;
  152. PixelShader = FXAALumaPass;
  153. }
  154. #endif
  155. pass
  156. {
  157. VertexShader = PostProcessVS;
  158. PixelShader = FXAAPixelShader;
  159. #if FXAA_LINEAR_LIGHT
  160. SRGBWriteEnable = true;
  161. #endif
  162. }
  163. }
  164.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement