Noob friendly expressions


#1

Are there any easy tutorials/examples for at least the basic/most important expressions.
I am not a programmer, so they should have a noob friendly documentation.
And are After Effects expessions usable here in Natron?


#2

Hi Mondayman,

I think the only document available is in the Natron documentation :
http://natron.readthedocs.io/en/master/devel/paramExpressions.html

This doc is not very noob friendly, but you may find a few things to start with.
I think the most common After Effect expression is the wiggle one, that in natron translate to random()
From this document I read to type random(1,10) to get a random value between 1 and 10. Never played with this myself tho.
you can use also the frame variable. Just type frame*2 to get a value of 20 at frame 10.
you can combine both of them like with random(0,frame) (not sure how this is useful but … anyway)

You’ll need to translate a bit from After Effect expression into Python or into natron specific commands, but that may be easier than it sound. Python is a very simple language that you can learn quickly even if you’re not a programmer. And most of the expressions stuff is like take a value of a node , do basic math and apply it to a value of another node.

If you’ve got an example of something to translate from After to Natron don’t hesitate to post it, that can be a good exercice for us to see how this can be done.

Good luck with all this, at first it may be a bit painful but if you’re serious about CG, learning a bit of python and this stuff will help you many time, as many CG software include python nowadays…


#3

Thanks sozap,

at this time I dont have a particular expression that I need to use. I just do some little tests now and then to learn Natron/nodal compositing, comming from layer based comp… But when in need I will post here some expressions for translations.


I know Python is the language to go (Blender, Fusion,…) and I tried it more or less several times, but it seems I wasnt made for it.
Maybe it just needs more time than I give myself for it.

The dokumentation I worked through as much as I could, and I bet it is all there what you need to know, but (how could I say…) aparrently I need it explained as it is for an eight year old kid. :wink:


For wiggle I found this tutorial some time ago, which is quite good.
Almost AE like.
Which brought my thought up with the usability in both programs.


By the way-
I think you should be on Natron teamhomepage for all your help here on the forum and your Video!
In both categories:

Content Development Team
and
Communications Team

Thanks a lot!


Random controlled movement
#4

Hey !

That’s cool to help people, this also help me to improve and clarify some things.
Also if we want Natron to grow I think it’s up to the users to help each-other and allow new people to get into it. As long as the documentation is incomplete or there isn’t too many tutorials.

For python, the basics of this language is very user friendly, I’m sure you’ll get used to it if you take some beginners tutorials. What can be confusing, is the integration of python in software. Because for that many commands are added and not always the same way. You don’t use the same command to access a value in blender and in natron. After that, you can generally manipulate the value the same way because it’s still python. And once you know the Python API of one software it gets easy to understand another app.

Don’t hesitate to post expressions or example of what you want to do, this will be simpler for us to provide an example that you can work with. Once you’ve done 2 or 3 different expressions I’m sure it will be much more clear.

I’ll see if I can make an example like one translate node that does the opposite of another translate node.
This is quite simple and once you’ll see the expressions you can apply it to other cases.

For the wiggle , have you tested it ? IIRC you have to put some code into the Init.py , but using the random will work. But it won’t be as complete as the wiggle function in the tutorial…

Also, expressions get very useful when you make Pyplugs, or groups. I use Natron only to pimp my 3D renders and I don’t need expression most of the time. But when working on Pyplugs I use them often.
So maybe it’s not a big issue if you don’t understand all of this right now.


#5

Hi,
I tried the wiggle expression like in the video tutorial and after some fiddling it worked almost perfect. Its a flaw on my side with the sliders, which I can surely work out with some time to think about it, but it basically works fine!

As far as I now understand, there are not all terms for expressions in Natron from the beginning?
For example the wiggle funktion. So I had to put the funktion (.py) in the plug-ins folder.

OK, now my question is, Is there a place or list where I can lookup all the expressions/terms that are right in there from the beginning? Or is Natron bare metal so to speak and all functions have to be installed by hand.
And are there already some functions besides wiggle made by Natron users, which I can use?


#6

Hello,

You don’t need to install functions to use expressions.
Expressions are generally used to link two value together. Every value in natron is accessible via a python expressions.
The wiggle function is a kind of super function that you need to install by hand, that has user friendly controls, but otherwise you don’t really need to install something . And I’m not sure that there are other specials functions of that kind available on the net.

I’ve made an example file where one transform node do the opposite of another one.

expression_01.ntp (29.4 KB)

The expression is pretty straightforward :
1/ first - : to invert the value
2/ Transform2.translate.get() : we get the translate value of node Transform2
3/ [0] : translate has two value (X and Y) [0] get the X value and [1] get Y value.

to see what is the script name of a value (like translate) , just look into the tooltips…

This should help you get started, you can also use some variables like frame to get the current frame in the timeline.
This is mainly how I use expressions, but if you want you can go crazy by creating custom value inside nodes, or create much more complicated expression with multi-line expressions and more python.
There is not so much fancy stuff that do nice things straight out of the box like the wiggle function. But still you can do very cool thinks by playing with all this.


#7

Thanks for the clarifying, and the example!
Yes sometimes i make make all unnecessary complicated.
I am currently reading through the Natron documentation with creating nodes, App settings and Natron Engine…

Is there a list of the variables I can use in Natron, such as frames, seed and so on?


#8

I’m not sure there is an extended Expression reference guide, as expressions are mixed with regular python commands in Natron.
But by reading the doc you may learn a few things.
Note also that Natron import python math module. Were you can find a few basic useful functions , like cos, sin…
Try to set an expression like cos(frame) or *cos(frame)100 depending on where you put the expression.

