Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorenricoturri1966 <enricoturri@seznam.cz>2022-03-31 14:23:04 +0300
committerenricoturri1966 <enricoturri@seznam.cz>2022-03-31 14:23:04 +0300
commit0763a48ce5c84fc3cf929e9adbf1d0ac19682a73 (patch)
tree8c6731cbe4f2826fbe4ef3d85f6b01f8e3b98019 /resources
parent8b73d8b65aafad59058fa0e6cc0af1f7721cd672 (diff)
Tech ENABLE_GL_SHADERS_ATTRIBUTES - Fixed OpenGL clipping planes while rendering picking pass
Diffstat (limited to 'resources')
-rw-r--r--resources/shaders/110/flat_clip.fs15
-rw-r--r--resources/shaders/110/flat_clip.vs23
-rw-r--r--resources/shaders/140/flat_clip.fs17
-rw-r--r--resources/shaders/140/flat_clip.vs23
4 files changed, 78 insertions, 0 deletions
diff --git a/resources/shaders/110/flat_clip.fs b/resources/shaders/110/flat_clip.fs
new file mode 100644
index 000000000..ececb8eb1
--- /dev/null
+++ b/resources/shaders/110/flat_clip.fs
@@ -0,0 +1,15 @@
+#version 110
+
+const vec3 ZERO = vec3(0.0, 0.0, 0.0);
+
+uniform vec4 uniform_color;
+
+varying vec3 clipping_planes_dots;
+
+void main()
+{
+ if (any(lessThan(clipping_planes_dots, ZERO)))
+ discard;
+
+ gl_FragColor = uniform_color;
+}
diff --git a/resources/shaders/110/flat_clip.vs b/resources/shaders/110/flat_clip.vs
new file mode 100644
index 000000000..cdf7d4b3b
--- /dev/null
+++ b/resources/shaders/110/flat_clip.vs
@@ -0,0 +1,23 @@
+#version 110
+
+uniform mat4 view_model_matrix;
+uniform mat4 projection_matrix;
+uniform mat4 volume_world_matrix;
+
+// Clipping plane, x = min z, y = max z. Used by the FFF and SLA previews to clip with a top / bottom plane.
+uniform vec2 z_range;
+// Clipping plane - general orientation. Used by the SLA gizmo.
+uniform vec4 clipping_plane;
+
+attribute vec3 v_position;
+
+varying vec3 clipping_planes_dots;
+
+void main()
+{
+ // Fill in the scalars for fragment shader clipping. Fragments with any of these components lower than zero are discarded.
+ vec4 world_pos = volume_world_matrix * vec4(v_position, 1.0);
+ clipping_planes_dots = vec3(dot(world_pos, clipping_plane), world_pos.z - z_range.x, z_range.y - world_pos.z);
+
+ gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
+}
diff --git a/resources/shaders/140/flat_clip.fs b/resources/shaders/140/flat_clip.fs
new file mode 100644
index 000000000..b77e0bfaa
--- /dev/null
+++ b/resources/shaders/140/flat_clip.fs
@@ -0,0 +1,17 @@
+#version 140
+
+const vec3 ZERO = vec3(0.0, 0.0, 0.0);
+
+uniform vec4 uniform_color;
+
+in vec3 clipping_planes_dots;
+
+out vec4 out_color;
+
+void main()
+{
+ if (any(lessThan(clipping_planes_dots, ZERO)))
+ discard;
+
+ out_color = uniform_color;
+}
diff --git a/resources/shaders/140/flat_clip.vs b/resources/shaders/140/flat_clip.vs
new file mode 100644
index 000000000..40cddf1e5
--- /dev/null
+++ b/resources/shaders/140/flat_clip.vs
@@ -0,0 +1,23 @@
+#version 140
+
+uniform mat4 view_model_matrix;
+uniform mat4 projection_matrix;
+uniform mat4 volume_world_matrix;
+
+// Clipping plane, x = min z, y = max z. Used by the FFF and SLA previews to clip with a top / bottom plane.
+uniform vec2 z_range;
+// Clipping plane - general orientation. Used by the SLA gizmo.
+uniform vec4 clipping_plane;
+
+in vec3 v_position;
+
+out vec3 clipping_planes_dots;
+
+void main()
+{
+ // Fill in the scalars for fragment shader clipping. Fragments with any of these components lower than zero are discarded.
+ vec4 world_pos = volume_world_matrix * vec4(v_position, 1.0);
+ clipping_planes_dots = vec3(dot(world_pos, clipping_plane), world_pos.z - z_range.x, z_range.y - world_pos.z);
+
+ gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
+}