You are here: User Guide > NukeX > Using the BlinkScript Node > Editing Kernels

Editing Kernels

You can edit existing kernels or write your own from scratch by clicking Clear and entering code in the Kernel Source field. Bear in mind that you won't see any results in the Viewer until you click Recompile.

TIP:  You can change how text in the Kernel Source appears using the controls in the Preferences > Script Editor tab. After saving your preferences, close and then re-open the BlinkScript properties panel to apply the changes.

The first line in a kernel is always a declaration, similar to a C++ class and derived from ImageComputationKernel, which describes a kernel used to produce an output image. In the case of the default InvertKernel:

kernel InvertKernel : ImageComputationKernel<eComponentWise>

Parameters for the kernel are declared in the param section, in the same way as you would declare member variables in a C++ class. If your kernel doesn’t require any parameters, you can omit this section.

For example, the InvertKernel has a single parameter, multiply:

param:

float multiply; //This parameter is made available to the user.

When a kernel is compiled inside the BlinkScript node, controls are generated for each of the kernel’s parameters and added to the Kernel Parameters tab. In the case of InvertKernel, the node has just one custom parameter, Multiply.

Kernel parameters can be C++ built-in types such as float or int. Vector and matrix parameters are also supported. The following table contains the control types that the Kernel Source can expose on the Kernel Parameters tab in the properties panel.

Control Type

Description

Bool_knob

Parameters of type bool are represented by a Bool_knob, or single checkbox.

Int_knob

Parameters of type int generate an Int_knob with a single numeric input box. Right-clicking in the input box displays a menu allowing you to animate the value.

MultiInt_knob

Parameters of type int2, int3, int4, or int[ ] generate a MultiInt_knob, with multiple numeric input boxes. As with the Int_knob, right-clicking in the input boxes displays a menu allowing you to animate the values.

Float_knob

Parameters of type float generate a Float_knob with a numeric input box, linear slider, and animation menu button. The slider ranges from 0 to twice the default value of the parameter, or 0 to 1 if no default value is set.

XY_knob

Parameters with two floating-point values, types float2 or float[2], are interpreted as positions in 2D space and generate an XY_knob with an adjustable handle in the Viewer.

XYZ_knob

Parameters with three floating-point values, types float3 or float[3], are interpreted as positions in 3D space and generate an XYZ_knob with an adjustable handle in the 3D Viewer.

AColor_knob

Parameters with four floating-point values, type float4 or float[4], are interpreted as colors with alpha, and generate an AColor_knob. This initially displays a single entry box and slider, a button to split to four entry boxes, a button to display the Nuke color wheel, and a swatch showing the current color with an eyedropper for sampling in the Viewer.

Array_knob

Parameters with nine floating-point values, including float3x3, are displayed as an Array_knob with a 3x3 grid. Parameters with sixteen floating-point values, including float4x4, are displayed as an Array_knob with a 4x4 grid.

MultiFloat_knob

Parameters with numbers of floating-point values not already listed above, such as float[5], generate a MultiFloat_knob with a numerical entry box for each value, a single linear slider, and an animation menu button. The slider ranges from 0 to 1.

The rest of the kernel is up to you, within certain guidelines listed in Nuke's Help menu under Documentation > Guide to Writing Blink Kernels or at http://docs.thefoundry.co.uk/nuke/80/BlinkKernels/. There are also several example kernels to get you started.