// Copyright (c) 2024 The Foundry Visionmongers Ltd. All Rights Reserved.
kernel SpecificationPrintlnKernel: ImageComputationKernel<ePixelWise>
{
Image<eRead> src;
Image<eWrite> dst;
void process(int2 pos)
{
/// The println(int x, int y, args...) call is a print function in Blink used to aid in debugging Blinkscript kernels.
/// The first two x and y arguments are the position in the iteration space to print.
/// Optionally, any number of args... may be passed in afterwards to be printed at the position.
/// The args... are concatenated together after the iteration position and printed with a line separator.
/// The function is only available in the process() kernel method.
/// Arbitrary input to x and y position.
// (5, 5):
println(5, 5);
// Will print for the range of ([0..4], [0..4]):
println(int(min(pos.x, 4)), int(min(pos.y, 4)));
// The following will print out for every point in the iteration space.
// It's recommended to avoid doing this as it will print once for every pixel of the iteration space.
// A 4k image will have roughly 8 million print-outs and will tank Nuke's performance until it is finished.
/// println(pos.x, pos.y);
/// Can print a custom string at a point in the iteration space to help with debugging.
// (0, 0): Hello world!
println(0, 0, "Hello world!");
/// Mix printing of strings with variables to check their values.
// (0, 0): int i = 7
int i = 7;
println(0, 0, "int i = ", i);
// (0, 0): float f = 1.500000
float f = 1.5f;
println(0, 0, "float f = ", f);
// (0, 0): int3 i3 = int3(2, 3, 4)
int3 i3 = int3(2, 3, 4);
println(0, 0, "int3 i3 = ", i3);
// (0, 0): float4 f4 = float4(3.500000, 4.000000, 5.500000, 6.000000)
float4 f4 = float4(3.5f, 4, 5.5f, 6);
println(0, 0, "float4 f4 = ", f4);
/// Print out the result of an expression directly.
/// Note: The values of the following print out may be different depending on the input image.
// (0, 0): src() = float4(2.041630, 2.570306, 2.788087, 2.944974)
println(0, 0, "src() = ", src() + 2);
/// Can easily chain any amount of prints together
/// concatenating arguments separated by a comma.
// (0, 0): src() = float4(2.041630, 2.570306, 2.788087, 2.944974), int i = 7
println(0, 0, "src() = ", src() + 2, ", int i = ", i);
/// Print matrix variable.
// (0, 0): float3x3 = float3x3((1.000000, 2.000000, 3.000000), (4.000000, 5.000000, 6.000000), (7.000000, 8.000000, 9.00000
//0))
float3x3 mat{1, 2, 3, 4, 5, 6, 7, 8, 9};
println(0, 0, "float3x3 = ", mat);
/// Print matrix directly.
// (0, 0): float4x4 = float4x4((1.000000, 2.000000, 3.000000, 4.000000), (5.000000, 6.000000, 7.000000, 8.000000), (9.00000
//0, 10.000000, 11.000000, 12.000000), (13.000000, 14.000000, 15.000000, 16.000000))
println(0, 0, "float4x4 = ", float4x4{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16});
// Copy the input image to the output image.
dst() = src();
}
};