This location is for Registered Users Only.
Perhaps you need to login or register.
Contributor: Nikolai Wüstemann
Website: wuestemann.net
Nuke implementation for 2D Gradients. Create an arbitrary number of color-samples in 2D and produce a smooth, natural interpolation over the entire image.
Requirements:
11.0, 10.5, 10.0, 9.0, 8.0 or later
Linux, Mac, Windows
28 Oct 2019
1938

Nuke implementation for 2D Gradients. Proof of Concept.

Create an arbitrary number of color-samples in 2D and produce a smooth, natural interpolation over the entire image.

The Gizmo uses Natural Neigbor Interpolation to calculate the pixels inbetween samples, using Blinkscripts.

You can also output the underlying Voronoi Diagram or play with the smoothness value to control the amount of the softening (0 = Voronoi Diagram, 1 = Accurate Natural Neighbor Interpolation).

Another important function is the ability to sample input colors, instead of defining them yourself. Setting the Type to 'Sample' uses all created points to sample the input colors at given positions. Furthermore you can use the 'Fill' Type to interpolate missing information in any image. A premultipied input is required for this.

Changing the Colorspace will change the color falloff. This can be used to achieve the best artistic result. Setting the Colorspace to HSV for example, will interpolate the colors over the spectrum.

There are several tricks and hacks used in this Gizmo to make it work, so please report any bugs you find, I am sure there still are some.
The user knobs and the inside of the gizmo are well documented to help with understanding the concept.
(The algorithm implemented is not the elegant geometric process, but a simple brute-force method, which was easy to implement. This however makes the tool super slow and you might wanna use the speed optimization control to make it a little bit faster at the cost of some quality. That's why I would still consider the whole thing a proof of concept. Although, with my update to v2.7 I'd say we are production ready now :) )

Example 1:
Creating the NNI or respective Voronoi Diagram via feature points

Example 2:
Using the Sample Type to generate a cleanplate

Example 3:
Using the Fill Type to fill in missing information (driven by alpha)

Example 4:
Using the Fill Type to generate a cleanplate

Update to 2.7 (2019-10-28)
Fully reworked feature point value forwading to BlinkScript. For the 4th time. Animation of Feature Points not buggy anymore. (hopefully)
- Minor update to the UI

Update to 2.6 (2019-10-06)
- Fixed a bug that prevented the smoothness setting to be applied to the Fill mode
- Minor Speed Improvements for the Fill mode

- Works now with aspect ratios other than 1
- Updated the description above with more examples

Update to 2.5 (2019-10-05)
- Fully reworked feature point value forwading to BlinkScript. No point limit anymore.
- Updated a few knob labels, defaults, etc.

Update to 2.4 (2019-09-07)
- Added Smoothness parameter to the NNI

Update to 2.3 (2019-09-07)
- Fixed a GPU related bug in the SetPoints Blinkscript

Update to 2.1 (2019-09-01)
- Fixed a namespace bug
- Added pointcount to the UI

Update to 2.0 (2019-08-31)
- Reworked the core
- Points can be animated now, but this introduced a limit of 50 points for now (100 points broke the Blinkscript)
- the sample functionality is now handled by a blinkscript and not a TCL expression, which makes it more stable

Update to 1.2
- Fixed another Expression I forgot in 1.1

Update to 1.1
- Fixed the string separator declarations for some Expressions from ',' to

0 # Frank Rueter 2019-05-02 22:32
This is awesome, been wanting this in Nuke forever.
Two things though:
-the "to" points shoe up in the viewer but they don't do anything?!
-it'd be great to implement the "Magic Carpet" functionality of sampling the incoming area under the respective point for the colour rather than having to set it manually.

A plugin version of this would be great to make it a bit faster.

0 # Nikolai Wüstemann 2019-05-02 23:28

The sample functionality is already implemented, just change the Type parameter to Sample :)

What do you mean with "to" points. I expect the viewer to look like the one in the screenshot above.

A plugin would be faster indeed, but the problem lies within the algorithm. My code is short, clean and slow
There is a way faster method to calculate the pixels, but its implementation is really hard, so instead I used the brute-force approach, that scales quadratically with image size. In order to reduce the processing time to less than 1s I added the optimization parameter. If you crank that up it will be a lot faster.

0 # Nikolai Wüstemann 2019-05-02 23:30
If you encounter any bugs or problems, please report!
The whole setup is quite experimental and uses a lot of tricks/hacks in different places, I don't even know how it works on another system.

0 # Frank Rueter 2019-05-03 00:21
Great. please ignore me, pre-coffee idiocy made me write this stupid comment :-D
Indeed, it's all there and the "to" points in the viewer was user error.
Awesome, this will be a great supplement for IBK workflows, thanks!

