To solve it let's use anisotropic texture filtering.
By default I were using trilinear filtering - because used BasicEffect sets linear interpolation for both texture sampling and mip map selection. The blurry artifact that I mentioned (see picture below) is caused by the way how mip mapping works: let's say we have a square shape (with "square-like" texture coordinates) but it gets rendered with a lot larger width than height (in screen space) because of the camera view angle.
The used mip map (mip maps in case of trilinear filt.) gets selected based on the smaller dimension - in our example the height. Because mip maps are squares (width=height) the larger dimension of our shape - the width - "gets" less texels (from texture) thus they need to be stretched. Hence the blurry look.
One could ask: why don't we choose a mip map based on the larger dimension? In that case we would have flickering and aliasing along the smaller dimension which was one of the reasons to create mip maps (second is to gain performance).
The used mip map (mip maps in case of trilinear filt.) gets selected based on the smaller dimension - in our example the height. Because mip maps are squares (width=height) the larger dimension of our shape - the width - "gets" less texels (from texture) thus they need to be stretched. Hence the blurry look.
One could ask: why don't we choose a mip map based on the larger dimension? In that case we would have flickering and aliasing along the smaller dimension which was one of the reasons to create mip maps (second is to gain performance).
Blurry result |
This is how it should be (sharper) |
That is, the sampling area in the texture has different width and height (its dimension is not isotropic) because it depends on the width/height ratio of the shape (in screen space) and thus on the camera (position+view angle) as well. Hence the name: anisotropic filtering.
Check out the larger picture to see differences between Trilinear and Anisotropic filtering.
Quite a difference, right?
Note:
Anisotropic filtering "just" means that more samples are taken depending on width/height ratio but these samples are still interpolated linearly. That is, trilinear and isotropic filtering are not disjoint. Bilinear and trilinear filtering can be used with anisotropic filtering and without it as well. That is, you can have filtering modes like bilinear with our without AF or trilinear filtering with or without AF.
No comments:
Post a Comment