Nuke Tips – Kronos, MotionBlur, Oflow, or VectorBlur?

The last draft for this article dated back to Jan 25, 2016… time to revive it!

Kronos, MotionBlur, Oflow, or Vector Blur? I’m blur…

The great thing with Nuke is that we have many ways to skin a cat problem.

I’ll be focusing on adding motion blur to CGI FX elements like fire, blood and debris. Yes you can abuse I mean use Kronos and Oflow for adding motion blur instead of slowing down footage!

Time to explore the various methods and see which one make or break depending on the situation.

Do not get confused with MotionBlur2D and MotionBlur3D which are not designed to generate motion blur by analysing the image sequences. MotionBlur2D uses the Transform animation while MotionBlur3D uses the camera animation to generate motion blur.

Continue reading

Nuke Tips – Hide Node Input

Hide Node Input or Node Hide Input or Input Node Hide

When your Nuke script start to grow bigger and complicated, it is time to start to organise the node graph flow for better readability and remove redundancy.

I don’t feel like writing a lengthy explanation on when or why to use it but here’s a bullet list on the usefulness of hiding node input:

  • Reduce redundancy by avoiding duplicates “copy” of the same node
  • Ensuring a cleaner and easier to read Node Graph (if only I can keep my personal belongings as tidy as the node graph–)
  • Avoid potential Nuke script corruption when cloning a node which can happen if you’re not lucky

Potential Nuke Script Corruption?!! Eeeepssss

To further explain on the last point, there are situation where you want to clone a node so you can use it on another part of the comp and prefer the ease of manipulating either of the clone nodes to propagate the same changes.

BUT

It comes with the risk of Nuke potentially screwing up the actual render and one of the way to fix it is to have a copy of it (think Clone Nodes is like Duplicate Special in Maya or Instance in 3ds Max) or linking the master node directly to where you want to use it.

This is where the Hide Node Input comes in handy!

Quick GIF Demonstration

Nuke Tips – Normalize Depth Pass

Time to Conform to Normality

Another short Nuke Tips so without further ado let’s normalise/normalize!

Hmmm Red Channel Mask. Wait a second...

Hmmm Red Channel Mask. Wait a second…

If you output a Pz (depth) image plane from Houdini’s Mantra and read it in Nuke, you’ll see it as a solid flat colour and wonder why it doesn’t match the view in the Render tab or Mplay in Houdini.

What happened is Houdini remap the Pz data by normalising the min/max value to a viewable range for the artist.

So here’s what we can do to make it viewable (and usable for various compositing tasks) in Nuke.

  • Shuffle the depth channel to RGB and alpha to… Alpha. (this step can be skipped if you prefer to manipulate the depth channel directly)
  • Optional but you can use the CurveTool node and use the Max Luma Pixel operator to find the brightest pixel in the depth channel.
  • Use Grade node to remap the black and white point. Typically you can leave the blackpoint at 0 and set the whitepoint to the brightest pixel.
  • Another optional step but in case there is no valid sky dome geometry to represent the sky depth, you can fake it by using a Constant node with a value way higher than the brightest pixel and merge it using Under if you been following the above steps.
  • To adjust the midpoint of the depth, tweak the Gamma value.

This is the end result:

Silent Hill-esque normalize depth after remapping in Nuke

Silent Hill-esque normalize depth after remapping in Nuke

Here’s the node graph setup for your reference:

Why Normalize Depth Pass?

Seeing a solid colour in the viewer is not exactly practical!

This tutorial is more for Mantra way of handling the depth pass where it renders depth using the distance from the camera.

Pixels that are nearer to the camera are closer to zero and pixels that are further from the camera are represented by the distance from the camera.

Imagine you have a building geometry that are 100 units away from the camera, the pixel value will be approximately 100.

Traditionally most renderer will offer options to set the near and far clip value to render the depth pass but this are destructive as we “bake” the possible depth range to fit into the final depth render. Unless you render and export the depth pass at least in 16-bit Half Float or better 32-bit Float (which can be overkill unless you need the highest accuracy during compositing).

Further Reading/Viewing

Learn How to Render and composite Z-Depth in Houdini: https://www.sidefx.com/tutorials/learn-how-to-render-and-composite-z-depth-in-houdini

Houdini Rendering to Z-depth with Mantra (Pz) (Japanese): http://yoong-cut-and.blogspot.com/2015/02/houdini-rendering-to-z-depth-with.html

Houdini – ZDepth Passes (Japanese): http://www.technical-artist.net/?p=92

Tutorial – Demystifying Camera Depth Passes in Maya Mental Ray: https://vimeo.com/113997080

The right way to render a depth pass: http://forums.cgsociety.org/showthread.php?t=901605

VRayZDepth using 3ds Max: https://docs.chaosgroup.com/display/VRAY3MAX/Z-Depth+%7C+VRayZDepth

VRayZDepth using Maya: https://docs.chaosgroup.com/display/VRAY3MAYA/Z-Depth+%7C+vrayRE_Z_depth

Nuke Tips – Procedural Film Scratch (Creating Gizmo) Part 3

The Last Part in the Trilogy of Procedural Film Scratch

Apology for the delay as I got busy prepping BG (Background ) assets for my Houdini reel for the past weeks.

Here’s the link to the first two parts of the tutorials.

Nuke Tips – Procedural Film Scratch (Creating Gizmo) Part 1

Nuke Tips – Procedural Film Scratch (Creating Gizmo) Part 2

The EXPR Dilemma

First of all, there is a particular issue that I missed out in Part 2 on the use of TCL expression in Nuke.

I’ll let the following screenshots explained the issues.

Just in case for users who relies on machine translation when reading this post, to use the value of a variable in another variable, we need to use expr for it to evaluate properly.

Slight Modification to Scratch

If you’re up to the challenge, you can give the user choices in selecting the look of the scratch. Problem is I’m lazy and decided to modify the look of the scratch directly in the RotoPaint node.

Here’s how the new curly scratch looks.

Adding Chromatic Aberration

There are a few Chromatic Aberration (CA) gizmo out there at Nukepedia but let’s create our own version here.

Ok maybe the node graph above is pretty complicated since it involves extra nodes as part of the gizmo.

The following node graph shows a simple construction to fake CA effect.

The idea here is to scale a particular channel (usually the Red channel) in a radial zoom which the GodRays node does. You can try scaling using the Transform node but it creates an unnatural looking CA but might be appropriate depending on the look you’re after.

The following BG render from my upcoming Houdini FX reel demonstrates the difference between both methods.

With that out of the way, let’s look at how to export our gizmo for others to use.

Exporting the Gizmo

Before that, we want to write a simple Help description whenever the user hovers over the question mark icon at the top right of the properties panel.

Just right click on an empty area at the gizmo properties and choose Edit help.

Well the help stuff are optional but it can be beneficial to write a short and critical information about the gizmo. You don’t want the user to be left in the dark!

Finally remember to set a default value for all the gizmo parameters before we export it.

Exporting the gizmo is as easy as going to the Node tab and choose export as gizmo…

So we have export the gizmo… now what we can do with it?

You can either place it in the .nuke folder in the Home directory (the path varies between OS) and go to Other -> All Plugins -> Update to access the gizmo through the Tab menu.

OR

Refer to the official documentation on how to access the custom gizmo:

https://help.thefoundry.co.uk/nuke/8.0/content/user_guide/configuring_nuke/custom_menus_toolbars.html

https://help.thefoundry.co.uk/nuke/8.0/content/user_guide/configuring_nuke/loading_gizmos_plugins_scripts.html#configuring_nuke_769985560_701388

The Finale of the Gizmo Trilogy

So we have reached the end of this three part tutorials and hopefully you have learned something useful from it.

One thing that I’ll love to add to the custom gizmo is an icon if you’re planning to access it from a custom menu and Dan Sturm wrote a good article on setting up a Nuke Gizmo icons.

As a reward, here’s how I abused the very gizmo that I created on a random train footage that I found on YouTube.

Still here?

You can download the tkk_FilmScratch gizmo by clicking this link and I’ll probably upload it over at Nukepedia in the near future after some minor modifications.

Happy Gizmo Nuking!

Nuke Tips – Procedural Film Scratch (Creating Gizmo) Part 2

Previously in Part 1 of Creating a Procedural Film Scratch Gizmo

In Part 1, we covered the process of creating a gizmo from scratch and ensuring the custom user knobs are working through the use of expression.

Albeit simple, the gizmo creation process is easy to learn but hard to master if we want to create a complex gizmo (take a look at some of the popular gizmo over at Nukepedia and study the node graph).

