mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2025-02-23 18:17:44 +11:00
add CMYK conversion matrices to colorspace-tools
This commit is contained in:
parent
47e7583af8
commit
a414020804
1 changed files with 32 additions and 9 deletions
|
@ -134,6 +134,29 @@ vec3 XYZtoYxy(vec3 XYZ)
|
||||||
return 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
|
// Converting pure hue to RGB
|
||||||
vec3 HUEtoRGB(float H)
|
vec3 HUEtoRGB(float H)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue