I'm having a problem with interpolation on the fragment shader. I'm simply drawing a full-screen quad. The viewport is set to (0, 0, 128, 128).
Each vertex has a texture coordinate.
var textureCoordinates = [
0.0, 1.0,
1.0, 1.0,
0.0, 0.0,
1.0, 0.0
];
I pass the texture coordinate from the vertex shader to the fragment shader via varying variable, which works fine.
vTextureCoord = aTextureCoord;
The issue is that the interpolation starts from 0+halfpixel and ends on 1-halfpixel. Half pixel is (1/128) * 0.5.
I want the interpolation to start from 0 and end on 1. This is because vTextureCoord will be used as an input to a noise function that I have on the fragment shader.
The MAG and MIN filters are both set to NEAREST.
WRAP_S and WRAP_T are set to CLAMP_TO_EDGE.
Please note that the texture coordinate attribute is not a mandatory, it's just my way to interpolate a number from 0 to 1. If there's a simpler way to interpolate a number from 0 to 1 on the fragment shader using something else than an attribute then I'd love to know how!
I've tried to offset the texture coordinates by half pixel, but it doesn't seem to work as I expected.
I also tried to subtract half pixel on the fragment shader, but then the interpolation doesn't end at 1.
newTextureCoord = vTextureCoord - (1.0 / 128.0) * 0.5;
Any tips, comments or feedback are much appreciated!