Changing CIKernel sampler coord causes chaos

I feel like I'm missing something really simple. I've got the simplest possible CIKernel, it looks like this:

extern "C" float4 Simple(coreimage::sampler s) {
    float2 current = s.coord();
    float2 anotherCoord = float2(current.x + 1.0, current.y);
    float4 sample = s.sample(anotherCoord);  // s.sample(current) works fine
    return sample;
}

It's (in my mind) incrementing the x position of the sampler by 1 and sampling the neighboring pixel. What I get in practice is a bunch of banded garbage (pictured below.) The sampler seems to be pretty much undocumented, so I have no idea whether I'm incrementing by the right amount to advance one pixel. The weird banding is still present if I clamp anootherCoord to s.extent() but it behaves normally if I sample s.coord() unchanged. I'm trying to write a box blur that samples / averages neighboring pixels and am completely blocked by this. What am I missing?

The texture coordinates are normalized by default, so each component goes from 0 to 1. (0,0) would be in the top left. These coordinates either wrap, repeat or clamp depending on the sampler.

I think what you are trying to do is sample one pixel over. For that, you would need to add 1 / width or 1 / height of the texture you are trying to sample.

Alternatively, if you don't need to actually sample it, you could read it at pixel coordinates, where +1 would actually work.

For the heck of it, I just tried your kennel out and it worked as expected on my end (sampling one pixel over on the x axis). I've got the kernel stuck in the middle of a pipeline though, including a crop. I wonder if you crop the incoming image, or the outgoing image, if that would help things (using CICrop).

Changing CIKernel sampler coord causes chaos
 
 
Q