0 # Nikolai Wüstemann 2019-05-03 08:06
You're welcome :)
I hope it will be a simple method to generate cleanplates for keying. Right now I am working on a variation of this tool, to fill in missing information (= black alpha) in an image. This is pretty straightforward , but takes even longer to calculate. As long as I don't come up with speed improvements in the Blinkscript itself.

+1 # Hendrik Proosa 2019-05-03 10:58
I get an error in Sample mode:

Also it seems that animated points are not properly evaluated, image is not refreshed even when I force-refresh and clear cache.

0 # Nikolai Wüstemann 2019-05-03 12:40
Ahh I guess splitting a string does not need quotation marks for the separator. What Nuke Version are you using anyway? I sill need to test a lot tho.

0 # Hendrik Proosa 2019-05-03 13:40
I tried it in Nuke 10.5v5, Windows 7

0 # Nikolai Wüstemann 2019-05-04 12:37
I fixed the Expressions, I hope this issue is gone now.

0 # Mohamed Abuzeid 2019-05-03 18:47
it's not working here also with sample mode . no result just black result .
working with Nuke 10.5

0 # bin zhuang 2019-05-05 02:33
+1

0 # Nikolai Wüstemann 2019-05-05 12:24
Try downloading the current Version, I did some fixes. If the problem still exists, look up the script editor or the console and post the error message here, thank you :)

+1 # Mohamed Abuzeid 2019-05-06 21:34
ERROR: VoronoiGradient 2.Expression_Sa mpleColor.temp_ expr3: Unexpected '"' in '[sample [node sample_image] alpha [value this.parent.pos _[lindex [split [value this.parent.poi nts] ","] [frame]].x] [value this.parent.pos _[lindex [split [value this.parent.poi nts] ,] [frame]].y]] '

0 # Nikolai Wüstemann 2019-05-07 08:07
Thank you for reporting the error, I just did an update to fix this! 1.2 is available now!

0 # Mohamed Abuzeid 2019-05-07 19:12
still not working in sample mode .

ERROR: VoronoiGradient 1.Expression_Ge nerateColor.tem p_expr3: Nothing named 'Nothing' in '[value this.parent.col or_[lindex [split [value this.parent.poi nts] ,] [frame]].a]'

0 # Craig Sylvester 2019-07-16 18:14
Hi. Would like to use this in production, but we're seeing intermittent Expression errors in non-GUI (farm) renders:

Warning: VoronoiGradient 1.SampleBlur: [Blur] Abort/cancel checked with no valid trees. This op most likely needs to have its parent set correctly.
ERROR: VoronoiGradient 1.Expression_Sa mpleColor.temp_ expr0: Nothing named 'Nothing' in '[sample [node sample_image] red [value this.parent.pos _[lindex [split [value this.parent.poi nts] ,] [frame]].x] [value this.parent.pos _[lindex [split [value this.parent.poi nts] ,] [frame]].y]] '

If you have any insight in to this error I'd appreciate the help. I'm also happy to send you files.

+1 # Alexey Kuchinski 2019-05-05 12:55
worked perfectly well on 11.3 linux!
thanks!

0 # darren coombes 2019-05-17 02:49
Could a quality knob speed things up for super quick sampling?
Apart from that, amazing!!

0 # Nikolai Wüstemann 2019-07-02 09:35
The "Optimizaton" knob does this kind of thing. Basically it reformats to a smaller size, does the calculations and scales up again. I'm using the Brutforce method of the Natural Neighbor Interpolation, which scales quadratically in time with frame resolution. All some dirty work

0 # Matthias Wäsch 2019-06-27 10:02
sample mode is still not working with nuke 10.0v6, but works with nuke 11.3v3

0 # Nikolai Wüstemann 2019-07-02 09:32
Thanks, I'll check it out for the next Version!

0 # darren coombes 2019-07-02 01:12
Does this sample per frame?
I'm using to try to create a cleanplate of a light on a stage with varying lighting changes, but need to remove some empty seats. Can't seem to get it working to sample per frame.

0 # Nikolai Wüstemann 2019-07-02 09:31
Hey, yes, this is still an issue related to the nature of Blinkscripts in Nuke. I will fix this in the next version on the "cost" of arbitrarily many sample points. This whole gizmo is a proof of concept anyway, and I'm not happy with the limitations it has right now.

0 # paddy eason 2019-09-12 09:52
Hi. No joy here. It think for a while, but it doesn't generate anything other than black. Error message is -

0 # Nikolai Wüstemann 2019-09-13 06:47
Hey, what version and OS are you using?
I tested Nuke 8.0 on Win and Nuke 10.1 on Linux so far.
If there is an error with the SetPoints I might need to build in more failsafe checks I guess...

+1 # paddy eason 2019-09-13 12:46
Hi. Nuke11.3v4 on Linux Centos 7.

Cheers...

