From patchwork Wed Oct 15 01:22:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24676 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 A0609BF415 for ; Wed, 15 Oct 2025 01:23:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0F7156067F; Wed, 15 Oct 2025 03:23:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="NagJ5X/M"; dkim-atps=neutral Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DDAFF60648 for ; Wed, 15 Oct 2025 03:23:26 +0200 (CEST) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-b403bb7843eso1253493166b.3 for ; Tue, 14 Oct 2025 18:23:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491406; x=1761096206; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3pLj5P6YPZYgBGgXFC8NMxiBkk93rrF9W+BqVEKVjMU=; b=NagJ5X/MG0kR8fwnmhFSZ/ha5G15EHSKDvZZYG1PcdBnwPiaGFBf1mxgx8pXccuGQ+ raw1aRRwTi4xbWUFkw1SAqk8y2kssj1sfhz/YZvvmUnpvLco8PRBXi9AMyzXyYvIxLwr WnUIjIP+XFsctGOfqOC17LspzJ9RuleiWXPjcd9Klfpmc5lKc0BeYbUSPAVtsoDzF6Zj W1j37FaGMnaCOdhEcESmzCD9/E0Mbu9FswTShWUnjmsJBobAYLg6r9ikWtvw7yT948ih kg/oNdA61lH1kstcfYF2xUPc1fIWq3eU258tdq1jwaRV39gj/suk4Davb3dEFO9XtUz1 7loA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491406; x=1761096206; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3pLj5P6YPZYgBGgXFC8NMxiBkk93rrF9W+BqVEKVjMU=; b=OwOO+/eYGiLpvlLTkucPVJXSlL+8je0xzjB0Xv1Ii5XJIH4mD7JXgq9wjapKtplQl0 8CTWz9q0MhbbHdhMCGfm5BJKQp4KlmPzC3jwEW7xctpgs0AUvQ76ssZsJa/9cOwMZg5S t5j4jxqn8Mqcd1IagfQ8S0SZRiKTWfbCO0vAXXaHyW3rzgQEAHYF2e84DIZQv2NcN/Pk KFxzgnIjUFNHG+mEQPRVbo9z+fOIXQuMcGZ6zc666+J6QXiy8Bramc6i99J9stR7GGCq Qnr2lb0DZlsd3VlhjHZwkDisno3BWMATcdcXjgUIWmfAEXpvRfekZfF5J+NsFZLFRw+w 7ZbQ== X-Gm-Message-State: AOJu0YzdHq3KbkLDmSakwFD25c/bnAUCbn4hOwlQObMyCwH5V6s3L2/s 730rOQJnWPVphhM4PIUaXs5Ht0CayYVVsnhBSHaIec8dZ84NMqvMT/7x+l3TqeqN6UwAn1PzBW/ y0ssn X-Gm-Gg: ASbGncujXLIrjhMkSVpNSU1gOTKBd9eezmMvrhi7ro1o5cOOLbmwqkFDrl/WTTDbA8z /9oaQnlJZl2YUnn2RZ3l53JcHpSuwBqB5CUSezEULUERHNGFdpqONSzy6Y/3X+UXAo+HgfEx7hA qbjdMwxQyQtBMVz31O+M9SI2Ev3wtEDBBWDv9gKC6tEfFmo6z32QW702hDw5+tiPQ3ohLqfDlqN jzmyr+XB4qhKoZQz9khpnQzWv1Iu4MSNO2o+nW+mGZEDa38Xc5tvxV3hDkpIuSqT/LwYnpLDtdh 3tgAEEbaGzFwcGV+js97pDbEn0DDAwCFcnDzuPZBmBzpdrAvE8wBzwg7CmruvaW3xtLpQ31Gl+m bDvoMAkBPmjDoVLXKzyt9fzBxLMh0G1pqJ1LHCsXZ0Froi/vISs0eE++kPelKALz9/raKDctXJr GR3Ob67S0aF1A85TZ2ZLrM3gFZNjEAl6hMVnGwtSAQ X-Google-Smtp-Source: AGHT+IFifMKAX2rD3sBzL7INia4PQrpoG4UoWxv/0uLFcpQHI3ea7BAml0xfEZUJkhOQJH6cGBDZ8A== X-Received: by 2002:a17:907:1c0f:b0:b4b:dd7e:65f2 with SMTP id a640c23a62f3a-b50aa48d34fmr2549706366b.5.1760491406039; Tue, 14 Oct 2025 18:23:26 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:25 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 31/39] libcamera: shaders: Fix neighbouring positions in 8-bit debayering Date: Wed, 15 Oct 2025 02:22:43 +0100 Message-ID: <20251015012251.17508-32-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 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: Milan Zamazal When accessing a texture position in a shader, the pixel with the nearest centre to the specified texture coordinates (as mandated by specifying GL_NEAREST parameter) is taken. The current vertex shader determines the positions of the neighbouring pixels by adding the provided texture steps to the exact centre pixel coordinates. But this places the computed coordinates, from the point of view of GL_NEAREST, exactly between the pixels and is thus prone to floating point inaccuracies. Wrong neighbouring pixel coordinates may be used, resulting in artefacts in the output image. Let's fix the problem by shifting the initial coordinates a bit from the pixel border. Signed-off-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/shaders/bayer_unpacked.vert | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/libcamera/internal/shaders/bayer_unpacked.vert b/include/libcamera/internal/shaders/bayer_unpacked.vert index fb5109ee..fc1cf89f 100644 --- a/include/libcamera/internal/shaders/bayer_unpacked.vert +++ b/include/libcamera/internal/shaders/bayer_unpacked.vert @@ -44,10 +44,10 @@ void main(void) { center.xy = textureIn; center.zw = textureIn * tex_size + tex_bayer_first_red; - xCoord = center.x + vec4(-2.0 * tex_step.x, - -tex_step.x, tex_step.x, 2.0 * tex_step.x); - yCoord = center.y + vec4(-2.0 * tex_step.y, - -tex_step.y, tex_step.y, 2.0 * tex_step.y); + xCoord = center.x + 0.1 * tex_step.x + + vec4(-2.0 * tex_step.x, -tex_step.x, tex_step.x, 2.0 * tex_step.x); + yCoord = center.y + 0.1 * tex_step.y + + vec4(-2.0 * tex_step.y, -tex_step.y, tex_step.y, 2.0 * tex_step.y); gl_Position = proj_matrix * vertexIn; }