forked from crosire/reshade-shaders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMonochrome.fx
131 lines (108 loc) · 3.11 KB
/
Monochrome.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
124
125
126
127
128
129
130
131
/*------------------.
| :: Description :: |
'-------------------/
Monochrome (version 1.1)
Author: CeeJay.dk
License: MIT
About:
Removes color making everything monochrome.
Ideas for future improvement:
* Tinting
* Select a hue to keep its color, thus making it stand out against a monochrome background
* Try Lab colorspace
* Apply color gradient
* Add an option to normalize the coefficients
* Publish best-selling book titled "256 shades of grey"
History:
(*) Feature (+) Improvement (x) Bugfix (-) Information (!) Compatibility
Version 1.0
* Converts image to monochrome
* Allows users to add saturation back in.
Version 1.1
* Added many presets based on B/W camera films
+ Improved settings UI
! Made settings backwards compatible with SweetFX
*/
/*---------------.
| :: Includes :: |
'---------------*/
#include "ReShade.fxh"
#include "ReShadeUI.fxh"
uniform int Monochrome_preset <
ui_type = "combo";
ui_label = "Preset";
ui_tooltip = "Choose a preset";
//ui_category = "";
ui_items = "Custom\0"
"Monitor or modern TV\0"
"Equal weight\0"
"Agfa 200X\0"
"Agfapan 25\0"
"Agfapan 100\0"
"Agfapan 400\0"
"Ilford Delta 100\0"
"Ilford Delta 400\0"
"Ilford Delta 400 Pro & 3200\0"
"Ilford FP4\0"
"Ilford HP5\0"
"Ilford Pan F\0"
"Ilford SFX\0"
"Ilford XP2 Super\0"
"Kodak Tmax 100\0"
"Kodak Tmax 400\0"
"Kodak Tri-X\0";
> = 0;
uniform float3 Monochrome_conversion_values < __UNIFORM_COLOR_FLOAT3
ui_label = "Custom Conversion values";
> = float3(0.21, 0.72, 0.07);
/*
uniform bool Normalize <
ui_label = "Normalize";
ui_tooltip = "Normalize the coefficients?";
> = false;
*/
uniform float Monochrome_color_saturation < __UNIFORM_SLIDER_FLOAT1
ui_label = "Saturation";
ui_min = 0.0; ui_max = 1.0;
> = 0.0;
float3 MonochromePass(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target
{
float3 color = tex2D(ReShade::BackBuffer, texcoord).rgb;
float3 Coefficients = float3(0.21, 0.72, 0.07);
float3 Coefficients_array[18] =
{
Monochrome_conversion_values, //Custom
float3(0.21, 0.72, 0.07), //sRGB monitor
float3(0.3333333, 0.3333334, 0.3333333), //Equal weight
float3(0.18, 0.41, 0.41), //Agfa 200X
float3(0.25, 0.39, 0.36), //Agfapan 25
float3(0.21, 0.40, 0.39), //Agfapan 100
float3(0.20, 0.41, 0.39), //Agfapan 400
float3(0.21, 0.42, 0.37), //Ilford Delta 100
float3(0.22, 0.42, 0.36), //Ilford Delta 400
float3(0.31, 0.36, 0.33), //Ilford Delta 400 Pro & 3200
float3(0.28, 0.41, 0.31), //Ilford FP4
float3(0.23, 0.37, 0.40), //Ilford HP5
float3(0.33, 0.36, 0.31), //Ilford Pan F
float3(0.36, 0.31, 0.33), //Ilford SFX
float3(0.21, 0.42, 0.37), //Ilford XP2 Super
float3(0.24, 0.37, 0.39), //Kodak Tmax 100
float3(0.27, 0.36, 0.37), //Kodak Tmax 400
float3(0.25, 0.35, 0.40) //Kodak Tri-X
};
Coefficients = Coefficients_array[Monochrome_preset];
// Calculate monochrome
float3 grey = dot(Coefficients, color);
// Adjust the remaining saturation
color = lerp(grey, color, Monochrome_color_saturation);
// Return the result
return saturate(color);
}
technique Monochrome
{
pass
{
VertexShader = PostProcessVS;
PixelShader = MonochromePass;
}
}