summaryrefslogtreecommitdiff
path: root/luma.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'luma.glsl')
-rw-r--r--luma.glsl27
1 files changed, 21 insertions, 6 deletions
diff --git a/luma.glsl b/luma.glsl
index 4dac957..160734f 100644
--- a/luma.glsl
+++ b/luma.glsl
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 Mikhail Burakov. This file is part of streamer.
+ * Copyright (C) 2024 Mikhail Burakov. This file is part of streamer.
*
* streamer is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,14 +16,29 @@
*/
uniform sampler2D img_input;
-uniform mediump mat3 colorspace;
-uniform mediump vec3 ranges[2];
-
varying mediump vec2 texcoord;
+const mediump mat3 kColorSpace = mat3(
+ 0.299, 0.587, 0.114,
+ -0.168736, -0.331264, 0.5,
+ 0.5, -0.418688, -0.081312
+);
+
+const mediump vec3 kColorRangeBase = vec3(
+ 16.0 / 255.0,
+ 16.0 / 255.0,
+ 16.0 / 255.0
+);
+
+const mediump vec3 kColorRangeScale = vec3(
+ (235.0 - 16.0) / 255.0,
+ (240.0 - 16.0) / 255.0,
+ (240.0 - 16.0) / 255.0
+);
+
mediump vec3 rgb2yuv(in mediump vec3 rgb) {
- mediump vec3 yuv = colorspace * rgb.rgb + vec3(0.0, 0.5, 0.5);
- return ranges[0] + yuv * ranges[1];
+ mediump vec3 yuv = kColorSpace * rgb.rgb + vec3(0.0, 0.5, 0.5);
+ return kColorRangeBase + yuv * kColorRangeScale;
}
void main() {