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

Nuke Tips – Tweak HDRI Map

Tweak HDRI Map and Where to Find Them!

This Nuke/insertprogramthatcaneditHDRI Tips will be a rather short tutorial that focuses on how to tweak HDRI map in Nuke for use in rendering.

I’m using Vray but any renderer that supports IBL (image-based lighting) should work too like Octane, Corona, Arnold and etc.

No idea if UE4 (Unreal Engine 4) own IBL system behaves similarly but let me know in the comment (if I haven’t update this article in the near future)!

Last edited: Nov 2, 2017 @ 6:28 pm Added HDRI Haven link as another free HDRI resources.

Continue reading

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

Procedural Film Scratch

One of the common (or cliche) effects in the post production phase to achieve the look of vintage film that are either worn out, exposed in a very dusty environment… or maybe for horror/spooky mood.

BUT for no actual reason (hehe), we will be creating a procedural system that can generate the scratches that has controllable parameters like translate, rotate, scale, animation speed, flickering and the amount of scratches!

This will be a three parts tutorials and for the first part, I’ll be covering the process of creating and testing a simple gizmo. Basic knowledge of Nuke are expected but not necessary although why are you visiting this website if not for the Nuke tutorials? ;D

What’s a Gizmo?

Gizmo in Nuke is a node or more accurately, a group that consists of a collection of nodes that are customised to serve a purpose in a pipeline.

Examples: Burn-in WIP dailies, glow effects from specific render matte passes, glitchy macro-blocking artifact effects and etc.

The advantage of gizmo is that the functionalities are self contained provided it is using the default nodes in Nuke so it can be reuse on other workstations provided it is compatible with the Nuke version (this is where the author need to ensure the gizmo are compatible by asking their colleagues or online samaritan for testing).

Here’s some useful links to get an idea about gizmo:

http://www.nukepedia.com/ (a great collection of gizmos although you need to register to download it)

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

http://www.cameroncarson.com/nuke-wave-expressions/

http://help.thefoundry.co.uk/nuke/8.0/content/user_guide/configuring_nuke/creating_sourcing_gizmos.html

http://www.digitalgypsy.com/vfxlog/archives/2007/10/tip-of-the-week-making-a-nuke.php (it’s over 10 years old(!) but a great tutorial which are applicable to the current Nuke release)

Creating the Gizmo Template

Throw in a bunch of nodes and CTRL+G to create the gizmo!

Ok technically it is correct but not the correct way to learn especially if you want to create a usable gizmo.

Steps by Steps

We’ll be creating a simple gizmo that fully desaturates the image and adds a vignette which are configurable.

The following steps will occasionally omits certain details like click this/that and screenshots since I find it redundant. Just pay attention when reading it again if you’re troubleshooting the steps!

  1. Add a Saturation and Vignette (which is a Gizmo itself!) node.
  2. Select both of them and CTRL+G to create the Gizmo. Rename it as tkk_ClassicProjectorLook (or whatever you like as tkk is a shortname for taukeke which act as a namespace for the gizmo in a typical studio pipeline).
  3. Rename Input1 as Source and Input2 as VignetteMask. This will update the label of the input arrows of the gizmo. Refer to the following screenshot to get an idea.
  4. Right-click on an empty space in the tkk_ClassicProjectorLook properties panel and choose Manage User Knobs.
  5. Depending on the situation, it might show up empty or it will have a User value in the list. For the sake of this tutorial, let’s proceed as though it is empty.
  6. Click Add and choose Group from the dropdown list.
  7. Rename both Name and Label as Settings.
  8. Uh oh, suddenly there is a User and endGroup in the list besides Settings. This is not desirable as seen in the Properties screenshot below so delete both Settings and endGroup.

  9. Select User and click on Edit. Rename it as Settings.
  10. Add a Check Box and fill in both Name and Label as Grayscale.
  11. Open the Saturation1 properties and make sure the saturation value is set to 0 (duh) to fully desaturate.
  12. Go to the Node tab of Saturation1 and right click on disable checkbox. Choose Add expression… from the dropdown list.
  13. You can use either !Grayscale or Grayscale == 0 in the Expression field.

    .
    Here’s how it works: Remember the Grayscale checkbox that we created earlier? Since a checkbox is a boolean aka true or false that returns 1 or 0 respectively, the expression is telling Nuke that if Grayscale == 0 (aka unchecked), the disable checkbox are enabled (true).
    .
    This means the Saturation1 node is disable. So if a user checked Grayscale which returns true, the Saturation1 node are no longer disabled since the Grayscale == 0 expression doesn’t match the new value. The !Grayscale is just another way of writing Grayscale == 0 to achieve the same result.
    .
  14. Instead of Add, we going to choose Pick… Pick the following knobs from the screenshot below.
  15. Add a Group and rename it as Vignette. Rearrange it to match the the screenshot below. Basically any knobs in between them belongs to the Vignette group that are collapsible in the Properties panel.
  16. Tada! We’re pretty much done so now we need to test the gizmo…

Testing the Gizmo

Use any valid image as the Source and a roto shape for the VignetteMask.

Proceed to fool around with the various settings that we setup for the gizmo to see if it works. All should be well and if it doesn’t work… back to troubleshooting the gizmo or redo the whole things from scratch!

Things to note:

  • Usually it is best to have both Name and Label to share the same naming. Remember only alphanumeric and underscore!
  • Don’t use spaces for the gizmo node name. Well Nuke will replace it as underscore but I usually prefer to use camelCase naming like NuclearGlow, RainingCatsDogs, InstantRich, etc.
  • To edit the gizmo, just click on the S button on the properties panel as highlighted in the screenshot below.

Next on Creating Gizmo Part 2…

Now that we manage to get a functioning gizmo that does absolutely nothing of value (heh), I’ll be covering the following topics in the next part:

  1. Drawing roto shapes for the scratch mark.
  2. Duplicate roto shapes using multiple transform expression and merge.
  3. Animating the roto shapes with expression.
  4. Using Noise to generate the dust speckles.

In conclusion, we learn the concept of creating a gizmo, adding custom user knobs and using expression to drive/link the knobs with the relevant parameters.

This will give you the foundation to iterate it to achieve the gizmo that are required by the production pipeline or accelerate tedious workflow that reuses dozens of nodes into a user friendly UI!

Coding in VFX and Animation

Coding in VFX and Animation Header

Coding to Improve Your Laziness

For the month of April, I’ll be covering about the use of coding/scripting to improve your productivity in common Digital Content Creation (DCC) like Maya, 3ds Max,  Houdini, Nuke and After Effects etc.

Typically the approach here is more like writing a script to automate the repetitive tasks.

Imagine setting up the render settings, replacing texture paths for every cuts in a production environment for a feature length film BUT having a small team of less than 10 people so manual approach is not practical.

So why work hard when you can be a more productive lazy artist with some coding!

Coding in VFX to Automagically…

The ultimate end goal for any codes (specifically scripts) that we’ll be writing is to let the computer perform the “samey” repetitive tasks.

In the screenshot below, I’ve written a MEL script in Maya which generate a UI Panel that contains many buttons that will execute the functions from an external scripts. The goal here is not only for my personal use but for my FX team members too so they can avoid doing repetitive stuff and spend more time lazing around.

Maya Script Editor and Custom UI Panel

While you can’t write a script to turn back time to tell your old self to learn programming and Nuke (hehe), here are popular examples of what scripting can do:

  1. Replacing all the textures path in a scene file that met a certain criteria
  2. Create folders if doesn’t exists when outputting a geometry cache
  3. Renaming objects names by adding prefix/suffix, version etc
  4. Converting directory path to UNC (Universal Naming Convention) for network rendering
  5. Assign randomize rock materials to dozens of rock geometry
  6. Output WIP in Quicktime format with the date/time as prefix name
  7. Lookup for a specific type of nodes and change the parameter values
  8. Setup the renderer settings with the appropriate values based on project specifications

Here’s an example of a MEL Script that I wrote for an actual project to export the characters geometry cache as FBX 2013 from Maya 2014 to Maya 2013:

Before We Get Started

Before one start to code, it is important to have access to the internet (especially Google and Youtube) when you need to lookup for a problem.

The way I work is to think up what I wanted to automate and start coding the script and execute it.

If there is an error, this is your cue to start look up for that specific error and see what others have to say.

The same goes if you’re trying to figure out a particular method like casting a list of arrays as a specific types. Try it out and obviously you’ll failed if this is your first time. Note the error message and look up with the proper keywords to help narrow down your results.

Having a rudimentary fundamentals in programming language is a plus as it will help in understanding the following:

  • Variables
  • Arrays
  • Functions
  • Syntax

Listen, listen, listen! Or Maybe Not

Depending on the software, it will have a listener which are a great tool in listening to the actions that you performed.

The following GIF example shows the Script Editor in Maya where it prints out the actions when I set up the Vray Render Settings.

Maya Script Editor Listener GIF

3ds Max does have a listener too although personally I think Maya does better in capturing more actions than 3ds Max.

Sadly, this is not true for compositing software like Nuke and After Effects (AE) although the nature of Nuke means majority of the actions/nodes are actually text scripts which you can copy to any text editor where else AE requires the user to code their scripts in Adobe ExtendScript.

Again, the listener will be your best buddy whenever you need to code… if said buddy is available to listen to your complaints.

Did You Know…?

…that coding a script is pretty straightforward despite the lengthy wall of text as seen above.

EXCEPT

When it breaks.

Troubleshooting the error and getting it to work to your requirement is the fun (and stressful) part!

For the next few articles, I’ll be covering practical example as seen in an actual production for Maya, 3ds Max, After Effects and probably Nuke although I haven’t try writing a Python or TCL script for it.

Remember that there are plentiful of great resources to jumpstart your coding skills on the internet and I’m focusing on actual use instead of a step-by-step tutorials.

Happy coding!

Recommended Links

General Coding Practice
https://learnpythonthehardway.org/book/ (A great tutorial for complete newbie to coding for general purpose and it’s Python which are supported by many DCC software!)

MaxScript for 3ds Max
https://www.scriptspot.com/bobo/mxs2/mxs_tut/lesson01.html
https://www.scriptspot.com/bobo/mel2mxs/mel2mxs.htm (For Maya MEL Script to Max MaxScript)

MEL Script for Maya
https://www.csit.parkland.edu/~dbock/Class/csc233/Lecture/MELFundamentals.html
https://github.com/BigRoy/mayaVrayCommandDocs/wiki (this is specific for Vray for Maya but super useful)
https://polygonspixelsandpaint.tumblr.com/post/102799282929 (explains the MEL whatIs command)

2017 and Beyond

Firstly Happy New Year 2017!

2016 has been a major milestones in my career and personal achievements as I’ve survived several situations by sacrificing many of my favourite pastime like writing Nuke/After Effects/Vray/Maya/3dsmax/etc Tips!

Not to forget gaming and drawing…

As 2016 ends in several hours as I’m writing this post, I’ve completed 19 months of working full-time in the Japanese 3DCG industry as a FX artist at a subsidiary studio located in a backwater corrupted “peaceful” country in South East Asia region.

This post will reflect on what I’ve achieved in 2016 and also what I’m looking forward in 2017 and beyond as a FX artist in the high-end visual effects industry.

2016 – In a Nutshell

Many things happened because it already happened! Here’s what happened to me in 2016:

  1. Survived the challenging FX works for Gantz: O! Ironically I’ve haven’t even got the chance to watch the final movie yet.
  2. Mastered majority of Maya and Vray features especially FX, lighting and rendering!
  3. Learned and wrote dozens of MEL Scripts for Maya and Javascript for After Effects to boost productivity.
  4. Scratch a bit of Python to prepare for the inevitable Python scripting for Maya and Nuke.
  5. Reached the summit of Mount Rinjani at Lombok, Indonesia! (and got sunburned super badly-)
  6. Still wondering why the use of Nuke is still not a reality at the studio… After Effects is very clunky when dealing with multi-channel EXR files.
  7. The increase of cost of living in my area = Being way too thrifty since what goes up in meals’ pricing in this country never goes down…
  8. Neglected my gaming and drawing session since my work has been insane with the amount of overtime.

2017 and Beyond!

So the following will be my to-do list for 2017:

  1. Must watch Gantz: O! Need to see my glorious FX works composited with various render layers with audio.
  2. Practice Houdini as the holy Maya, 3dsmax, FumeFX, Realflow combo are not sufficient in the ever demanding VFX works.
  3. Create a new demoreel featuring FX works done in Houdini!
  4. Continue my coding practice especially Python and maybe for fun, C++ for Unreal Engine 4.
  5. Slowly brush up my language skills in Cantonese and Mandarin. Yes, I’m still a banana but a slightly better banana from previous year-
  6. Going on a journey to explore other countries beyond South-East Asia region for the very first time in my life!
  7. Probably I might need to pickup rudimentary French to future proof my living skills.
  8. Resume whatever gaming/drawing that I left in the backburner…

…So What’s Next?

I should hit the publish button and wrap this up–

Being a non-believer in religion and Gods, I don’t really care if something happens because it happens. I believe in creating and seizing the opportunity.

Also the desire to keep learning new stuff (and earning more money too-) is crucial for my personal growth and development since globalisation has exposed me to various stories of other humans who manage to push their limits in raising the bar especially in the realms of VFX and real-time graphics!

While my other tutorials articles still a work in progress since proof reading it takes time, hopefully I can up my guide to MEL Scripting to improve your quality of life when you’re working in a very small facility that lacks a dedicated artist/scripter by the middle of January.

Thanks for all the support and visits to my website!