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)
39 lines
1.0 KiB
GLSL
39 lines
1.0 KiB
GLSL
|
|
layout(lines) in;
|
|
layout(triangle_strip, max_vertices = 4) out;
|
|
|
|
uniform mat4 ProjectionMatrix;
|
|
uniform vec2 viewportSize;
|
|
uniform int lineThickness = 2;
|
|
|
|
in vec4 finalColor_geom[];
|
|
in vec2 ssPos[];
|
|
|
|
out vec4 finalColor;
|
|
|
|
vec2 compute_dir(vec2 v0, vec2 v1)
|
|
{
|
|
vec2 dir = normalize(v1 - v0 + 1e-8);
|
|
dir = vec2(-dir.y, dir.x);
|
|
return dir;
|
|
}
|
|
|
|
void main(void)
|
|
{
|
|
vec2 t;
|
|
vec2 edge_dir = compute_dir(ssPos[0], ssPos[1]) / viewportSize;
|
|
|
|
bool is_persp = (ProjectionMatrix[3][3] == 0.0);
|
|
|
|
finalColor = finalColor_geom[0];
|
|
t = edge_dir * (float(lineThickness) * (is_persp ? gl_in[0].gl_Position.w : 1.0));
|
|
gl_Position = gl_in[0].gl_Position + vec4(t, 0.0, 0.0); EmitVertex();
|
|
gl_Position = gl_in[0].gl_Position - vec4(t, 0.0, 0.0); EmitVertex();
|
|
|
|
finalColor = finalColor_geom[1];
|
|
t = edge_dir * (float(lineThickness) * (is_persp ? gl_in[1].gl_Position.w : 1.0));
|
|
gl_Position = gl_in[1].gl_Position + vec4(t, 0.0, 0.0); EmitVertex();
|
|
gl_Position = gl_in[1].gl_Position - vec4(t, 0.0, 0.0); EmitVertex();
|
|
EndPrimitive();
|
|
}
|