0 # Nikolai Wüstemann 2019-09-13 13:18
I see, I'll fix the issue.
Tested it on 11.4 Centos 7 just now and it works fine. The knob does not evaluate though l, which is probably causing your error. It seems that some workspace configurations are more sensitive than others.

0 # Nikolai Wüstemann 2019-10-05 00:06
This problem should be fixed now :)
I replaced the whole part where I feed the sample points into the BlinkScript with a completely different and more elegant method.

+1 # Mads Hagbarth Damsbo 2019-10-07 11:43
really nice and solid release!

0 # Nikolai Wüstemann 2019-10-07 22:29

+1 # Frank Rueter 2019-10-08 23:25
Awesome work! This is gonna show up in lots of my comps for sure!

0 # Brian Tatosky 2019-10-10 23:39
Anyone on Linux 10.5v7 having trouble getting the colors to animate over time? I set keyframes for each, they seem to update when I click on different frames, but when I try to flipbook or render, they just render the last frame that I clicked on, or the first keyframe's dettings.

0 # Nikolai Wüstemann 2019-10-13 14:17
Hey there, thanks for reporting this bug. I had a look into it and it seems that some Nuke Versions don't evaluate my setup in the desired way. I am currently working on this issue but I don't know when I will come up with a solution.

0 # Brian Tatosky 2019-10-13 18:36
You're welcome! It's a great tool; leave it to me to go right to a rare case! :)

If I can, I'll try it on a Nuke 11 build and see what happens

0 # Nikolai Wüstemann 2019-10-28 21:52
Hey Brian,
I just did an update with some major improvements and animating the points should not be buggy anyore. Tested on Nuke 8.0 on Win and Nuke 10.1 on Centos7, both locally and on th farm.
Would be great to hear if it works for you! :)

+1 # Brian Tatosky 2019-10-29 18:29
Works GREAT now! Thank you very much!

I have so many places to use this.

0 # Frank Rueter 2019-10-22 22:23
the sample mode seems broken in v2.6 It samples only when the node is created but not when the points are moved.

0 # Nikolai Wüstemann 2019-10-28 21:56
I fully reworked the point data forwading in the new version 2.7 (for the 4th time now lol) and I'm quite happy with the result. I now use clean, direct TCL instead of indirect python or other weird ideas I had before. Hope it works for you :)

+1 # Frank Rueter 2019-10-29 23:42
brilliant, easily one of my all time favourite tools

0 # Roman Melnyk 2019-11-13 16:40
Hi, I just downloaded the gizmo but it says there's an error, BlinkScript unknown command....Cant render from that. Node.
I'm on non comercial Nuke 11 3.5

0 # Nikolai Wüstemann 2019-11-13 22:26
Hey, "The WriteGeo, Primatte, Ultimatte, BlinkScript, and GenerateLUT nodes are disabled." This is from the Nuke Non-commercial website. Consequently, using the Gizmo will not work.

+1 # Olivier B 2020-11-04 01:29
Great tool, well done! Really handy!

0 # darren coombes 2021-02-18 04:17
Getting an Issue (Windows) using Gizmo v2.7
Adding extra points, adds them in an extra Tab and make them only visible when that tab selected, rather than all points being seen at same time.

0 # Nikolai Wüstemann 2021-06-10 12:57
Hey, thanks for pointing hat out! I had a similar issue in the past when multiple Nodes of this exist. It is because I just add the point knobs to the end of everything. In the next version I will have a look into that problem, should not be too hard to fix.

+1 # Norman Cates 2021-06-10 08:50
Awesome to see this tool. I want to make some changes but I really don't understand at all whats going on under the hood.

Now, I am very new to Blink scripts, and C++ is a language I have almost no experience with... So some of my confusion may stem from that. I'm trying to use my desire to make changes to this to learn Blink scripts, and whatever of C++ I may need to.

In a previous version, you set up a array of points that appeared in one of the Blink nodes. But in this version, I can't find that Blink script node. The points just seem to appear by magic.

Where are those points set?

Indeed, HOW are those points added? The Add Point button has no script on it to create anything. I get the impression that he Expression nodes are refering to a points array somehow. But where and how does that exist?

In general I think I'm getting the shape that the Expressions for SetPosition and SetColour use the number of points to create a visual index (as it were) of x,y coordinates on the left side, and the RGBA values on the right side. As shown on the PostageStamp_SamplePoints.

I suspect I'm also getting confused by the TCL in the Expressions. I just dont understand what they are referring to with the points. MInd you, TCL has only ever been something I dipped into as needed, and the syntax is very different from other languages I've learned. Parsing the expressions is doing my head in.

I realise you can only comment to a certain level of experience. But if there were any more explanations you could throw in, that would be really helpful.

Thanks

0 # Nikolai Wüstemann 2021-06-10 12:46
Hey Norman,
Thanks for your interest!! I will try to clarify as good as I can. You got most of the assumptions right :)

