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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-12-22 23:02:30 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-01-11 18:00:23 +0300
commit9d19ff90760755f6dea97a58fa50e5e299ae334e (patch)
treef26e108d68063725753e9817ca732725ea1cd462 /source/blender/gpu/shaders
parent943852c0dc17bff74e3cc91d17c2eeb66adacf33 (diff)
GPUShader: Add selection id shader
This is to separate id drawing from standard color drawing.
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_3D_selection_id_vert.glsl24
-rw-r--r--source/blender/gpu/shaders/gpu_shader_selection_id_frag.glsl21
2 files changed, 45 insertions, 0 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_3D_selection_id_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_selection_id_vert.glsl
new file mode 100644
index 00000000000..9c6be69efce
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_3D_selection_id_vert.glsl
@@ -0,0 +1,24 @@
+
+uniform mat4 ModelViewProjectionMatrix;
+
+in vec3 pos;
+
+#ifndef UNIFORM_ID
+uniform uint offset;
+in uint color;
+
+flat out vec4 id;
+#endif
+
+void main()
+{
+#ifndef UNIFORM_ID
+ id = vec4(
+ (((color + offset) ) & uint(0xFF)) * (1.0f / 255.0f),
+ (((color + offset) >> 8) & uint(0xFF)) * (1.0f / 255.0f),
+ (((color + offset) >> 16) & uint(0xFF)) * (1.0f / 255.0f),
+ (((color + offset) >> 24) ) * (1.0f / 255.0f));
+#endif
+
+ gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
+}
diff --git a/source/blender/gpu/shaders/gpu_shader_selection_id_frag.glsl b/source/blender/gpu/shaders/gpu_shader_selection_id_frag.glsl
new file mode 100644
index 00000000000..29fe9e9d8c7
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_selection_id_frag.glsl
@@ -0,0 +1,21 @@
+
+#ifdef UNIFORM_ID
+uniform uint id;
+#else
+flat in vec4 id;
+#endif
+
+out vec4 fragColor;
+
+void main()
+{
+#ifdef UNIFORM_ID
+ fragColor = vec4(
+ ((id ) & uint(0xFF)) * (1.0f / 255.0f),
+ ((id >> 8) & uint(0xFF)) * (1.0f / 255.0f),
+ ((id >> 16) & uint(0xFF)) * (1.0f / 255.0f),
+ ((id >> 24) ) * (1.0f / 255.0f));
+#else
+ fragColor = id;
+#endif
+}