mapping t and s

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 :

Maybe you can write this down in equations? What is the mapping exactly, if a specific s or t is given?
I can’t really write it down in equations, because it’s really quite complex (and I don’t know what it is). As ZbuffeR suggested, study the OpenGL spec. for what’s important to you. Here’s part of why it is so complicated: there are different types of texture maps (1D, 2D, 3D, cubemap, etc.), there may be mipmap levels, there may be various filterings in play (from anisotropic to nearest to linear, etc.), there may be different interpolation qualifiers (centroid, sample, smooth, flat, noperspective). All of these things interact with each other to make it especially complex. For example, the graphics hardware actually calculates the partial derivatives (in x and in y) in the fragment shader to properly apply texture maps, at least under some circumstances. So, it’s more than just a simple interpolation to calculate the mapping from texture coordinates to texel.

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

Come on.
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.