diff --git a/include/libcamera/internal/shaders/bayer_unpacked.vert b/include/libcamera/internal/shaders/bayer_unpacked.vert
index fb5109ee..1425b449 100644
--- a/include/libcamera/internal/shaders/bayer_unpacked.vert
+++ b/include/libcamera/internal/shaders/bayer_unpacked.vert
@@ -40,8 +40,10 @@ varying vec4            xCoord;
 /** of the adjacent pixels.*/
 varying vec4            yCoord;
 
+uniform float stride_factor;
+
 void main(void) {
-    center.xy = textureIn;
+    center.xy = vec2(textureIn.x * stride_factor, textureIn.y);
     center.zw = textureIn * tex_size + tex_bayer_first_red;
 
     xCoord = center.x + vec4(-2.0 * tex_step.x,
diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp
index cf40478f..29a8ae70 100644
--- a/src/libcamera/software_isp/debayer_egl.cpp
+++ b/src/libcamera/software_isp/debayer_egl.cpp
@@ -455,7 +455,7 @@ void DebayerEGL::setShaderVariableValues(DebayerParams &params)
 			      (GLfloat)height_ };
 	GLfloat Step[] = { static_cast<float>(bytesPerPixel_) / (inputConfig_.stride - 1),
 			   1.0f / (height_ - 1) };
-	GLfloat Stride = 1.0f;
+	GLfloat Stride = (GLfloat)width_ / (inputConfig_.stride / bytesPerPixel_);
 	GLfloat scaleX = (GLfloat)window_.width / width_;
 	GLfloat scaleY = (GLfloat)window_.height / height_;
 	GLfloat transX = -(1.0f - scaleX);
