title: GLSL texture coordinate to absolute pixel?
body: <p>my question regards how a texturecoordinate exactly maps to texel in a texture (not taking into consideration filtering).</p>
  
  <p>does (0,0) for example refere to the top left corner of the top left pixel or does it refere to the center of the top left pixel?</p>
  
  <p>if using near-filtering, what pixel is fetched at the texture coordinate (0.5,0.5)?</p>
  
  <p>what about (1.0,1.0), does it refere to the bottom-right corner of the bottom-right pixel or rather the top-left corner of the bottom-right pixel? (i can recall that some years ago this differed between some ATI and NVIDIA cards. is it now standardized?)</p>
  
  <p>if using texelFetch() instead of textureLod(), what's the correct way to access the pixel?</p>
  
  <p>is it</p>
  
  <pre><code>ivec2 size = textureSize(sampler,0);
  ivec2 iCoords = ivec2(int(uv.x*size.x),int(uv.y*size.y));
  vec4 col = texelFetch(sampler,iCoords);
  </code></pre>
  
  <p>or is maybe</p>
  
  <pre><code>ivec2 iCoords = ivec2(int(uv.x*size.x+0.5f),int(uv.y*size.y+0.5f));
  </code></pre>
  
  <p>correct?</p>
  
  <p>or even</p>
  
  <pre><code>ivec2 iCoords = ivec2(int(uv.x*(size.x+1)),int(uv.y*(size.y+1)));
  </code></pre>
  
  <p>?</p>
  
  <p>maybe someone can clarify how the mapping exactly works?</p>