-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a81916
commit 3a37bcf
Showing
3 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
[configuration] | ||
[OptionRangeFloat] | ||
GUIName = Desaturation | ||
OptionName = DESATURATION | ||
MinValue = 0.0 | ||
MaxValue = 1.0 | ||
StepAmount = 0.1 | ||
DefaultValue = 0.0 | ||
[/configuration] | ||
*/ | ||
|
||
/***** Linear <--> Oklab *****/ | ||
|
||
const mat4 RGBtoLMS = mat4( | ||
0.4122214708, 0.2119034982, 0.0883024619, 0.0000000000, | ||
0.5363325363, 0.6806995451, 0.2817188376, 0.0000000000, | ||
0.0514459929, 0.1073969566, 0.6299787005, 0.0000000000, | ||
0.0000000000, 0.0000000000, 0.0000000000, 1.0000000000); | ||
|
||
const mat4 LMStoOklab = mat4( | ||
0.2104542553, 1.9779984951, 0.0259040371, 0.0000000000, | ||
0.7936177850, -2.4285922050, 0.7827717662, 0.0000000000, | ||
-0.0040720468, 0.4505937099, -0.8086757660, 0.0000000000, | ||
0.0000000000, 0.0000000000, 0.0000000000, 1.0000000000); | ||
|
||
float4 LinearRGBToOklab(float4 c) | ||
{ | ||
return LMStoOklab * pow(RGBtoLMS * c, float4(1.0 / 3.0)); | ||
} | ||
|
||
const mat4 OklabtoLMS = mat4( | ||
1.0000000000, 1.0000000000, 1.0000000000, 0.0000000000, | ||
0.3963377774, -0.1055613458, -0.0894841775, 0.0000000000, | ||
0.2158037573, -0.0638541728, -1.2914855480, 0.0000000000, | ||
0.0000000000, 0.0000000000, 0.0000000000, 1.0000000000); | ||
|
||
const mat4 LMStoRGB = mat4( | ||
4.0767416621, -1.2684380046, -0.0041960863, 0.0000000000, | ||
-3.3077115913, 2.6097574011, -0.7034186147, 0.0000000000, | ||
0.2309699292, -0.3413193965, 1.7076147010, 0.0000000000, | ||
0.0000000000, 0.0000000000, 0.0000000000, 1.0000000000); | ||
|
||
float4 OklabToLinearRGB(float4 c) | ||
{ | ||
return max(LMStoRGB * pow(OklabtoLMS * c, float4(3.0)), 0.0); | ||
} | ||
|
||
void main() | ||
{ | ||
float4 color = Sample(); | ||
|
||
// Nothing to do here, we are in SDR | ||
if (!OptionEnabled(hdr_output) || !OptionEnabled(linear_space_output)) { | ||
SetOutput(color); | ||
return; | ||
} | ||
|
||
const float hdr_paper_white = hdr_paper_white_nits / hdr_sdr_white_nits; | ||
color.rgb /= hdr_paper_white; | ||
|
||
float4 oklab_color = LinearRGBToOklab(color); | ||
|
||
float lum = oklab_color.x; | ||
oklab_color.z *= pow(hdr_paper_white, pow(oklab_color.x, DESATURATION) / 3.0); | ||
oklab_color.y *= pow(hdr_paper_white, pow(oklab_color.x, DESATURATION) / 3.0); | ||
oklab_color.x *= pow(hdr_paper_white, pow(oklab_color.x, 1.0) / 3.0); | ||
|
||
SetOutput(OklabToLinearRGB(oklab_color)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters