Category Archives: Math

JPEG compression in nuke (in-line)

I’ve been annoyed with the basic jpeg nuke workflow for a while – the only way to get that magic compression look was to write it out as a jpeg, and then read it back in. So when I discovered blink scripts last week, building this was a great way to learn.

Introducing – JPEGer! Including quality slider, and options for chroma and alpha (jpeg-ing an alpha is untested right now). Interestingly enough, in our testing, the results were identical across multiple machines, so this should be safe for a renderfarm. I’m not sure if it’s coded in the most efficient way, but it seems to only take a few seconds/frame, even on 4k images, which seems workable.

Update 12/8/22 – At some point the Blink syntax changed and the tool started to fail in newer versions of nuke. This has been fixed! [check out this forum post on the nuke dev forum for more info]

Download:

JPEGer Gizmo
tested on Nuke 11/12/13, Win 10

Nuke multiGrad

***updated 3/9/2015

I’ll be the first to admit that I’m no expert on rotoscoping, but in my experience one of the first tools I look for is a multi-gradient – something that I can use to paint out large sections of the image, and then add detail to. So I was surprised that, besides this shake-like 4-point gradient there wasn’t anything in Nuke that was what I wanted. The shake gradient is nice, but I was really looking for one that would allow me to move the points around in space, and would interpolate colors around the points as well as in between. With some patience and a lot of math (point-slope anyone?) I created a gizmo that will do just that. Below you can see the results on a racecar:

Of course, it’s not perfect, and there would need to be fine tuning around the edges, but all the rotoing in that image was done just with this tool. The user pipes in the source image to “Source” and a mask to “matte”, and the gizmo will comp it onto the source automatically, preserving the source alpha (the user can turn this feature off under the “Matte” tab. It also includes python scripting that will automatically grab the color of the source at the points, which makes painting out areas really quick and easy.

Control Panel

Because of the math involved, points 1 & 2 must be at the top, and 3 & 4 at the bottom, or it will start to act screwy. If it needs to rotate, you’re better off translating the whole result.

Download:

4pointgradient.txt
tested on Nuke 9.0v4

Houdini Animation Curves otl

curves

I’ve recently been working on an idea that requires me to do separate luminance values in an image into x discreet “steps”, such as 0-12. However I don’t want to do the distribution linearly (read: equally distributed), I need to account for the fact that luminance is non-linear.

Continue Reading →

Technodolly Focus, Z-Depth, and Lens Distortion

techno_dolly

Any comp lives or dies on subtle qualities of a scene – color, depth of field, lens distortion, etc etc. Solving lens distortion with nuke is pretty easy once you understand the process (and immensely easy if you prepare ahead of time!); without a good lens distortion solve you’ll never get a convincing composite. Depth of field is easier to do a guess-and-check method, but of course we’d much rather get an accurate result. We’ll discuss both, but first a quick overview of the technodolly itself.

Continue Reading →

Luminance Curves

grayscale_curve-perceptual

Often in compositing, I will need to take one set of values and convert it to a different set of values. Say I have a linear image, with luminance values in a range from 0 – 4.589:

Input: Output:
0 0
4.589 1
If I want to do some fancy operation on that image based on it’s luminance, I’ll probably want to convert that range to 0-1, so it’s easier to work with. The easiest and most straight-forward type of conversion is a linear one, of course, where we simply divide all the luminance values by the largest value, giving us a range of values between 0 and 1:

Continue Reading →