BlinkScript
The BlinkScript node runs Foundry's Blink framework enabling us to write our code once and run it on any supported device. This is achieved through code translation, in which the Blink code is turned into specific code for each target device. Code is generated and compiled on-the-fly, allowing you to switch between devices at will.
BlinkScript runs a Blink "kernel" over every pixel in the output, where a Blink kernel is similar to a C++ class, but with some special parameter types and functions. Through translation, the code in the BlinkScript node can be turned into normal C++ or SIMD code for the CPU, or OpenCL for the GPU.
The Blink framework streamlines plug-in development workflow significantly, as you no longer have to exit Nuke to compile your code.
Note: To use the GPU when rendering from the command line, add --gpu to your command. For more information on GPU support, see the Release Notes for your version of Nuke.
You can publish kernels in Group nodes which can then be saved as gizmos, if required. Published kernels can be encoded to protect your IP using BlinkScript's built-in kernel protection. Protected kernels are not readable when the published node is saved to a script.
Warning: BlinkScript is very flexible, as there are no restrictions on the code you can write within a kernel. As a result, code complied from the Kernel Source can cause Nuke to crash, so please use caution!
Inputs and Controls
Connection Type |
Connection Name |
Function |
Input |
src |
The image to which the BlinkScript kernel is applied. |
Control (UI) |
Knob (Scripting) |
Default Value |
Function |
BlinkScript Tab |
|||
Kernel File |
kernelSourceFile |
none |
Sets the file path of the kernel used for Load and Save operations. BlinkScript kernels use the .rpp file extension. |
Load |
reloadKernelSourceFile |
N/A |
Click to load and compile the kernel specified in the Kernel File field. |
Save |
saveKernelFile |
N/A |
Click to save the current kernel to the location and file name specified in the Kernel File field. |
Clear |
clearKernelSource |
N/A |
Click to clear the Kernel Editor. |
Recompile |
recompile |
N/A |
Click to recompile the kernel currently in the Kernel Editor. Any compile errors present are displayed on screen. |
Kernel Source |
|||
Kernel Editor |
kernelSource |
SaturationKernel |
Enter the kernel you intend to compile or edit the default SaturationKernel to suit your purposes. Click the Recompile button to see the result of any changes. |
Kernel Parameters Tab |
|||
Local GPU |
gpuName |
N/A |
Displays the GPU used for rendering when Use GPU if available is enabled. Local GPU displays Not available when: • Use CPU is selected as the default blink device in the Preferences. • no suitable GPU was found on your system. • it was not possible to create a context for processing on the selected GPU, such as when there is not enough free memory available on the GPU. You can select a different GPU, if available, by navigating to the Preferences and selecting an alternative from the default blink device dropdown. Note: Selecting a different GPU requires you to restart Nuke before the change takes effect. |
Use GPU if available |
useGPUIfAvailable |
enabled |
When enabled, rendering occurs on the Local GPU specified, if available, rather than the CPU. Note: Enabling this option with no local GPU allows the script to run on the GPU whenever the script is opened on a machine that does have a GPU available.
|
Vectorize on CPU |
vectorize |
enabled |
When enabled, use SIMD instructions on the CPU where possible. Note: This is currently an experimental feature and vectorization might fail for some valid Blink kernels. |
Saturation |
SaturationKernel_Saturation |
1.2 |
Adjusts the result of the SaturationKernel by this factor. Note: Saturation is the only control exposed by the default SaturationKernel. For more information on writing kernels and some examples, see Help > Documentation. |
Publish |
publishButton |
N/A |
Click to create a Group node containing a copy of the current node. The Group can then be saved as a gizmo. The kernel parameters and GPU controls are exposed as user controls in the published version of the node. |
Protect kernel |
protectKernel |
disabled |
When enabled, the kernel in the published group is encoded and is not readable when the published node is written to a script. |
format |
format |
Dependent on Project Settings |
Sets the output format when Specify output format is enabled, but otherwise defaults to the input format size. |
Specify output format |
specifiedFormat |
disabled |
When enabled, allows you to set the output format using the format control. Enabling this control also exposes the format dropdown in the published Group node. |