By the end of this tutorial, we’ll be able to generate this result using the gizmo:

What’s Covered in Part 2?

If you are looking for a complete walkthrough of creating this gizmo, I’m afraid to say that I’ll be covering the critical aspect of the gizmo creation only as it is better to get the hang of creating several basic gizmos before attempting this part.

As long you have the understanding of the following, you are good to go in troubleshooting the gizmo creation:

  1. TCL/Python Expression
  2. Using Variables in Nuke
  3. Google (or any major search engine)

Without further ado, let’s take a look at the node graph layout which can be further develop in the future.

Do not confuse this with an organisation chart–

Do take note that renaming nodes inside a gizmo are not necessary so you can leave the default name that Nuke generate like Reformat1, Transform3, Shuffle2 and so on.

Create scratch using RotoPaint

Just draw a line and you’re done!

Serious answer, it is better to setup a Reformat node with a low resolution (ideally lower than 512×512) since you don’t want Nuke to draw a high resolution scratch for faster calculation.

If you need higher res for a 4K Ultra HD output, feel free to bump it up according to your requirements.

Setting up Variables in Nuke

The best way to setting up variables in Nuke is to use a Text node and write it out in the Node tab instead of the Text tab.

To setup a variable in Nuke using TCL, use the following format:

[set variablename value]

[set variablename [value node.parameter] ]

Examples:

projwidth [set projwidth [value root.format.width]]

projheight [set projheight [value root.format.height]]

minX [set minX $projwidth/3]

maxX [set maxX $projwidth/5]

minY [set minY $projheight/4]

maxY [set maxY $projheight/4]

You’ll notice there is a variablename prefix before the square brackets in the example above. It is to help us identify the variable as Nuke will only return the value of the expression in the square brackets. Here is more random examples:

month [set month November] = month November

rainamount [set rainamount 1000] = rainamount 1000

petrolJellySmear [set petrolJellySmear [value Blur1.size]] = petrolJellySmear 80

So how do we use the variables? Just append it with a $ prefix like $month and $rainamount in your expression although we can use it anywhere within Nuke like in the following example:

Using expression on Transform node for animation

To procedurally generate the animation of the scratch, expression is the way to go as you’ll unlikely to keyframe every single frame manually!

As I’m not an expert in mathematics algebra, do visit the excellent Nuke Wave Expressions by Cameron Carson to get a good idea on generating the desire animation curves.

In the above screenshot, you can see the expressions with the variables that I set up earlier.

If you have the Transform node active, you can preview the animation curve of the expression through the Curve Editor tab and the animation path on the Viewer tab.

After playing around with the various parameters in the expression, it is time to duplicate the transform node to allow us to configure the amount of visible scratches on the gizmo using the switch node.

Duplicate and expression tweak for variation

Once you’re happy with a particular expression, it is time to duplicate it and slightly modify the expression to generate another variation.

In the above node graph, the setup allow us to use the Switch node to control the amount of scratches by using expression to link the number on the Switch node with a pulldown choice knob.

Create dust speckle using…

…Noise node?

Nothing much to see here. Just tweak to your heart content to get the appearance of a flickering dust speckle and don’t forget to link the useful parameters to the custom user knobs.

Setup User Knobs to Access Relevant Parameters

The usual stuff. Add or pick the knobs that you will be using for the gizmo.

Do note that you can use HTML tags to customise the appearance of the Text knob as shown above with the bold tag <b></b>.

The current user knob layout for this tutorial.

As not every film scratch needs to be white on black background, I added an invert checkbox (linked to an Invert node) to allow for black on white background.

Depending on the situation, it can be redundant since a user can manually add their own invert node after the gizmo node.

Still it is nice to have the option built into the gizmo to save the trouble for the users.

Next in Part 3, Chromatic Aberration and Exporting Gizmo

For Part 3, we’ll be adding a Chromatic Aberration toggle (heh) and wrap it up by exporting the gizmo.

Hopefully you find Part 2 useful in your quest to create a custom gizmo that will save the universe. Just kidding.

Here’s another version of the procedural film scratch just by adjusting a few parameters on the gizmo.

See you next time in Part 3!

Further Reading

https://docs.thefoundry.co.uk/nuke/63/pythondevguide/index.html

http://thoughtvfx.blogspot.my/2012/12/nuke-tcl-tips.html

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