The culprit is the following line in my HLSL shader:
input.TextureCoordinates0.xy = frac(input.TextureCoordinates0.xy * input.NumTiles.xy);
input.TextureCoordinates1.xy = frac(input.TextureCoordinates1.xy * input.NumTiles.zw);
input.NumTiles is just (1, 1, 1, 1) for this quadrangle (no tiling)
The texture is drawn with the following sampler states:
sampler TextureSampler = sampler_state
{
Texture = <AtlasTexture>;
MinFilter = Point;
MagFilter = Point;
MipFilter = Point;
AddressU = Clamp;
AddressV = Clamp;
};
The texture comes from a texture atlas whose sprites have a gutter region of 2 pixels around them but this shouldn't be of too much concern given that I am avoiding linear filtering.
How can I prevent the texture coordinates from incorrectly wrapping when using frac?