[v6,08/24] libcamera: shaders: Add support for black level compensation
diff mbox series

Message ID 20251202134544.662446-9-bryan.odonoghue@linaro.org
State New
Headers show
Series
  • Add GLES 2.0 GPUISP to libcamera
Related show

Commit Message

Bryan O'Donoghue Dec. 2, 2025, 1:45 p.m. UTC
Add the ability to apply a int blacklevel gain against the demosaiced data
prior to application of colour correction data.

We calculate the index into the RGB black-level table so that we can apply
the black level when we sample the input prior to the demosiac operation.

Don't do this when using the lookup tables as the black level is
already calculated in those.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 src/libcamera/shaders/bayer_1x_packed.frag | 3 +++
 src/libcamera/shaders/bayer_unpacked.frag  | 3 +++
 2 files changed, 6 insertions(+)

Patch
diff mbox series

diff --git a/src/libcamera/shaders/bayer_1x_packed.frag b/src/libcamera/shaders/bayer_1x_packed.frag
index db8c2a0b3..7036fe278 100644
--- a/src/libcamera/shaders/bayer_1x_packed.frag
+++ b/src/libcamera/shaders/bayer_1x_packed.frag
@@ -66,6 +66,7 @@  uniform vec2 tex_bayer_first_red;
 
 uniform sampler2D tex_y;
 uniform mat3 ccm;
+uniform vec3 blacklevel;
 
 void main(void)
 {
@@ -213,6 +214,8 @@  void main(void)
 			vec3(patterns.y, C, patterns.x) :
 			vec3(patterns.wz, C));
 
+	rgb = rgb - blacklevel;
+
 	/*
 	 *   CCM is a 3x3 in the format
 	 *
diff --git a/src/libcamera/shaders/bayer_unpacked.frag b/src/libcamera/shaders/bayer_unpacked.frag
index 06d80f3dd..f0d8cd1e2 100644
--- a/src/libcamera/shaders/bayer_unpacked.frag
+++ b/src/libcamera/shaders/bayer_unpacked.frag
@@ -25,6 +25,7 @@  varying vec4            center;
 varying vec4            yCoord;
 varying vec4            xCoord;
 uniform mat3            ccm;
+uniform vec3            blacklevel;
 
 void main(void) {
     vec3 rgb;
@@ -108,6 +109,8 @@  void main(void) {
             vec3(PATTERN.w, C, PATTERN.z) :
             vec3(PATTERN.yx, C));
 
+    rgb = rgb - blacklevel;
+
     /*
      *   CCM is a 3x3 in the format
      *