I’d like to know to which texel specific t and s values map to. Let’s take s, for example:
s x (texel)
0 -> .5
1 -> width (outside of texture)
Is the mapping correct? It seems odd.
I’ve tried to find the mapping in the GL specs, but failed. Maybe you can give a reference?
The texture mapping is parametric; 0 (not -1) maps to the left or bottom, 1 maps to the right or top.
Maybe you can write this down in equations? What is the mapping exactly, if a specific s or t is given?
If you want exact equation, that should be detailed in the GL spec :
One more thing I should add: only fragment shaders access texture maps with all the complexity I described above. The other shaders can’t access mipmaps, for example, because it only makes sense in a context of window coordinates to make such a mapping.
So, the mapping from texture coordinates to texel is considerably simpler in the non-fragment shaders.
Well, as I wrote down, I’ve already studied the specs and got nowhere. I don’t really care much about filtering: the filters average texels in the neighborhood of a specific texel. So you can assume GL_NEAREST filtering. But you wrote down you didn’t know anyway so… I think s = 1, can’t point to the last texel in the column. I think it’s the edge between the last and the one outside the texture, if it gets clamped on the last, that’s GL’s thing.
I’ve already studied the specs and got nowhere
Quick check, on glspec 2.1, page numbered 160 (pdf page 174) you even have a nice diagram in figure 3.10 …
Yeah, you’ve got it. 0,0 is the bottom left corner of the bottom left texel. 1,1 is the top-right corner of the top-right texel.
So texel edge coords are 0/N, 1/N, … N/N, and texel centers are 0.5/N, 1.5/N, … (N-1+0.5)/N. The texel data value being considered to be at the center of the texel. See the diagram Z-buffer pointed you two in the spec.
While true that answers to many questions are in the spec, I do remember the day when when sifting through it was a bit daunting and finding what I want didn’t always happen very fast. Having a good dose of GL experience and contextual knowledge (and knowing the standard names for things) works wonders. Don’t get discouraged. Just dive in and search. It gets easier fast.
Thanks for all answers. I am very grateful. It is indeed hard when you look for a simple answer like this in the specs and all you see are partial derivatives.