TexCoords: Where do they EXACTLY point to?


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) ?

Thanks in advance,

i think, if you have GL_REPEAT, at least (and ordinary GL_CLAMP, too…?), your coords you want are

pixel.x = (int)x + .5*(1/width)
pixel.y = (int)y + .5*(1/height)

but i’m so tierd, i’m not sure about anything anymore

Could you just use the next level mipmap of the texture.

(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:


PS: dave is wrong

[This message has been edited by zeckensack (edited 09-10-2003).]

@heath: No, tried that, but the results are crappy.

@zeckensack: Thanks, that clears i up for me.