I want to blur a texture, by putting it in all 4 texture-units, offsetting the texcoords a bit and then averaging the values.
Now, of course i want to blur as efficiently as possible, meaning to reduce the passes needed.
For this i want to use bilinear filtering. However, to be able to really take advantage of bilinear filtering, i have to calculate my texcoords very carefully.
Some ASCII art:
A “T” stands for a texel. An “X” is the intended position of the texture-coordinate.
If my texcoords point to those positions, than every texcoord samples from exactly 4 texels.
Now the question is: What location does a texcoord like (0|0) point to? Is it the center of a texel, or is it a border/corner where 4 texels meet? And does (0|0) point to the same position as (1|1), or is there a difference?
Let´s just take the case of a 3x3 texture. Which coordinates does “X” have in this case:
Is it (1/3 | 1/3) or is it (1/6 | 1/6) ? Or might this position even be (0 | 0) ?
(0;0) will point to the bottom left corner of the texture, just at the edge to the texture border.
Note that this isn’t the sample position. Tex coords are interpolated over primitives, of course, and the texcoord that’s interpolated for the pixel center is the sample position.
Ie, if you render a single-pixel quad and want to cover it with a single texel from a 32x32 texture, this is what you should do: