aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickshapes/shaders_ng
diff options
context:
space:
mode:
Diffstat (limited to 'src/quickshapes/shaders_ng')
-rwxr-xr-xsrc/quickshapes/shaders_ng/compile.bat15
-rw-r--r--src/quickshapes/shaders_ng/conicalgradient.frag8
-rw-r--r--src/quickshapes/shaders_ng/conicalgradient.frag.qsbbin2284 -> 0 bytes
-rw-r--r--src/quickshapes/shaders_ng/conicalgradient.vert14
-rw-r--r--src/quickshapes/shaders_ng/conicalgradient.vert.qsbbin1856 -> 0 bytes
-rw-r--r--src/quickshapes/shaders_ng/lineargradient.frag8
-rw-r--r--src/quickshapes/shaders_ng/lineargradient.frag.qsbbin1500 -> 0 bytes
-rw-r--r--src/quickshapes/shaders_ng/lineargradient.vert14
-rw-r--r--src/quickshapes/shaders_ng/lineargradient.vert.qsbbin2003 -> 0 bytes
-rw-r--r--src/quickshapes/shaders_ng/radialgradient.frag8
-rw-r--r--src/quickshapes/shaders_ng/radialgradient.frag.qsbbin2555 -> 0 bytes
-rw-r--r--src/quickshapes/shaders_ng/radialgradient.vert14
-rw-r--r--src/quickshapes/shaders_ng/radialgradient.vert.qsbbin1956 -> 0 bytes
-rw-r--r--src/quickshapes/shaders_ng/texturefill.frag25
-rw-r--r--src/quickshapes/shaders_ng/texturefill.vert31
-rw-r--r--src/quickshapes/shaders_ng/wireframe.frag25
-rw-r--r--src/quickshapes/shaders_ng/wireframe.vert23
17 files changed, 161 insertions, 24 deletions
diff --git a/src/quickshapes/shaders_ng/compile.bat b/src/quickshapes/shaders_ng/compile.bat
deleted file mode 100755
index be21daf62f..0000000000
--- a/src/quickshapes/shaders_ng/compile.bat
+++ /dev/null
@@ -1,15 +0,0 @@
-:: Copyright (C) 2019 The Qt Company Ltd.
-:: SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-
-:: For HLSL we invoke fxc.exe (-c argument) and store the resulting intermediate format
-:: instead of HLSL source, so this needs to be run on Windows from a developer command prompt.
-
-:: For SPIR-V the optimizer is requested (-O argument) which means spirv-opt must be
-:: invokable (e.g. because it's in the PATH from the Vulkan SDK)
-
-qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o lineargradient.vert.qsb lineargradient.vert
-qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o lineargradient.frag.qsb lineargradient.frag
-qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o radialgradient.vert.qsb radialgradient.vert
-qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o radialgradient.frag.qsb radialgradient.frag
-qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o conicalgradient.vert.qsb conicalgradient.vert
-qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o conicalgradient.frag.qsb conicalgradient.frag
diff --git a/src/quickshapes/shaders_ng/conicalgradient.frag b/src/quickshapes/shaders_ng/conicalgradient.frag
index 0b1e01bae2..59862f991a 100644
--- a/src/quickshapes/shaders_ng/conicalgradient.frag
+++ b/src/quickshapes/shaders_ng/conicalgradient.frag
@@ -1,3 +1,6 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
#version 440
layout(location = 0) in vec2 coord;
@@ -6,7 +9,12 @@ layout(location = 0) out vec4 fragColor;
layout(binding = 1) uniform sampler2D gradTabTexture;
layout(std140, binding = 0) uniform buf {
+#if QSHADER_VIEW_COUNT >= 2
+ mat4 matrix[QSHADER_VIEW_COUNT];
+#else
mat4 matrix;
+#endif
+ mat4 gradientMatrix;
vec2 translationPoint;
float angle;
float opacity;
diff --git a/src/quickshapes/shaders_ng/conicalgradient.frag.qsb b/src/quickshapes/shaders_ng/conicalgradient.frag.qsb
deleted file mode 100644
index df58050128..0000000000
--- a/src/quickshapes/shaders_ng/conicalgradient.frag.qsb
+++ /dev/null
Binary files differ
diff --git a/src/quickshapes/shaders_ng/conicalgradient.vert b/src/quickshapes/shaders_ng/conicalgradient.vert
index 3db027294b..cdaab16842 100644
--- a/src/quickshapes/shaders_ng/conicalgradient.vert
+++ b/src/quickshapes/shaders_ng/conicalgradient.vert
@@ -6,16 +6,24 @@ layout(location = 1) in vec4 vertexColor;
layout(location = 0) out vec2 coord;
layout(std140, binding = 0) uniform buf {
+#if QSHADER_VIEW_COUNT >= 2
+ mat4 matrix[QSHADER_VIEW_COUNT];
+#else
mat4 matrix;
+#endif
+ mat4 gradientMatrix;
vec2 translationPoint;
float angle;
float opacity;
} ubuf;
-out gl_PerVertex { vec4 gl_Position; };
-
void main()
{
- coord = vertexCoord.xy - ubuf.translationPoint;
+ vec2 gradVertexCoord = (ubuf.gradientMatrix * vertexCoord).xy;
+ coord = gradVertexCoord - ubuf.translationPoint;
+#if QSHADER_VIEW_COUNT >= 2
+ gl_Position = ubuf.matrix[gl_ViewIndex] * vertexCoord;
+#else
gl_Position = ubuf.matrix * vertexCoord;
+#endif
}
diff --git a/src/quickshapes/shaders_ng/conicalgradient.vert.qsb b/src/quickshapes/shaders_ng/conicalgradient.vert.qsb
deleted file mode 100644
index 958a75e918..0000000000
--- a/src/quickshapes/shaders_ng/conicalgradient.vert.qsb
+++ /dev/null
Binary files differ
diff --git a/src/quickshapes/shaders_ng/lineargradient.frag b/src/quickshapes/shaders_ng/lineargradient.frag
index 16894fc764..b6f0dc172a 100644
--- a/src/quickshapes/shaders_ng/lineargradient.frag
+++ b/src/quickshapes/shaders_ng/lineargradient.frag
@@ -1,3 +1,6 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
#version 440
layout(location = 0) in float gradTabIndex;
@@ -6,7 +9,12 @@ layout(location = 0) out vec4 fragColor;
layout(binding = 1) uniform sampler2D gradTabTexture;
layout(std140, binding = 0) uniform buf {
+#if QSHADER_VIEW_COUNT >= 2
+ mat4 matrix[QSHADER_VIEW_COUNT];
+#else
mat4 matrix;
+#endif
+ mat4 gradientMatrix;
vec2 gradStart;
vec2 gradEnd;
float opacity;
diff --git a/src/quickshapes/shaders_ng/lineargradient.frag.qsb b/src/quickshapes/shaders_ng/lineargradient.frag.qsb
deleted file mode 100644
index be3a820afd..0000000000
--- a/src/quickshapes/shaders_ng/lineargradient.frag.qsb
+++ /dev/null
Binary files differ
diff --git a/src/quickshapes/shaders_ng/lineargradient.vert b/src/quickshapes/shaders_ng/lineargradient.vert
index b4eb868186..13168b1c0f 100644
--- a/src/quickshapes/shaders_ng/lineargradient.vert
+++ b/src/quickshapes/shaders_ng/lineargradient.vert
@@ -6,17 +6,25 @@ layout(location = 1) in vec4 vertexColor;
layout(location = 0) out float gradTabIndex;
layout(std140, binding = 0) uniform buf {
+#if QSHADER_VIEW_COUNT >= 2
+ mat4 matrix[QSHADER_VIEW_COUNT];
+#else
mat4 matrix;
+#endif
+ mat4 gradientMatrix;
vec2 gradStart;
vec2 gradEnd;
float opacity;
} ubuf;
-out gl_PerVertex { vec4 gl_Position; };
-
void main()
{
+ vec2 gradVertexCoord = (ubuf.gradientMatrix * vertexCoord).xy;
vec2 gradVec = ubuf.gradEnd - ubuf.gradStart;
- gradTabIndex = dot(gradVec, vertexCoord.xy - ubuf.gradStart) / (gradVec.x * gradVec.x + gradVec.y * gradVec.y);
+ gradTabIndex = dot(gradVec, gradVertexCoord - ubuf.gradStart) / (gradVec.x * gradVec.x + gradVec.y * gradVec.y);
+#if QSHADER_VIEW_COUNT >= 2
+ gl_Position = ubuf.matrix[gl_ViewIndex] * vertexCoord;
+#else
gl_Position = ubuf.matrix * vertexCoord;
+#endif
}
diff --git a/src/quickshapes/shaders_ng/lineargradient.vert.qsb b/src/quickshapes/shaders_ng/lineargradient.vert.qsb
deleted file mode 100644
index 9e76279ca5..0000000000
--- a/src/quickshapes/shaders_ng/lineargradient.vert.qsb
+++ /dev/null
Binary files differ
diff --git a/src/quickshapes/shaders_ng/radialgradient.frag b/src/quickshapes/shaders_ng/radialgradient.frag
index 411e589295..cfbb44ac69 100644
--- a/src/quickshapes/shaders_ng/radialgradient.frag
+++ b/src/quickshapes/shaders_ng/radialgradient.frag
@@ -1,3 +1,6 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
#version 440
layout(location = 0) in vec2 coord;
@@ -6,7 +9,12 @@ layout(location = 0) out vec4 fragColor;
layout(binding = 1) uniform sampler2D gradTabTexture;
layout(std140, binding = 0) uniform buf {
+#if QSHADER_VIEW_COUNT >= 2
+ mat4 matrix[QSHADER_VIEW_COUNT];
+#else
mat4 matrix;
+#endif
+ mat4 gradientMatrix;
vec2 translationPoint;
vec2 focalToCenter;
float centerRadius;
diff --git a/src/quickshapes/shaders_ng/radialgradient.frag.qsb b/src/quickshapes/shaders_ng/radialgradient.frag.qsb
deleted file mode 100644
index ecd7f2926d..0000000000
--- a/src/quickshapes/shaders_ng/radialgradient.frag.qsb
+++ /dev/null
Binary files differ
diff --git a/src/quickshapes/shaders_ng/radialgradient.vert b/src/quickshapes/shaders_ng/radialgradient.vert
index 08f15c4f8c..16c8406b23 100644
--- a/src/quickshapes/shaders_ng/radialgradient.vert
+++ b/src/quickshapes/shaders_ng/radialgradient.vert
@@ -6,7 +6,12 @@ layout(location = 1) in vec4 vertexColor;
layout(location = 0) out vec2 coord;
layout(std140, binding = 0) uniform buf {
+#if QSHADER_VIEW_COUNT >= 2
+ mat4 matrix[QSHADER_VIEW_COUNT];
+#else
mat4 matrix;
+#endif
+ mat4 gradientMatrix;
vec2 translationPoint;
vec2 focalToCenter;
float centerRadius;
@@ -14,10 +19,13 @@ layout(std140, binding = 0) uniform buf {
float opacity;
} ubuf;
-out gl_PerVertex { vec4 gl_Position; };
-
void main()
{
- coord = vertexCoord.xy - ubuf.translationPoint;
+ vec2 gradVertexCoord = (ubuf.gradientMatrix * vertexCoord).xy;
+ coord = gradVertexCoord - ubuf.translationPoint;
+#if QSHADER_VIEW_COUNT >= 2
+ gl_Position = ubuf.matrix[gl_ViewIndex] * vertexCoord;
+#else
gl_Position = ubuf.matrix * vertexCoord;
+#endif
}
diff --git a/src/quickshapes/shaders_ng/radialgradient.vert.qsb b/src/quickshapes/shaders_ng/radialgradient.vert.qsb
deleted file mode 100644
index 68e0e21f02..0000000000
--- a/src/quickshapes/shaders_ng/radialgradient.vert.qsb
+++ /dev/null
Binary files differ
diff --git a/src/quickshapes/shaders_ng/texturefill.frag b/src/quickshapes/shaders_ng/texturefill.frag
new file mode 100644
index 0000000000..c8a7f280f1
--- /dev/null
+++ b/src/quickshapes/shaders_ng/texturefill.frag
@@ -0,0 +1,25 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#version 440
+
+layout(location = 0) in vec2 textureCoord;
+layout(location = 0) out vec4 fragColor;
+
+layout(binding = 1) uniform sampler2D sourceTexture;
+
+layout(std140, binding = 0) uniform buf {
+#if QSHADER_VIEW_COUNT >= 2
+ mat4 qt_Matrix[QSHADER_VIEW_COUNT];
+#else
+ mat4 qt_Matrix;
+#endif
+ mat4 fillMatrix;
+ vec2 boundsSize;
+ float qt_Opacity;
+} ubuf;
+
+void main()
+{
+ fragColor = texture(sourceTexture, textureCoord) * ubuf.qt_Opacity;
+}
diff --git a/src/quickshapes/shaders_ng/texturefill.vert b/src/quickshapes/shaders_ng/texturefill.vert
new file mode 100644
index 0000000000..c9d52469dc
--- /dev/null
+++ b/src/quickshapes/shaders_ng/texturefill.vert
@@ -0,0 +1,31 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#version 440
+
+layout(location = 0) in vec4 vertexCoord;
+layout(location = 1) in vec4 vertexColor;
+
+layout(location = 0) out vec2 textureCoord;
+
+layout(std140, binding = 0) uniform buf {
+#if QSHADER_VIEW_COUNT >= 2
+ mat4 qt_Matrix[QSHADER_VIEW_COUNT];
+#else
+ mat4 qt_Matrix;
+#endif
+ mat4 fillMatrix;
+ vec2 boundsSize;
+ float qt_Opacity;
+} ubuf;
+
+void main()
+{
+ vec2 xformed = (ubuf.fillMatrix * vertexCoord).xy;
+ textureCoord = vec2(xformed.x / ubuf.boundsSize.x, xformed.y / ubuf.boundsSize.y);
+#if QSHADER_VIEW_COUNT >= 2
+ gl_Position = ubuf.qt_Matrix[gl_ViewIndex] * vertexCoord;
+#else
+ gl_Position = ubuf.qt_Matrix * vertexCoord;
+#endif
+}
diff --git a/src/quickshapes/shaders_ng/wireframe.frag b/src/quickshapes/shaders_ng/wireframe.frag
new file mode 100644
index 0000000000..b37ffde6ff
--- /dev/null
+++ b/src/quickshapes/shaders_ng/wireframe.frag
@@ -0,0 +1,25 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#version 440
+
+layout(location = 0) out vec4 fragColor;
+layout(location = 0) in vec3 barycentric;
+
+layout(std140, binding = 0) uniform buf {
+#if QSHADER_VIEW_COUNT >= 2
+ mat4 qt_Matrix[QSHADER_VIEW_COUNT];
+#else
+ mat4 qt_Matrix;
+#endif
+} ubuf;
+
+void main()
+{
+ float f = min(barycentric.x, min(barycentric.y, barycentric.z));
+ float d = fwidth(f * 1.5);
+ float alpha = smoothstep(0.0, d, f);
+
+ //alpha = 1.0 - step(0.5, barycentric.x);
+ fragColor = vec4(1.0, 0.2, 1.0, 1.0) * (1.0 - alpha);
+}
diff --git a/src/quickshapes/shaders_ng/wireframe.vert b/src/quickshapes/shaders_ng/wireframe.vert
new file mode 100644
index 0000000000..69f8872d51
--- /dev/null
+++ b/src/quickshapes/shaders_ng/wireframe.vert
@@ -0,0 +1,23 @@
+#version 440
+
+layout(location = 0) in vec4 vertexCoord;
+layout(location = 1) in vec3 vertexBarycentric;
+layout(location = 0) out vec3 barycentric;
+
+layout(std140, binding = 0) uniform buf {
+#if QSHADER_VIEW_COUNT >= 2
+ mat4 qt_Matrix[QSHADER_VIEW_COUNT];
+#else
+ mat4 qt_Matrix;
+#endif
+} ubuf;
+
+void main()
+{
+ barycentric = vertexBarycentric;
+#if QSHADER_VIEW_COUNT >= 2
+ gl_Position = ubuf.qt_Matrix[gl_ViewIndex] * vertexCoord;
+#else
+ gl_Position = ubuf.qt_Matrix * vertexCoord;
+#endif
+}