I'm trying to understand the mapping of texels to pixels, especially in the context of pixel shaders. I already found out the following:
When I define a standard quad with vertices at integer positions (texture coordinates ranging from 0 to 1), a pixel shader for the upper left pixel will be called with texture coordinates
When I subtract 0.5 from the vertices' coordinates (as it's recommended when drawing sprites), the pixel shader for the upper left pixel will be called with texture coordinates
My question is about the behaviour of the tex2D function in HLSL:
I would have assumed that it just returns the color of the upper left pixel of the texture when called with texture coordinates of
(0,0). But obviously this is not the case, since the second of the above-mentioned variants actually leads to the desired 1:1 mapping.
So is it correct that
tex2D returns the original pixel values of a texture when given the following texture coordinates?