aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/shaders_ng/smoothcolor.vert
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2023-06-26 15:49:06 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2024-01-15 21:25:12 +0100
commitb5a05e4e7e97f8ef5c4cc65fee0cfcfd9e4c5cc4 (patch)
tree0e4a559eb4d2003964631e455228069315f668c6 /src/quick/scenegraph/shaders_ng/smoothcolor.vert
parent2874c79cebdf6a0f0322b7217d20772060e065d9 (diff)
scenegraph: Add plumbing for enabling multiview
This will be used in RenderMode3D only in practice, where Qt Quick 3D is going to pass in multiple matrices to the QSGRenderer. Task-number: QTBUG-114871 Change-Id: Icae7f05958729d9e51948e1f38621ec4a541192d Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/quick/scenegraph/shaders_ng/smoothcolor.vert')
-rw-r--r--src/quick/scenegraph/shaders_ng/smoothcolor.vert28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/quick/scenegraph/shaders_ng/smoothcolor.vert b/src/quick/scenegraph/shaders_ng/smoothcolor.vert
index 03a3ff8975..6ec10a7e70 100644
--- a/src/quick/scenegraph/shaders_ng/smoothcolor.vert
+++ b/src/quick/scenegraph/shaders_ng/smoothcolor.vert
@@ -7,22 +7,32 @@ layout(location = 2) in vec4 vertexOffset;
layout(location = 0) out vec4 color;
layout(std140, binding = 0) uniform buf {
+#if QSHADER_VIEW_COUNT >= 2
+ mat4 matrix[QSHADER_VIEW_COUNT];
+#else
mat4 matrix;
+#endif
vec2 pixelSize;
float opacity;
-} ubuf;
-
-out gl_PerVertex { vec4 gl_Position; };
+};
void main()
{
- vec4 pos = ubuf.matrix * vertex;
+#if QSHADER_VIEW_COUNT >= 2
+ vec4 pos = matrix[gl_ViewIndex] * vertex;
+ vec4 m0 = matrix[gl_ViewIndex][0];
+ vec4 m1 = matrix[gl_ViewIndex][1];
+#else
+ vec4 pos = matrix * vertex;
+ vec4 m0 = matrix[0];
+ vec4 m1 = matrix[1];
+#endif
gl_Position = pos;
if (vertexOffset.x != 0.) {
- vec4 delta = ubuf.matrix[0] * vertexOffset.x;
+ vec4 delta = m0 * vertexOffset.x;
vec2 dir = delta.xy * pos.w - pos.xy * delta.w;
- vec2 ndir = .5 * ubuf.pixelSize * normalize(dir / ubuf.pixelSize);
+ vec2 ndir = .5 * pixelSize * normalize(dir / pixelSize);
dir -= ndir * delta.w * pos.w;
float numerator = dot(dir, ndir * pos.w * pos.w);
float scale = 0.0;
@@ -34,9 +44,9 @@ void main()
}
if (vertexOffset.y != 0.) {
- vec4 delta = ubuf.matrix[1] * vertexOffset.y;
+ vec4 delta = m1 * vertexOffset.y;
vec2 dir = delta.xy * pos.w - pos.xy * delta.w;
- vec2 ndir = .5 * ubuf.pixelSize * normalize(dir / ubuf.pixelSize);
+ vec2 ndir = .5 * pixelSize * normalize(dir / pixelSize);
dir -= ndir * delta.w * pos.w;
float numerator = dot(dir, ndir * pos.w * pos.w);
float scale = 0.0;
@@ -47,5 +57,5 @@ void main()
gl_Position += scale * delta;
}
- color = vertexColor * ubuf.opacity;
+ color = vertexColor * opacity;
}