Bilinear Filtering

This topic is 3793 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello, in order to understand some DX SDK code I need to unterstand bilinear filtering. I have understood the theory, but I can't find a working equation for texture filtering. The wikipedia article ( Bilinear Filtering ) has some sample code to demonstrate bilinear filtering. But something surprises me: Their texture coordinates ALWAYS pick the top left texel of the four sample texel. So for example texture coordiantes of (3.7, 4.8) pick texel (3, 8) and this is the top left texel. The other texels are (4,8), (3,9) and (4,9). But also a texture coordinate of (3.1, 4.2) would select the same 4 texels, even though the texels above and left to texel (3,4) are closer to the texture coordinate sample point! So is the wiki code just a very simple version of bilinear filtering? Has anyone a good explanation of bilinear filtering for textures?

Share on other sites
Bilinear filtering isn't so bad. If you imagine four points in a rectangular arrangement, then two are on the top and two are on the bottom. You linearly interpolate between the top two points by some factor u, linearly interpolate between the bottom two points by the same factor u, and then interpolate between the results of those previous interpolations by a second factor v.

Share on other sites
Well, thanks for your answer, but actually you did not answer my question. As I already said I have understood the theory of bilinear filtering.
My question was if the texel, where the texture coordintes are placed, (for example texel (3,4) if the tex coords are (3.6, 3.7) is ALWAYS the top left texel of the 4 sampling texels (like in the wikipedia article). This is kinda strange to me, cause if you have tex coords of (3.1, 4.1) the 3 texels above and left to texel (3.4) are closer so it would make more sense that texel (3,4) is the top right texel of the 4 sample texels. Hm.. :/

Share on other sites
I think you've mixed something up with your v coords, where do you get 8 and 9 from given a value of 4.8?

the code in the wiki floors both the u and v's so from (3.7,4.8) you get integer coords (3,4) and the other texels read are (4,4) (3,5) (4,5)

And yes, (3.1,4.2) will select the same texels to read from as the point lies within the same box of 4 texels.

Share on other sites
I think the thing that you're asking about is how texel values map to texels, spatially. The math you're describing assumes that the integer UV coordinates map to the centers of texels (not the upper-left corner). In that case, it makes sense (and is correct).

1. 1
2. 2
3. 3
4. 4
Rutin
21
5. 5

• 9
• 13
• 19
• 14
• 9
• Forum Statistics

• Total Topics
632938
• Total Posts
3009318
• Who's Online (See full list)

There are no registered users currently online

×