Creating a (viewer) interactive Nuke Gizmo.

February 26, 2017

One of my biggest Nuke-Python requests for TheFoundry, is the ability to grab the mouse X and Y position in the viewer. It would open up a whole new world of interactivity in toolsets, gizmos and custom python scripts. Thanks to a conversation in the Nuke Mailing List and Ben Dickson’s example code i have cooked up a little example tool that utilizes the cursor position to grab data and display a custom UI element.

First of all, i have not yet found a easy way to get the current position of the cursor. So to get around this i use the color sample bounding box to get the position. This however means that you must hold down CTRL to get it. On the upside, it does feel natural and means the user doesn’t trigger it accidentally.

#Get the bbox data
bboxinfo = nuke.activeViewer().node()['colour_sample_bbox'].value()
#Get the aspect of the input. Note that we sample input[0] for the width and height info!
aspect = float(self.node.input(0).width())/float(self.node.input(0).height())
#Convert relative coordinates into x and y coordinates
self.mousePosition = [(bboxinfo[0]*0.5+0.5)*self.node.input(0).width(),(((bboxinfo[1]*0.5)+(0.5/aspect))*aspect)*self.node.input(0).height()]

Then i need to know if the user does a mouseclick. For that i hook the main QApplication instance.
And to make sure that the event only fires when we are inside the actual viewer window, i grab the viewer widget using Ben Dickson’s code.

Now what this tool does, is that it samples the color that are at the cursor position. (I have created a little “dot” inside my gizmo that i call “sampler”.)

sampleR = self.node.node("sampler").sample('red',self.mousePosition[0],self.mousePosition[1])
sampleG = self.node.node("sampler").sample('green',self.mousePosition[0],self.mousePosition[1])
sampleB = self.node.node("sampler").sample('blue',self.mousePosition[0],self.mousePosition[1])

The Blinkscript that does the color manipulation is using a 2d color lattice, that does basic linear interpolation between each point in the grid.

To get the best color seperation for my tool, I use a custom colorspace called HSP. This gives me a good seperation of color, and have e better ratio to luminance compared to HSV and HSL.
So i convert the 3 sample values into HSP space and find point on the color lattice that is nearest to the current sample.
Now using the relative cursor position i manipulate the HSP color data and convert it back into RGB space.

To create the UI element i use a GPUOp node, the node is being enabled every time the user does the Ctrl Click in the viewer and disabled again once the user release again.

Weave for Nuke, beta update.

December 19, 2016

I have been asked quite a few times about updates on the beta of Weave for Nuke, and the Fall 2016 release date. So i thought id’ just do a quick update on that one.



Silk for Nuke available this week.

December 15, 2016


Update: Its available now at Nukepedia


SILK have been on the shelf for a year now, along with a few other tools, but I finally finished it yesterday.  The tool is like a blur, godrays or any other 2d processing effect. You apply it to your footage and it outputs these silk streaks. This video from early last year shows this quite well. I don’t exactly know what it should be used for, but it looks quite interesting, so maybe someone is going to be able to use it for something.

It should be ready on Nukepedia any moment, and hope you can make use of it. (if you can.. please tell me)

Here is a little example video:

And here is a more indepth rundown of the features, most of which is being displayed on a fBm noise:

And the node itself…


This was the original demo posted 10 months ago:

Nuke Point Rendering Engine – Introduction

September 11, 2016

I have hit the wall, trying to create magic effects using points in the Nuke Scanline render a bit too many times. It is slow, does not do anti aliasing and for some reason there are limits to how many points you can have. One example is the particle system that cannot do more than 2 million points per system. That is the reason why i started working on the point render engine, along with the voxel render and weave, as highlighted in my “A Few Updates” post, earlier this year.


The original version was just the point rendering, but it have expanded greatly since that. I am looking forward to tell more about this in the near future, but in the meantime you can see much of the progress on my Twitter. And you are welcome to drop me a line if you have any requests or ideas.

Fractals_04 3drender_fintest_0973drender_fintest_0963drender_fintest_0983drender_fintest_100