In my first blog post I am going to talk about some nuke expressions that I found really useful in the past. I either created them myself, found them on the web or got some advice from my awesome colleagues.
I save the most useful ones as presets in my expression node.
crunch / fill - alpha:
crunch alpha: a < 1 ? 0 : a
fill alpha: a > 0 ? 1 : a
I use these two expressions to modify the alpha values between 0 and 1.
The crunch alpha expression turns all pixels with a value below 1 into 0.
The fill alpha expressions turns all pixels with a value over 0 into 1.
Either way, you get a fully opaque alpha with pixels being 0 or 1 and above.
alpha fringe:
4*(1-a)*a
This Expression is exactly the same then checking the "fringe" checkbox that you can find in the mask row of many nodes.
It is somehow the opposite of the crunch- and fill alpha expressions.
It turns all pixels with a value of 1 or above into 0 and gives pixels with a value of 0.5 the value 1.
The advantage of using it in the expression node is the option to modify it further.
create an "ST Map":
red: ( x + 0.5 ) / width
green: ( y + 0.5 ) / height
This expression creates an ST Map that does not distort your image when you use it with the "STMap" node.
You can manipulate this image in any possible way which then gives you the distortion.
handling nan / inf pixel:
isnan( "channel" ) ? "new value" : "channel"
isnan( "channel" ) ? "channel"(x+"off",y+"off") : "channel"
When you see "nan" or "inf" pixel you should remove them directly or you will be in a big trouble really soon. Luckily there are these 2 expressions which you could use to remove them. You should replace "channel" with r, g, b or a depending on the channel in that your are using the expression. The "isnan" could be replaced with "isinf" to modify "inf" pixel.
The first expression replaces the pixel with a fixed "new value" that you can choose.
The second one offsets the pixels to replace your "inf" or "nan" pixel with surrounding values. Just replace the "off" which means offset with values of your choice.
An example expression could look like this:
isnan( r ) ? r(x+2,y+3) : r
retiming animations:
curve ( ( frame - "first frame" ) * "speed" + "first frame" )
This expression is not designed for the use in the expression node. Instead, you can use this in every knob that has an animation.
It retimes your animation curve based on a factor which I called "speed".
It is very useful when you have retimed a shot which has a matchmove that was done on the original plate.
You can then use this expression in your camera and geometry if they are animated.
Just replace the "first frame" with the starting frame of your clip and replace the "speed" with your retiming factor for example "0.5" or link it to a knob where you did your retiming animation (e.g. the "timingOutputSpeed" in a Kronos node).
An example expression with a clip starting on frame 1009 could look like this:
curve ( ( frame - 1009 ) * Kronos1.timingOutputSpeed + 1009 )
I hope that these expressions will help you in your comps.
If I encounter new useful expressions I will add them to this post.
Stay productive!
Cheers,
Marcel
Comentários