This code samples the input image at grid-points, and creates a single-pixel horizontal strip.
The idea is to feed the Kernel with a pixellated image, so that every pixel-tile of the input image becomes a single pixel at the output of the kernel.
It’s not meant as an effect in it’s own right. I’ll pass the resulting image through a Crop, and then pass this into the Iterator of the CubeField patch, instead of the full-sized original image.
I’m hoping this will make the whole thing much more efficient, but actually, I’m not certain this is the case. If anyone knows the answer to this one, let me know…
vec2 makeStrip(vec2 xy, float cellWidth, float cellHeight, float cols)
// Calculate Row and Column of pixel to sample
float rowNum = ceil(xy.x / cols);
float colNum = xy.x – ((rowNum – 1.0) * cols);
// Calculate position of pixel to copy
xy.x = colNum * cellWidth;
xy.y = rowNum * cellHeight;
// Return coord for sampler
kernel vec4 main(sampler Image, float CellWidth, float CellHeight, float CellNum, float Cols)
// Current pixel position
vec2 xy = samplerCoord(Image);
vec2 samplePos = (xy.x > CellNum) ? vec2(0.0,0.0) : (xy.y > 1.0) ? vec2(0.0,0.0) : makeStrip(xy, CellWidth, CellHeight, Cols);
return sample(Image, vec2(samplePos));