forked from crosire/reshade-shaders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vibrance.fx
75 lines (57 loc) · 2.17 KB
/
Vibrance.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
/**
Vibrance
by Christian Cann Schuldt Jensen ~ CeeJay.dk
Vibrance intelligently boosts the saturation of pixels so pixels that had little color get a larger boost than pixels that had a lot.
This avoids oversaturation of pixels that were already very saturated.
History:
Version 1.0 by Ceejay.dk
- Original
Version 1.1 by CeeJay.dk
- Introduced RBG balance to help colorblind users
Version 1.1.1
- Minor UI improvements for Reshade 3.x
*/
#include "ReShadeUI.fxh"
uniform float Vibrance < __UNIFORM_SLIDER_FLOAT1
ui_min = -1.0; ui_max = 1.0;
ui_tooltip = "Intelligently saturates (or desaturates if you use negative values) the pixels depending on their original saturation.";
> = 0.15;
uniform float3 VibranceRGBBalance <
ui_type = "drag";
ui_min = 0.0; ui_max = 10.0;
ui_label = "RGB Balance";
ui_tooltip = "A per channel multiplier to the Vibrance strength so you can give more boost to certain colors over others.\nThis is handy if you are colorblind and less sensitive to a specific color.\nYou can then boost that color more than the others.";
> = float3(1.0, 1.0, 1.0);
/*
uniform int Vibrance_Luma <
ui_type = "combo";
ui_label = "Luma type";
ui_items = "Perceptual\0Even\0";
> = 0;
*/
#include "ReShade.fxh"
float3 VibrancePass(float4 position : SV_Position, float2 texcoord : TexCoord) : SV_Target
{
float3 color = tex2D(ReShade::BackBuffer, texcoord).rgb;
float3 coefLuma = float3(0.212656, 0.715158, 0.072186);
/*
if (Vibrance_Luma)
coefLuma = float3(0.333333, 0.333334, 0.333333);
*/
float luma = dot(coefLuma, color);
float max_color = max(color.r, max(color.g, color.b)); // Find the strongest color
float min_color = min(color.r, min(color.g, color.b)); // Find the weakest color
float color_saturation = max_color - min_color; // The difference between the two is the saturation
// Extrapolate between luma and original by 1 + (1-saturation) - current
float3 coeffVibrance = float3(VibranceRGBBalance * Vibrance);
color = lerp(luma, color, 1.0 + (coeffVibrance * (1.0 - (sign(coeffVibrance) * color_saturation))));
return color;
}
technique Vibrance
{
pass
{
VertexShader = PostProcessVS;
PixelShader = VibrancePass;
}
}