LerpVersioned¶
The LerpVersioned kernel demonstrates using the Nuke versioning macros to detect the current Nuke version and adapt functionality accordingly.
// Kernel which changes behaviour based on the current Nuke version
kernel LerpVersioned : ImageComputationKernel<ePixelWise>
{
// Input images for blending
Image<eRead, eAccessPoint, eEdgeClamped> input0;
Image<eRead, eAccessPoint, eEdgeClamped> input1;
// Output image
Image<eWrite> output;
// Blend parameter: range [0, 1]
param:
float blend;
void process()
{
// Read the current pixel from each input image
float4 a = input0();
float4 b = input1();
// Check the current Nuke version
#if kNukeVersionMajorNum >= 16
// Use built-in lerp as it is available
output() = lerp(a, b, blend);
#else
// Manual lerp fallback for older versions
output() = a * (1.0f - blend) + b * blend;
#endif
}
};