https://docs.python.org/2/library/math.html

As I’m not that much into maths I generally use only sin, cos, pow, but it’s very up to you…


#9

Thanks, I will have a look at it.
Math isn’t my hobbyhorse either. :wink:


#10

These are for AE, but it will hopefully get me to a better understanding of the different terms.
http://www.jjgifford.com/expressions/basics/index.html
http://www.motionscript.com/


#11

Ok I’ve got a quick look at these link. It looks like some recipes or quick tutorials to be used with expressions…
There are some other infos, but it can be indeed a bit confusing…

Maybe one way to make the bridge between AE and Natron would be to take one of these examples and recreate it in Natron.

BTW if I understand correctly, functions like auto-bounce for curves are not supported , but I’m sure it’s possible to recreate most of this stuff into Natron. Don’t hesitate to post a link to a tutorial if you want me to have a look into it.


#12

I tried yesterday evening/night to recreate a very old AE tutorial for pie charts, where the chart is linked to the percentage number. A fairly easy one. The full circle part was easy after looking through all nodes (including GMIC), but where it got complicated was were I needed a transition node to slice up the circle to get some sort of pacman over the other coloured circle. Natron seems to have no thing such as transition effects like radial wipe or any wipe at all for that matter. Which are nice to have for Motiongraphics. So after an hour of searching for some equivalent I was to tired and went to sleep.
I will try some other expressions in the next days and see how far I can get.
Thanks anyway!


#13

Indeed for MotionGraphics AE is the best of all, I’ve found a little cheat to do your pacman pie chart, using a transform node and a polar node. A kind of a radial transition would be a cool addition anyway.
I’ll had it to the Pyplug repository todo list, If I’ve got a bit of time I’ll try to make one with shadertoy that will be faster than the polar conversion.

Taking a tutorial from one software to another always lead to littles cheat and adaptation, but that’s cool to improve our skills :slight_smile:

pacman.ntp (21.2 KB)

Just play with the X and Y location of the transform node, and the rotate of the polar node.
Plug a checkboard instead of the constant to see better what the polar node is doing…


#14

Its fun to play around with your radial transition. :slight_smile:
But instead of the X and Y parameters, I took the Amount parameter.

At first I couldnt get a fully closed circle, because the slider goes only up to 1 but it needs to 4.8.
I tried to multiply the amount*4.8 with an expression, which gave me only “invalid expressions” as answer.
I believe I made it again to complicated with extra sliders that gets the Amount value from the original Amount slider to my slider (with a scala to 5) and *4.8.
The next thought was to get the original Amountslider up to a scala to 5. This was way easier.
(right click Manage userparameters - Pick transform1Amount - edit scala to 4.8 - hit ok)

But now the scale is always off, which gets me to the conclusion to use an expression for it to scale up and down with.
Scale has to be 1 at full circle and 3.5 when almost gone.
Here is my atempt so far (without expression)

PacMan_2.ntp (33.9 KB)


#15

Hey, that’s cool !

Using the amount parameter is kind of OK even if I’ll try to avoid it in that case.
Maybe I’ll do one slider to map the scale (Y value of the translate) and one slider to map the wipe (X) ?
The scale may be not needed depending on what you want…

Anyway , if you set the Translate X to 1920, then the Amount will work when ranging from 0 to 1.

Maybe you can look at creating a nodegroup like a “Pie generator”, with the controls that you’ll need to make your animation, then you can use several Pie node to make a Pie Chart.

At least your starting to make funky expressions and custom properties , keep it up !


#16

Just playing to get two parameters crossed when using the Amountslider (Amount up = Zoom down), and found this site which can be very useful if someone (like me) doesn’t know any math functions to use in an expression.

http://help.thefoundry.co.uk/nuke/8.0/content/user_guide/expressions/adding_math_functions.html#expressions_1415537460_676881


and here are some examples to try. Some work, some not. I used the constant node and the SeExprSimple node.

http://www.nukepedia.com/written-tutorials/expressions-101


#17

Hey cool !

The last link from the nukepedia look like pure awesomness, I must definitly check all these expressions…
I found that expressions on pixels values tends to get generally more complex than expressions on values, (in fact it depends on the case you’re working with) …
SeExpr may be a bit different than the nuke expression language , but if you look at the SeExpr documentation you may find how to translate it.
Thanks a lot for the resources, I see already some things that deserve to be adaptated to Pyplugs…


#18

You’re welcome. :slight_smile:
I am glad its interesting for you. Hope to see the some Pyplugs soon :wink:

Do you know a good expression to link two parameters together, but when the first one gets higher, the other one goes down in a certain proportion?
I worked me theoretically through “if > then” functions, but I guess that is not the solution, because it works on a certain number, but then? I need it fluidly on a range of numbers, so to speak.
Any idea?


#19

Hum, you mean param A get’s always up, but param B get’s up then down ?

That’s maybe a good job for a cos/sin function… let’s say param A is “frame” you can add an expression to param B like sin(frame).
That will create an infinite animation of B going up and down.
You can then tweak the expression with something like sin(frame/0.25) if you want the up and down to be slower, or (sin(frame))*50 if you want a bigger amplitude.

Is that make sense or you need something else ?


#20

If I understand correctly what you mean, you could just multiply the value of the first parameter (A) with -1:

B=A*-1. (The expression will look a little different of course).
so if A = 0, B = 0, and the higher A is, the lower B is, too. You can change the proportion by changing the multiplier, and to offset the values into a range you want, just add a suitable value at the end.
For ex, in pseudocode:

A=sin(frame)
B=A*-0.3+1