This commit restores support for Motion Path drawing in 2.8 (as it wasn't ported over to the new draw engines earlier, and the existing space_view3d/drawanimviz.c code was removed during the Blender Internal removal). Notes: * Motion Paths are now implemented as an overlay (enabled by default). Therefore, you can turn all of them on/off from the "Overlays" popover * By and large, we have kept the same draw style as was used in 2.7 Further changes can happen later following further design work. * One change from 2.7 is that thicker lines are used by default (2px vs 1px) Todo's: * There are some bad-level calls introduced here (i.e. the actgroup_to_keylist() stuff). These were introduced to optimise drawing performance (by avoiding full keyframes -> keylist conversion step on each drawcall). Instead, this has been moved to the calculation step (in blenkernel). Soon, there will be some cleanups/improvements with those functions, so until then, we'll keep the bad level calls. Credits: * Clément Foucault (fclem) - Draw Engine magic + Shader Conversion/Optimisation * Joshua Leung (Aligorith) - COW fixes, UI integration, etc. Revision History: See "tmp-b28-motionpath_drawing" branch (rBa12ab5b2ef49ccacae091ccb54d72de0d63f990d)
48 lines
1.2 KiB
GLSL
48 lines
1.2 KiB
GLSL
|
|
uniform mat4 ViewProjectionMatrix;
|
|
|
|
uniform int pointSize = 2;
|
|
uniform int frameCurrent;
|
|
uniform int cacheStart;
|
|
uniform bool showKeyFrames = true;
|
|
uniform bool useCustomColor;
|
|
uniform vec3 customColor;
|
|
|
|
in vec3 pos;
|
|
in int flag;
|
|
|
|
#define MOTIONPATH_VERT_SEL (1 << 0)
|
|
#define MOTIONPATH_VERT_KEY (1 << 1)
|
|
|
|
out vec4 finalColor;
|
|
|
|
void main()
|
|
{
|
|
gl_Position = ViewProjectionMatrix * vec4(pos, 1.0);
|
|
gl_PointSize = float(pointSize + 2);
|
|
|
|
int frame = gl_VertexID + cacheStart;
|
|
finalColor = (useCustomColor) ? vec4(customColor, 1.0) : vec4(1.0);
|
|
|
|
/* Bias to reduce z fighting with the path */
|
|
gl_Position.z -= 1e-4;
|
|
|
|
if (showKeyFrames) {
|
|
if ((flag & MOTIONPATH_VERT_KEY) != 0) {
|
|
gl_PointSize = float(pointSize + 5);
|
|
finalColor = colorVertexSelect;
|
|
/* Bias more to get these on top of regular points */
|
|
gl_Position.z -= 1e-4;
|
|
}
|
|
/* Draw big green dot where the current frame is.
|
|
* NOTE: this is only done when keyframes are shown, since this adds similar types of clutter
|
|
*/
|
|
if (frame == frameCurrent) {
|
|
gl_PointSize = float(pointSize + 8);
|
|
finalColor = colorCurrentFrame;
|
|
/* Bias more to get these on top of keyframes */
|
|
gl_Position.z -= 1e-4;
|
|
}
|
|
}
|
|
}
|