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:
authorAlexander Gavrilov <angavrilov@gmail.com>2018-10-19 18:55:19 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2018-10-29 22:04:19 +0300
commita0dfa320cddd8396911058bae7c3a0eb52e7f2ee (patch)
tree9fbb05f44a99a83354edbfea586edbb9130b886c /source/blender/gpu/shaders/gpu_shader_keyframe_diamond_frag.glsl
parentb18ac77df3c2eb002bd4c5ed2e6b606535cb67cc (diff)
Dope Sheet: new option to display keyframe interpolation mode and extremes.
With the new automatic handle algorithm, it is possible to do a lot of the animation via keyframes without touching the curves. It is however necessary to change the keyframe interpolation and handle types in certain cases. Currently the dopesheet/action editor allows changing the types, but does not show them in any way. To fix, add a new menu option to display this information. For handle type, it is represented using the shape of the key icons: diamond for Free, clipped diamond for Aligned, square for Vector, circle for Auto Clamp, and cirle with dot for Automatic. Non-bezier interpolation is a property of intervals between keys, so it is marked by drawing lines, similar to holds. In this initial version, only the fact of non-bezier interpolation is displayed, without distinguishing types. For summaries, the line is drawn at half alpha if not all curves in the group are non-bezier. In addition, it is sometimes helpful to know the general direction of change of the curve, and which keys are extremes. This commit also adds an option to highlight extremes, based on comparing the keyed values with adjacent keys. Half-intensity display is used for overshot bezier extremes, or non-uniform summaries. Reviewers: brecht, aligorith, billreynish Differential Revision: https://developer.blender.org/D3788
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.glsl108
1 files changed, 82 insertions, 26 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
index 7f445369833..1c12a4f942d 100644
--- a/source/blender/gpu/shaders/gpu_shader_keyframe_diamond_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_keyframe_diamond_frag.glsl
@@ -1,31 +1,87 @@
+flat in vec4 radii;
+flat in vec4 thresholds;
+
+flat in vec4 finalColor;
+flat in vec4 finalOutlineColor;
+
+flat in int finalFlags;
-in vec4 radii;
-in vec4 finalColor;
-in vec4 finalOutlineColor;
out vec4 fragColor;
+const float diagonal_scale = sqrt(0.5);
+
+const float minmax_bias = 0.7;
+const float minmax_scale = sqrt(1.0 / (1.0 + 1.0/minmax_bias));
+
+bool test(int bit) {
+ return (finalFlags & bit) != 0;
+}
+
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(finalOutlineColor.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));
+ vec2 pos = gl_PointCoord - vec2(0.5);
+ vec2 absPos = abs(pos);
+ float radius = (absPos.x + absPos.y) * diagonal_scale;
+
+ float outline_dist = -1.0;
+
+ /* Diamond outline */
+ if (test(0x1)) {
+ outline_dist = max(outline_dist, radius - radii[0]);
+ }
+
+ /* Circle outline */
+ if (test(0x2)) {
+ radius = length(absPos);
+
+ outline_dist = max(outline_dist, radius - radii[1]);
+ }
+
+ /* Top & Bottom clamp */
+ if (test(0x4)) {
+ outline_dist = max(outline_dist, absPos.y - radii[2]);
+ }
+
+ /* Left & Right clamp */
+ if (test(0x8)) {
+ outline_dist = max(outline_dist, absPos.x - radii[2]);
+ }
+
+ float alpha = 1 - smoothstep(thresholds[0], thresholds[1], abs(outline_dist));
+
+ /* Inside the outline. */
+ if (outline_dist < 0) {
+ /* Middle dot */
+ if (test(0x10)) {
+ alpha = max(alpha, 1 - smoothstep(thresholds[2], thresholds[3], radius));
+ }
+
+ /* Up and down arrow-like shading. */
+ if (test(0x300)) {
+ float ypos = -1.0;
+
+ /* Up arrow (maximum) */
+ if (test(0x100)) {
+ ypos = max(ypos, pos.y);
+ }
+ /* Down arrow (minimum) */
+ if (test(0x200)) {
+ ypos = max(ypos, -pos.y);
+ }
+
+ /* Arrow shape threshold. */
+ float minmax_dist = (ypos - radii[3]) - absPos.x * minmax_bias;
+ float minmax_step = smoothstep(thresholds[0], thresholds[1], minmax_dist * minmax_scale);
+
+ /* Reduced alpha for uncertain extremes. */
+ float minmax_alpha = test(0x400) ? 0.55 : 0.85;
+
+ alpha = max(alpha, minmax_step * minmax_alpha);
+ }
+
+ fragColor = mix(finalColor, finalOutlineColor, alpha);
+ }
+ /* Outside the outline. */
+ else {
+ fragColor = vec4(finalOutlineColor.rgb, finalOutlineColor.a * alpha);
+ }
}