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_frag.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_frag.glsl')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_keyframe_diamond_frag.glsl38
1 files changed, 38 insertions, 0 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_keyframe_diamond_frag.glsl b/source/blender/gpu/shaders/gpu_shader_keyframe_diamond_frag.glsl
new file mode 100644
index 00000000000..43a7e42153a
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_keyframe_diamond_frag.glsl
@@ -0,0 +1,38 @@
+
+#if __VERSION__ == 120
+ varying vec4 radii;
+ varying vec4 finalColor;
+ varying vec4 finalOutlineColor;
+ #define fragColor gl_FragColor
+#else
+ in vec4 radii;
+ in vec4 finalColor;
+ in vec4 finalOutlineColor;
+ out vec4 fragColor;
+#endif
+
+void main() {
+ vec2 quad = abs(gl_PointCoord - vec2(0.5));
+ float dist = quad.x + quad.y;
+
+// transparent outside of point
+// --- 0 ---
+// smooth transition
+// --- 1 ---
+// pure outline color
+// --- 2 ---
+// smooth transition
+// --- 3 ---
+// pure point color
+// ...
+// dist = 0 at center of point
+
+ float mid_stroke = 0.5 * (radii[1] + radii[2]);
+
+ vec4 backgroundColor = vec4(finalColor.rgb, 0.0);
+
+ if (dist > mid_stroke)
+ fragColor = mix(finalOutlineColor, backgroundColor, smoothstep(radii[1], radii[0], dist));
+ else
+ fragColor = mix(finalColor, finalOutlineColor, smoothstep(radii[3], radii[2], dist));
+}