In earlier versions I used different methods for feeding the point data (rgb and position) to the Blinkscript. Each of those methods had flaws and restrictions, so I had to come up with something new. The idea is, to generate a looong expression, that writes these values to a visual array. This would look like this for the red channel:

x==0&&y==0 ? point1.red : [...]

If the pixel coordinate is 0,0 then use the red value of the color knob "point1" in the UI. After the : we continue writing more exceptions, one for each point. For 3 points, it would look like this:

x==0&&y==0 ? point1.red : x==0&&y==1 ? point2.red : x==0&&y==2 ? point3.red : 0

It basically is a command chain of instructions to write all point data to the image. Now this is what the Expression node has to evaluate in the end. But I don't know how many points there will be or if there will be deleted points, so I need to generate this expression chain on the fly. I do this using a multiline TCL script. These are not documented by The Foundry anywhere I guess, but there are plenty of references online that do not need to be in context with Nuke. There is actually a lot more possible with TCL than is documented or written in tutorials.
In the UI of the Tool I have a hidden knob that stores an index list of all points that currently exist/were created by the user. This list is updated via python every time the user adds or deletes a point. (These functions are defined within the onKnobChanged event, not the button itself, since I did not want to the Tool size grow with more points added and each of them containig a whole script to delete this button. So it is generalized in the knobChange event)
In the multiline TCL within the Expression node i take this list and loop through it with a "foreach" command, looking up the corresponding point rgb and position data. Within each foreach loop I add an expression to the command chain mentioned above. So under the hood Nuke FIRST evaluates the TCL that produced the command chain. THEN it evaluates the generated chain/expressio n. This allows us now to have as many points as we want and even have them animated, because the expression is forced to evaluate every frame. I was very lucky that the Expression node allowed all these shenanigans.

For how to approach Blink, I think it needs a lot of trial and error. The documentation is bad and there is almost no way to debug. I learned a lot by looking at other Blinkscripts and nowadays there are better tutorials online.

0 # Norman Cates 2021-06-11 00:18

I am also learning more about callbacks in Nuke. I've dabbled around the edges with Python and TCL so I'm extending myself into areas that seem dark and scary.

What I'm stumbling up against is that I can't see the Python in the call back while in Nuke. I can only see it by copying the group, then pasting into a text editor. And the Python is all on one line, with "\n" for the line breaks.

I attempted a browse through the developer docs and the main Nuke docs, but I couldn't see any way of managing these callbacks, other than using a method to populate the knobChanged callback. And certainly no way of working with the Python already in the callback.

I hope I'm missing something. Otherwise it seems like The Foundry have made these things more difficult than they need to be.

Also very glad to be pointed at good tutorials / docs that give good insight into this.

0 # Nikolai Wüstemann 2021-06-11 07:44
You are not missing anything, there simply is no way to view or edit the knobChanged event in Nuke. LUCKILY there are great people in the community who fill in these missing things. Have a look at KnobScripter by Adrian Pueyo: http://www.nukepedia.com/python/ui/knobscripter
This is a must have when attempting scripting in Nuke.

0 # Norman Cates 2021-06-11 08:31
Hah! I literally just came across that. Looks like a great addition to the scripting toolset

0 # George Melesanakis 2022-05-24 06:51
Hello I am getting an Error compilling kernerl for GPU. Is there any way to bypass it? Thanks

0 # Nikolai Wüstemann 2022-05-24 07:02
Hi George, what Nuke Version are you using and which OS? I did not have this issue in a long time.

0 # Max Rodas 2023-01-12 17:16
I'm having this exact issue, the only thing I've change is I updated the video card from a 2070 to a 4090(big update :)), and the comp I had working now gives me this compiling kernel for GPU error

0 # Nikolai Wüstemann 2023-01-12 17:32
Hey,
I am not quite sure why this is happening between cards, but until I can find the time to update the tool (and also introduce some new features) you can try to go inside the group and find the Blinkscript Node(s) and turn off "Use GPU if available" checkbox under the Kernel Parameters. Also it would help a lot if you find out, which of the 3 Blinkscripts throws the error.

0 # Max Rodas 2023-01-20 00:43
Thanks for the advice, it make it work, I think the 3 blinkscrips have the issue, but since one of them is disable by default so only had to do it in BlinkScript_Vor onoiDiagram and BlinkScript_Nat uralNeighborInt erpolation and started working. Thanks man, really useful tool.

0 # Max Rodas 2023-01-12 17:18
In case is usefull to you, I'm on windows 11, nuke 14 indie

0 # darren coombes 2024-04-18 07:15
would be great to have it add a point at each click in the viewer and grab the location of that click as well, so you don't have to add a point an manually drag each time

You have no rights to post comments

We have 2860 guests and 50 members online