summaryrefslogtreecommitdiffstats
path: root/src/multimedia/shaders/colorconvert.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'src/multimedia/shaders/colorconvert.glsl')
-rw-r--r--src/multimedia/shaders/colorconvert.glsl19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/multimedia/shaders/colorconvert.glsl b/src/multimedia/shaders/colorconvert.glsl
new file mode 100644
index 000000000..f28a0902e
--- /dev/null
+++ b/src/multimedia/shaders/colorconvert.glsl
@@ -0,0 +1,19 @@
+#ifndef COLORCONVERT
+#define COLORCONVERT
+
+// Convert the Rec2020 RGB colorspace to sRGB using:
+// https://www.itu.int/dms_pub/itu-r/opb/rep/R-REP-BT.2407-2017-PDF-E.pdf
+// We can use the simple matrix defined there for a conversion between BT2020
+// and sRGB. Conversion has to be done in linear color space.
+vec4 convertRec2020ToSRGB(vec4 rgba)
+{
+ const mat4 mat =
+ mat4(1.6605f, -0.5876f, -0.0728f, 0.0000f,
+ -0.1246f, 1.1329f, -0.0083f, 0.0000f,
+ -0.0182f, -0.1006f, 1.1187f, 0.0000f,
+ 0.0000f, 0.0000f, 0.0000f, 1.0000f);
+
+ return rgba * mat;
+}
+
+#endif