From patchwork Wed Jun 11 01:32:42 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: 23538 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 DE7F9C3325 for ; Wed, 11 Jun 2025 01:34:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6192568DFB; Wed, 11 Jun 2025 03:34:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Glk39CmF"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 57FDA68DFA for ; Wed, 11 Jun 2025 03:34:32 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-451d6ade159so52326435e9.1 for ; Tue, 10 Jun 2025 18:34:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605672; x=1750210472; 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=UpTmWd8hRPOTTl1Zn7CO833uoJq0hIJmPFpjlTRP34c=; b=Glk39CmFCNtZlxwuVdV8l8OZv3xcVMyNIgA1S19ioxyHj2YnvU3m2+Dtg5ALZTnK8A 6bmfN+QY/H9P44M+V40h16oZTbObV6YJ0e484Za7bJz6odQrVbYSDqPgsrFOBBV7B0He Uc1RphVnEDTRWLIcJoTrnNiy7FESL3YRafDGEcWCoRMJimP39u6EyKyXR4GnJJvD8ZuM 3jYcGOGw/jm1LzGGAJxcmFjBYIpEVyMuPaxtt/sjbU/Mohafv9OfGsMLcYCs66IonTkz eATlEA0NVNCQmyFLzV/SJp4rAcLEYbImECAegTLlGVTKclOyUbm/K6SW21YcWuXJBHLo KNCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605672; x=1750210472; 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=UpTmWd8hRPOTTl1Zn7CO833uoJq0hIJmPFpjlTRP34c=; b=PV43oDg1rN6sTOzekgLJj0uuRD8w2pIxzueSwl+l+x+LDtn/hCW2s7vg5IcwdQum7E rNaSiSOgam+bXSgM/NDVIuhMIxici83hgwsUNPlXWhRYpC+JwJxXbBHQQpTKZdPILeBk N2ZXdnWLMcisEJbuGcnTOP8NO3Edvz/TJOOghVeIf3zXF1d44wXdRvStVmYptFPFVrgp 4ynA2Gkc+nY6bngGtG55uqYiofXYEzAj6+cc6lyo4ZctOfI0vwhLRnDS1LuWz1c2hN9f 1UsnLCWLEqmkcjQ+BHHJ+z98PDt6ViGqu0swq98G6wc4Qpb20+B1Rt3aToBnBdSqPhLk baSg== X-Gm-Message-State: AOJu0YwbumClZEMNsJ2A/a8FB2VdkGNvr6gjiCNUkRoFIlCl8VNUmhk1 CAG2Hi7A4v/7aJbDlaFY8TxkuV60cZNMyn5L0QLynsrax6QVSB5JJJjAd1plV+Wg8dzjF+0zvRO CVwhI9cM= X-Gm-Gg: ASbGncsDJ8mbfNTe/kDbMj0YGvdkJ4ONclJ55Ux/9CVqWQSujCYCexiOaXrUhByzplH pgNoFwsr+tkqPkuH+/0ZBqUdi+BXA9m/vmBQXYs+fgs4Tis8WRHHklQ58wVQaljH6Enu1lKiADI sugHYz0lJ4nFadIAI88tTQhl87+J8tvHfympK519tb/HvGns3frzKZHFtsydwugvoYES3oO9Iw0 vWNx8HF2k0jl4uNQQf88XCbd9W7mrg4dkdVGmtfAOxNDoqLkf2YWKy/MpZsbvr4BCD2jnPj4SOv QbioY6BtMqZiI1pqZjwt0pZfM7Hq6Fi6U3GdorK5PRwtDXPm1k6YNIHpSQP+vND6x463XHAa6t2 ECjtK/dmqVK1FN1aWyPIThsLASq3L+WXOJgSREeFMLw== X-Google-Smtp-Source: AGHT+IF57xJsyb8PP2X+NVStRNReaAyK1c5hTIA0OotLoIoZ7SHYs6w4lvE3tRjzwA7v49IQ8AFoYA== X-Received: by 2002:a05:600c:5289:b0:442:f4a3:8c5c with SMTP id 5b1f17b1804b1-453248813e0mr11682935e9.10.1749605671625; Tue, 10 Jun 2025 18:34:31 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.34.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:34:30 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [PATCH 32/35] libcamera: shaders: Fix neighbouring positions in 8-bit debayering Date: Wed, 11 Jun 2025 02:32:42 +0100 Message-ID: <20250611013245.133785-33-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-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 --- include/libcamera/internal/shaders/bayer_8.vert | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/libcamera/internal/shaders/bayer_8.vert b/include/libcamera/internal/shaders/bayer_8.vert index fb5109ee..fc1cf89f 100644 --- a/include/libcamera/internal/shaders/bayer_8.vert +++ b/include/libcamera/internal/shaders/bayer_8.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; }