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:
authorMike Erwin <significant.bit@gmail.com>2017-02-11 08:02:28 +0300
committerMike Erwin <significant.bit@gmail.com>2017-02-11 08:02:28 +0300
commita161d45cfb6de45c5227f4bfc5161f5567c25e6c (patch)
tree45970f3b935b253f16e71746ecb5a1976929e315 /source/blender/gpu/shaders/gpu_shader_keyframe_diamond_vert.glsl
parentf7b1b87ba953ba9ae86ca9a70d6da66b6e0ea3f7 (diff)
add builtin GPU_SHADER_KEYFRAME_DIAMOND
Now we can draw keyframe markers as point sprites, with fewer draw calls and state changes. Based on the builtin shader for round points with anti-aliased outline. This one is more pointy.
Diffstat (limited to 'source/blender/gpu/shaders/gpu_shader_keyframe_diamond_vert.glsl')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_keyframe_diamond_vert.glsl44
1 files changed, 44 insertions, 0 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_keyframe_diamond_vert.glsl b/source/blender/gpu/shaders/gpu_shader_keyframe_diamond_vert.glsl
new file mode 100644
index 00000000000..69afefa685f
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_keyframe_diamond_vert.glsl
@@ -0,0 +1,44 @@
+
+uniform mat4 ModelViewProjectionMatrix;
+
+const float pixel_fudge = sqrt(2.0);
+const float outline_width = 1.25 * pixel_fudge;
+
+#if __VERSION__ == 120
+ attribute vec2 pos;
+ attribute float size;
+ attribute vec4 color;
+ attribute vec4 outlineColor;
+ varying vec4 finalColor;
+ varying vec4 finalOutlineColor;
+ varying vec4 radii;
+#else
+ in vec2 pos;
+ in float size;
+ in vec4 color;
+ in vec4 outlineColor;
+ out vec4 finalColor;
+ out vec4 finalOutlineColor;
+ out vec4 radii;
+#endif
+
+void main() {
+ gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0);
+
+ // pass through unchanged
+ gl_PointSize = size;
+ finalColor = color;
+ finalOutlineColor = outlineColor;
+
+ // calculate concentric radii in pixels
+ float radius = 0.5 * gl_PointSize;
+
+ // start at the outside and progress toward the center
+ radii[0] = radius;
+ radii[1] = radius - pixel_fudge;
+ radii[2] = radius - outline_width;
+ radii[3] = radius - outline_width - pixel_fudge;
+
+ // convert to PointCoord units
+ radii /= size;
+}