forked from crosire/reshade-shaders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vignette.fx
115 lines (96 loc) · 3.45 KB
/
Vignette.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
/**
* Vignette version 1.3
* by Christian Cann Schuldt Jensen ~ CeeJay.dk
*
* Darkens the edges of the image to make it look more like it was shot with a camera lens.
* May cause banding artifacts.
*/
#include "ReShadeUI.fxh"
uniform int Type <
ui_type = "combo";
ui_items = "Original\0New\0TV style\0Untitled 1\0Untitled 2\0Untitled 3\0Untitled 4\0";
> = 0;
uniform float Ratio < __UNIFORM_SLIDER_FLOAT1
ui_min = 0.15; ui_max = 6.0;
ui_tooltip = "Sets a width to height ratio. 1.00 (1/1) is perfectly round, while 1.60 (16/10) is 60 % wider than it's high.";
> = 1.0;
uniform float Radius < __UNIFORM_SLIDER_FLOAT1
ui_min = -1.0; ui_max = 3.0;
ui_tooltip = "lower values = stronger radial effect from center";
> = 2.0;
uniform float Amount < __UNIFORM_SLIDER_FLOAT1
ui_min = -2.0; ui_max = 1.0;
ui_tooltip = "Strength of black. -2.00 = Max Black, 1.00 = Max White.";
> = -1.0;
uniform int Slope < __UNIFORM_SLIDER_INT1
ui_min = 2; ui_max = 16;
ui_tooltip = "How far away from the center the change should start to really grow strong (odd numbers cause a larger fps drop than even numbers).";
> = 2;
uniform float2 Center < __UNIFORM_SLIDER_FLOAT2
ui_min = 0.0; ui_max = 1.0;
ui_tooltip = "Center of effect for 'Original' vignette type. 'New' and 'TV style' do not obey this setting.";
> = float2(0.5, 0.5);
#include "ReShade.fxh"
float4 VignettePass(float4 vpos : SV_Position, float2 tex : TexCoord) : SV_Target
{
float4 color = tex2D(ReShade::BackBuffer, tex);
if (Type == 0)
{
// Set the center
float2 distance_xy = tex - Center;
// Adjust the ratio
distance_xy *= float2((ReShade::PixelSize.y / ReShade::PixelSize.x), Ratio);
// Calculate the distance
distance_xy /= Radius;
float distance = dot(distance_xy, distance_xy);
// Apply the vignette
color.rgb *= (1.0 + pow(distance, Slope * 0.5) * Amount); //pow - multiply
}
if (Type == 1) // New round (-x*x+x) + (-y*y+y) method.
{
tex = -tex * tex + tex;
color.rgb = saturate(((ReShade::PixelSize.y / ReShade::PixelSize.x)*(ReShade::PixelSize.y / ReShade::PixelSize.x) * Ratio * tex.x + tex.y) * 4.0) * color.rgb;
}
if (Type == 2) // New (-x*x+x) * (-y*y+y) TV style method.
{
tex = -tex * tex + tex;
color.rgb = saturate(tex.x * tex.y * 100.0) * color.rgb;
}
if (Type == 3)
{
tex = abs(tex - 0.5);
float tc = dot(float4(-tex.x, -tex.x, tex.x, tex.y), float4(tex.y, tex.y, 1.0, 1.0)); //XOR
tc = saturate(tc - 0.495);
color.rgb *= (pow((1.0 - tc * 200), 4) + 0.25); //or maybe abs(tc*100-1) (-(tc*100)-1)
}
if (Type == 4)
{
tex = abs(tex - 0.5);
float tc = dot(float4(-tex.x, -tex.x, tex.x, tex.y), float4(tex.y, tex.y, 1.0, 1.0)); //XOR
tc = saturate(tc - 0.495) - 0.0002;
color.rgb *= (pow((1.0 - tc * 200), 4) + 0.0); //or maybe abs(tc*100-1) (-(tc*100)-1)
}
if (Type == 5) // MAD version of 2
{
tex = abs(tex - 0.5);
float tc = tex.x * (-2.0 * tex.y + 1.0) + tex.y; //XOR
tc = saturate(tc - 0.495);
color.rgb *= (pow((-tc * 200 + 1.0), 4) + 0.25); //or maybe abs(tc*100-1) (-(tc*100)-1)
//color.rgb *= (pow(((tc*200.0)-1.0),4)); //or maybe abs(tc*100-1) (-(tc*100)-1)
}
if (Type == 6) // New round (-x*x+x) * (-y*y+y) method.
{
//tex.y /= float2((ReShade::PixelSize.y / ReShade::PixelSize.x), Ratio);
float tex_xy = dot(float4(tex, tex), float4(-tex, 1.0, 1.0)); //dot is actually slower
color.rgb = saturate(tex_xy * 4.0) * color.rgb;
}
return color;
}
technique Vignette
{
pass
{
VertexShader = PostProcessVS;
PixelShader = VignettePass;
}
}