This repository has been archived by the owner on Feb 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathPS_Vibrance.hlsl
54 lines (39 loc) · 1.7 KB
/
PS_Vibrance.hlsl
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
sampler s0 : register(s0);
float4 p0 : register(c0);
float4 p1 : register(c1);
#define width (p0[0])
#define height (p0[1])
#define counter (p0[2])
#define clock (p0[3])
#define one_over_width (p1[0])
#define one_over_height (p1[1])
#define PI acos(-1)
float4 main(float2 tex : TEXCOORD0) : COLOR {
float4 source = tex2D(s0, tex);
double4 result;
result.r = (float)source.r;
result.g =(float)source.g;
result.b = (float)source.b;
result.a = (float)1.0;
double saturationRate =20.0;
double luminance = (source.r + source.g + source.b)/3.0;
double currentSaturation = ((abs(result.r-luminance) + abs(result.g-luminance) + abs(result.b-luminance))/3.0) * (1.0-luminance);
double currentSaturationCompensation = (1.0 - currentSaturation)/10.0;
double4 moreVibrant = result;
double4 lessVibrant = result;
double4 moreSaturated = result;
moreVibrant.r += (result.r-luminance) * saturationRate * currentSaturation;
moreVibrant.g += (result.g-luminance) * saturationRate * currentSaturation;
moreVibrant.b += (result.b-luminance) * saturationRate * currentSaturation;
lessVibrant.r += (result.r-luminance) * saturationRate * currentSaturationCompensation;
lessVibrant.g += (result.g-luminance) * saturationRate * currentSaturationCompensation;
lessVibrant.b += (result.b-luminance) * saturationRate * currentSaturationCompensation;
moreSaturated.r += (result.r-luminance) * saturationRate * luminance;
moreSaturated.g += (result.g-luminance) * saturationRate * luminance;
moreSaturated.b += (result.b-luminance) * saturationRate * luminance;
// result = lessVibrant;
// result = moreSaturated;
result = moreVibrant;
// result = source;
return result;
}