4
$\begingroup$

Is there any function or method to obtain the slope (first derivative) of an fcurve at a particular point/frame? (Corresponding to velocity or angular velocity or "velocity of scale" or any other rate of change of a property with an fcurve).

At the basic level I'd like to have a driver depend on whether a scene object is travelling upwards or downwards, not just on it's instantaneous location. The velocity would have even more uses than just a simple sign.

At the moment I can approximate it by sampling the fcurve a little before and a little after the frame in question, and calculating a slope from there, but it feels a bit like a hack, particularly if a better way to calculate it exists.

The maths for calculating the slope of linear and Bezier interpolated fcurves isn't that difficult, but so far I've been unable to find an elegant method of doing so. The upcoming easing equations would also have an simple mathematical solution, but again it's a matter of whether it's implemented as a python function or whether it would have to be calculated from the control points. (If it does have to be calculated that way, I'd love some advice on how to calculate it best).

Further, is it possible to obtain the second derivative (acceleration) for use in a driver?

$\endgroup$
2
$\begingroup$

No, blender doesn't have the ability to do this.

For Bezier splines you could probably calculate this yourself, but once you have F-Curve modifiers and use 2.71's new easing options, this becomes very complicated.

So the best you can do is check values to either side of the keyframe with some offset (called nabla)

|improve this answer|||||
$\endgroup$
1
$\begingroup$

I came across a problem similar to this, when I wanted to use the "Image Offset" checkbox in the Edit Strip tab of the VSE:

How can I add some 'blurry-ness' to a video clip, when I animate the x-component (or y-component) with key-frames?

My solution was to use the Node Compositor and couple of Drivers;This doesn't calculate a slope value, but you may be able to refine it, using the concept:

Slope (M) = Y/X, where Y = (Y1)-(Y2) and X = (X1)-(X2), representing two points (X1,Y1) and (X2,Y2) equally spaced from point (X,Y) on a graphed line or curve. I'm sure that someone can come up with a better definition, that this one.

I don't think that Blender has a function for this (yet) in the compositing nodes (as of Blender 2.79), but they do have 'value' nodes and 'math' nodes that can derive M, if you can get the values of (X1,Y1) and (X2,Y2) at the same time.

So, instead of trying to get two points on the same curve (or line) at the same time, I caused Blender to generate one point on two similar curves (at the same time).

Do this by animating an object, somewhere in a Scene. The object should have all the keyframes and interpolated motion elements that you want your video strip to have (I used an 'empty' object). After every movement is to your liking, use 'shift-d' to duplicate the original object. Then, in the F-Curve editor, select and move all the keyframes for the duplicate object ahead by one frame. I used this key-board command:

a (toggle 'all' key-frames on) gx1 (Go in the X-direction 1(frame) press 'enter'

Now, at any frame number on the Timeline, I can compare the X or Y components of these objects to see if they are becoming closer, or farther apart. With this information, I can animate the 'Vector Blur' node's Speed input to change the amount of blur that is added to the animated displacement('Displace' node).

Composite Node Editor - Detecting speed of movement with two drivers (from Original and Duplicate objects) and applying to video. This causes motion blur to be exaggerated while video displacement is animated. This example (though poor) is only meant to blur in X-axis. It's not perfect, but its what I've got.

Composite Node Editor - Detecting speed of movement with two drivers (from Original and Duplicate objects) and applying to video. This causes motion blur to be exaggerated while video displacement is animated. This example (though poor) is only meant to blur in X-axis. It's not perfect, but its what I've got.

The numbers in the Value nodes are generated by drivers, linked to X-axis data of my two objects.![Closeup - Driver

These values, in my example, are so large that the scale of the grid in the main blender 3D view becomes almost un-seeable. Blender didn't complain, though.

For most of the frames, the location values are equal, meaning a 'zero-value' for speed input to the Vector-blur node. But a difference between the values comes when the first empty object has a head-start on the timeline.

This example is not really 'slope', even according to my own definition. but it gets the blur going, close enough to where I need it. further refining is needed, but I'm out of time.

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.