View Full Version : range of texture coords in rectangle textures
for rectangle textures the texture coordinates are going from 0 to texture's width. But to get a texel in the fragment shader do the texture coordinates go from 0.5 to texwidth-0.5 or from 0 to texwidth-1? That would give exactly texwidth texels, instead of texwidth+1 when going from 0 to texwidth.
Any clarification is appreciated.
05-25-2005, 03:01 AM
Let's look at a single pixel quad to render.
In pixel coordinates the lower left corner of the quad is at (0.0, 0.0) the upper right corner is at (1.0, 1.0).
If you want to texture that pixel with a texture which is also 1 texel of size what would you send?
You send texture coordinates of (0.0, 0.0) and (1.0, 1.0) (== (width, height) with texture rectangles) at the two corners to map the texture on the pixel area.
Now OpenGL's rasterization rules raster at the pixel center, so due to the texcoord interpolation the texture coordinate actually used during the lookup will be (0.5, 0.5) with nearest filtering, which is the center of texels in this mapping.
Things get more complicated when you have linear filtering. Look up the clamping modes in the spec which can be used to not filter texture border colors or texture borders.
Thanks. So, nothing special here, the same behaviour like for 'normal' textures (except the range from 0 to w resp. h)
So, having a (floating point) rectangle texture with dimensions (w,h) (nearest filtering), accessing an element in the fragment shader can then be done for example by rendering a point with texcoord (i,j) where 0 <= i < w, 0 <= j < h.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.