olive
olive copied to clipboard
[NODES] Simple math operations in numeric input fields
It's quite useful to have basic math operations in numeric input fields in cases when you know exactly by how much you want to change a value.
Here is how it works e.g. in GIMP:
- Place the cursor after the last number in the numeric input field
- Type +231, or -7643, or *3, or /28
- Press Tab to compute
- The original value in the input field then gets replaced with the computed value
Blender has a great way of doing this, also allows other variable's to be used, (such as frame
).
In order to tell Blender that a user wants a scripted driver a #
is used.
Such an expression could be: #sin(frame)
.
I can straight away think of a few very useful variables:
frame
frame number of clip
sframe
frame number of sequence
length
length of clip which effect is on
With frame
& length
a user could easily make a ken burns effect for example, which dynamically responds to editing. Only issue I can see is how to deal with transitions? frame
would have to start from beginning of transition, not clip.
@alcomposer Yeah, I left it out for simplicity's sake, but yes — GIMP does that sort of thing too (e.g. 1000px + 2cm, or 700+2%), and it's useful indeed. 'frame', 'sframe', and 'length' look good to me :)
Some more I can think of are height
, width
and their s
- prefixed versions, for doing operations that might depend on clip/sequence dimensions.
However, one should think, how this would work (or not) with keyframes? And would it be animatable? (ex: compute #sin(frame)
every frame)
@oc1024 obviously this is a long term idea. If you check out Blender, yes #sin(frame)
would be calculated for every frame.)
If this was to work with keyframes then there would need to be another keyword: keyframe
.
The keyframe
keyword would allow a user to feed the keyframed value into the field. Something like:
#keyframe+sin(frame)
would add a wobble to the keyframed animation.
I think it would be convenient to do the simplest mathematical operations to change the time on the timeline when the video is being edited. Just as implemented in a blender VSE.
This is where GLSL may be better as a scripting language because of its context of computing per frame pixel. While sin, cos, and tan may be interesting for some scenarios. Easing functions that handle tweening may be much easier to understand and implement than hard core inline math. This is the way that CSS went after having hardcore math in Flash. In the end most artistic types just weren't that handy with calculating computation. Easing functions were easier to understand...