mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-23 00:01:31 +11:00
add CMYK conversion matrices to colorspace-tools
This commit is contained in:
parent
47e7583af8
commit
a414020804
|
@ -134,6 +134,29 @@ vec3 XYZtoYxy(vec3 XYZ)
|
|||
return XYZ;
|
||||
}
|
||||
|
||||
// RGB <-> CMYK conversions require 4 channels
|
||||
vec4 RGBtoCMYK(vec3 RGB){
|
||||
float Red = RGB.r;
|
||||
float Green = RGB.g;
|
||||
float Blue = RGB.b;
|
||||
float Black = min(1.0 - Red, min(1.0 - Green, 1.0 - Blue));
|
||||
float Cyan = (1.0 - Red - Black) / (1.0 - Black);
|
||||
float Magenta = (1.0 - Green - Black) / (1.0 - Black);
|
||||
float Yellow = (1.0 - Blue - Black) / (1.0 - Black);
|
||||
return vec4(Cyan, Magenta, Yellow, Black);
|
||||
}
|
||||
|
||||
vec3 CMYKtoRGB(vec4 CMYK){
|
||||
float Cyan = CMYK.x;
|
||||
float Magenta = CMYK.y;
|
||||
float Yellow = CMYK.z;
|
||||
float Black = CMYK.w;
|
||||
float Red = 1.0 - min(1.0, Cyan * (1.0 - Black) + Black);
|
||||
float Green = 1.0 - min(1.0, Magenta * (1.0 - Black) + Black);
|
||||
float Blue = 1.0 - min(1.0, Yellow * (1.0 - Black) + Black);
|
||||
return vec3(Red, Green, Blue);
|
||||
}
|
||||
|
||||
// Converting pure hue to RGB
|
||||
vec3 HUEtoRGB(float H)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue