From patchwork Tue May 12 12:36:09 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 26728 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 381AEBDB1C for ; Tue, 12 May 2026 12:36:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CCA5463033; Tue, 12 May 2026 14:36:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="e071FrAB"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ED99A63024 for ; Tue, 12 May 2026 14:36:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778589411; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZejWO7eq6zPZKHw9LKkh1s6lR/zsy+h8NR3S8NCIeYg=; b=e071FrABe89jN+g88H3cg0Wz0uhim1GBnZUgjA9/3DENrSTtqeezZuvSx9cWPwJr3UBOUf DTVwhdYRbhPoR/T0YmXcKjbSZt8hE5MyBi/hYSUDTYNo93iHze/k1WlMqalaJdQhL7kTEZ WcLVKPfQRpMVP3ylrlpnT8UpAakgGlk= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-172-fZL0MPDVOYqT1exp0QgSzQ-1; Tue, 12 May 2026 08:36:48 -0400 X-MC-Unique: fZL0MPDVOYqT1exp0QgSzQ-1 X-Mimecast-MFC-AGG-ID: fZL0MPDVOYqT1exp0QgSzQ_1778589406 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9885D18002C9; Tue, 12 May 2026 12:36:46 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.50.44]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 00A841955D84; Tue, 12 May 2026 12:36:43 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Xander Pronk , Bryan O'Donoghue , Hans de Goede , Laurent Pinchart , Rick ten Wolde , Milan Zamazal Subject: [RFC PATCH v5 05/10] libcamera: shaders: Add LSC support Date: Tue, 12 May 2026 14:36:09 +0200 Message-ID: <20260512123619.120068-6-mzamazal@redhat.com> In-Reply-To: <20260512123619.120068-1-mzamazal@redhat.com> References: <20260512123619.120068-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: MIlTQK2VPiw-BezY40tOJ8sHnqexAbW4_yFXqyP7vTI_1778589406 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Xander Pronk Lens shading correction should be applied after black level subtraction (in order to make the computations with meaningful values) and before white balance (especially before white balance stats are computed). Note that lens shading correction depends on temperature, which is computed from the preceding, rather than current, frame (this is due to how white balance is currently computed). The grid is specified in the YAML definition as follows: - Lsc: sets: - ct: temperature-1 r: [ ... 16 x 16 float values ...] g: [ ... 16 x 16 float values ...] b: [ ... 16 x 16 float values ...] - ct: temperature-2 r: [ ... 16 x 16 float values ...] g: [ ... 16 x 16 float values ...] b: [ ... 16 x 16 float values ...] - ... Reviewed-by: Laurent Pinchart Co-developed-by: Rick ten Wolde Signed-off-by: Rick ten Wolde Signed-off-by: Xander Pronk Signed-off-by: Milan Zamazal --- src/libcamera/shaders/bayer_1x_packed.frag | 8 ++++++++ src/libcamera/shaders/bayer_unpacked.frag | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/libcamera/shaders/bayer_1x_packed.frag b/src/libcamera/shaders/bayer_1x_packed.frag index 23747f78a..228c72309 100644 --- a/src/libcamera/shaders/bayer_1x_packed.frag +++ b/src/libcamera/shaders/bayer_1x_packed.frag @@ -70,6 +70,10 @@ uniform vec3 blacklevel; uniform float gamma; uniform float contrastExp; +#if defined(APPLY_LSC) +uniform sampler2D lsc_tex; +#endif + float apply_contrast(float value) { // Apply simple S-curve @@ -227,6 +231,10 @@ void main(void) rgb = rgb - blacklevel; +#if defined(APPLY_LSC) + rgb = rgb * texture2D(lsc_tex, textureOut).rgb; +#endif + /* * CCM is a 3x3 in the format * diff --git a/src/libcamera/shaders/bayer_unpacked.frag b/src/libcamera/shaders/bayer_unpacked.frag index 1b85196ae..af87bcc0f 100644 --- a/src/libcamera/shaders/bayer_unpacked.frag +++ b/src/libcamera/shaders/bayer_unpacked.frag @@ -29,6 +29,10 @@ uniform vec3 blacklevel; uniform float gamma; uniform float contrastExp; +#if defined(APPLY_LSC) +uniform sampler2D lsc_tex; +#endif + float apply_contrast(float value) { // Apply simple S-curve @@ -130,6 +134,10 @@ void main(void) { rgb = rgb - blacklevel; +#if defined(APPLY_LSC) + rgb = rgb * texture2D(lsc_tex, center.xy).rgb; +#endif + /* * CCM is a 3x3 in the format *