forked from crosire/reshade-shaders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FXAA.fx
123 lines (106 loc) · 3.12 KB
/
FXAA.fx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
* FXAA 3.11
*
* for ReShade 3.0
*/
uniform float Subpix <
ui_type = "drag";
ui_min = 0.0; ui_max = 1.0;
ui_tooltip = "Amount of sub-pixel aliasing removal. Higher values makes the image softer/blurrier.";
> = 0.25;
uniform float EdgeThreshold <
ui_type = "drag";
ui_min = 0.0; ui_max = 1.0;
ui_label = "Edge Detection Threshold";
ui_tooltip = "The minimum amount of local contrast required to apply algorithm.";
> = 0.125;
uniform float EdgeThresholdMin <
ui_type = "drag";
ui_min = 0.0; ui_max = 1.0;
ui_label = "Darkness Threshold";
ui_tooltip = "Pixels darker than this are not processed in order to increase performance.";
> = 0.0;
//------------------------------ Non-GUI-settings -------------------------------------------------
#ifndef FXAA_QUALITY__PRESET
// Valid Quality Presets
// 10 to 15 - default medium dither (10=fastest, 15=highest quality)
// 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)
// 39 - no dither, very expensive
#define FXAA_QUALITY__PRESET 15
#endif
#ifndef FXAA_GREEN_AS_LUMA
#define FXAA_GREEN_AS_LUMA 0
#endif
#ifndef FXAA_LINEAR_LIGHT
#define FXAA_LINEAR_LIGHT 1
#endif
//-------------------------------------------------------------------------------------------------
#if (__RENDERER__ == 0xb000 || __RENDERER__ == 0xb100)
#define FXAA_GATHER4_ALPHA 1
#define FxaaTexAlpha4(t, p) tex2Dgather(t, p, 3)
#define FxaaTexOffAlpha4(t, p, o) tex2Dgatheroffset(t, p, o, 3)
#define FxaaTexGreen4(t, p) tex2Dgather(t, p, 1)
#define FxaaTexOffGreen4(t, p, o) tex2Dgatheroffset(t, p, o, 1)
#endif
#define FXAA_PC 1
#define FXAA_HLSL_3 1
#include "FXAA.fxh"
#include "ReShade.fxh"
// Samplers
sampler FXAATexture
{
Texture = ReShade::BackBufferTex;
MinFilter = Linear; MagFilter = Linear;
#if FXAA_LINEAR_LIGHT
SRGBTexture = true;
#endif
};
// Pixel shaders
#if !FXAA_GREEN_AS_LUMA
float4 FXAALumaPass(float4 vpos : SV_Position, noperspective float2 texcoord : TEXCOORD) : SV_Target
{
float4 color = tex2D(ReShade::BackBuffer, texcoord.xy);
color.a = sqrt(dot(color.rgb * color.rgb, float3(0.299, 0.587, 0.114)));
return color;
}
#endif
float4 FXAAPixelShader(float4 vpos : SV_Position, noperspective float2 texcoord : TEXCOORD) : SV_Target
{
return FxaaPixelShader(
texcoord, // pos
0, // fxaaConsolePosPos
FXAATexture, // tex
FXAATexture, // fxaaConsole360TexExpBiasNegOne
FXAATexture, // fxaaConsole360TexExpBiasNegTwo
ReShade::PixelSize, // fxaaQualityRcpFrame
0, // fxaaConsoleRcpFrameOpt
0, // fxaaConsoleRcpFrameOpt2
0, // fxaaConsole360RcpFrameOpt2
Subpix, // fxaaQualitySubpix
EdgeThreshold, // fxaaQualityEdgeThreshold
EdgeThresholdMin, // fxaaQualityEdgeThresholdMin
0, // fxaaConsoleEdgeSharpness
0, // fxaaConsoleEdgeThreshold
0, // fxaaConsoleEdgeThresholdMin
0 // fxaaConsole360ConstDir
);
}
// Rendering passes
technique FXAA
{
#if !FXAA_GREEN_AS_LUMA
pass
{
VertexShader = PostProcessVS;
PixelShader = FXAALumaPass;
}
#endif
pass
{
VertexShader = PostProcessVS;
PixelShader = FXAAPixelShader;
#if FXAA_LINEAR_LIGHT
SRGBWriteEnable = true;
#endif
}
}