# Anisotropic F. : Does D3DSAMP_MIPFILTER with D3DTEXF_ANISOTROPIC have a meaning?

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

## Recommended Posts

Hi. I am familiar with the trilinear filtering; which is achieved by setting all the min,mag and mip filters to linear. The results of bilinear filterings of the closest two mipmaps to the polygon are interpolated to a final result. But what if we set the mipmap filter to anisotropic? What does this do exactly? By the way, I have a question too: How can Direct3D get the angle between the polygon and the view plane in anisotropic filtering? Sampling and filtering are per-pixel operations and at the pixel level, I can't imagine any way of obtaining this polygon level data. How can this be possible? Thanks in advance

##### Share on other sites
Quote:
 Original post by 67rtyusBy the way, I have a question too: How can Direct3D get the angle between the polygon and the view plane in anisotropic filtering? Sampling and filtering are per-pixel operations and at the pixel level, I can't imagine any way of obtaining this polygon level data. How can this be possible?

This isn't how it's done: for example you can have dependent texture read (texture read after some operations are done to compute the texture coordinates). So there's no single good relationship between the polygon angle to the viewing plane and the level of anisotropy that you want to apply.

In practice the way anisotropy is evaluated is through the pixel derivatives. That is the du/dx, du/dy, dv/dx, dv/dy. That's an evaluation on how fast each coordinates changes in each direction, also called a gradient. Then it fits those gradients/derivatives to an ellipsoid that covers a certain area of the texture (the ellipsoid is supposed to represent the approximate pixel footprint on the texture). This ellipsoid has a major axis and a minor axis. The minor axis determines what LOD is used (in the mip chain), the ratio between the minor axis and the major axis determines how many individual samples you need to take into account for the anisotropy. Of course the exact way all those computations are done varies by hardware and most of the time it's an approximation (of an approximation), but that gives you a better idea I hope. Note that that's also how the mip level is computed in non anisotropic case, except that the footprint is reduced to a circle (with its radius bigger than the major axis of the ellipsoid).

The gradient is calculated per quad (quad = group of four adjacent pixels). In particular pixel 1 shares its dx derivatives with its left (or right) neighbor and its dy derivatives with its bottom (or top) neighbor. You could probably also derive the texcoords after the plane equation (for the non dependent texture cases) but that's not how it's done.

LeGreg

##### Share on other sites

Quote:
 This isn't how it's done: for example you can have dependent texture read (texture read after some operations are done to compute the texture coordinates). So there's no single good relationship between the polygon angle to the viewing plane and the level of anisotropy that you want to apply.

I didn't understand what is meant by a dependent texture read. Do you mean getting a color value from a sampler by using the tex2D HLSL function? On what is this dependent?

Quote:
 The minor axis determines what LOD is used (in the mip chain), the ratio between the minor axis and the major axis determines how many individual samples you need to take into account for the anisotropy.

Quote:
 Note that that's also how the mip level is computed in non anisotropic case, except that the footprint is reduced to a circle (with its radius bigger than the major axis of the ellipsoid).

After a good amount of brainstorming I think have grasped how the anisotropic filtering and mip level selecting works,thanks to your explanation. But I still have a question though..
What is the difference of using
SetSamplerState(0,D3DSAMP_MAGFILTER,D3DTEXF_ANISOTROPIC);SetSamplerState(0,D3DSAMP_MINFILTER,D3DTEXF_ANISOTROPIC);SetSamplerState(0,D3DSAMP_MIPFILTER,D3DTEXF_ANISOTROPIC);

and
SetSamplerState(0,D3DSAMP_MAGFILTER,D3DTEXF_ANISOTROPIC);SetSamplerState(0,D3DSAMP_MINFILTER,D3DTEXF_ANISOTROPIC);SetSamplerState(0,D3DSAMP_MIPFILTER,D3DTEXF_LINEAR);

AFAIK, the D3DTEXF_POINT for D3DSAMP_MIPFILTER makes Direct3D to just choose the mipmap LOD with the nearest texel size to the current pixel. D3DTEXF_LINEAR takes the two closest LODs, does a min filter on the larger and a mag filter on the smaller and then linearly interpolates the two results according to pixel's size. But what does D3DTEXF_ANISOTROPIC for the Mip filter? I still don't understand that.

[Edited by - 67rtyus on November 18, 2008 8:34:39 AM]

##### Share on other sites
Quote:
 Original post by 67rtyusI didn't understand what is meant by a dependent texture read. Do you mean getting a color value from a sampler by using the tex2D HLSL function? On what is this dependent?

He means that when you sample a texture, the coordinates you use don't necessarily have anything to do with the geometry you're rasterizing. In many cases it will since you'll be interpolating the texture coordinates embedded in the vertex data, but in many cases you won't. Consider something like reflections: you'll often compute a reflection vector based on the view direction and surface normal and then use that to sample a texture. Or consider the case where you sample a screen-sized buffer and then use the results of that sample to calculate an address at which to sample another texture. The bottom line is that the level of anisotropy needed may not have anything at all to do with the slope of the geometry you're rendering.

Quote:
 Original post by 67rtyusAfter a good amount of brainstorming I think have grasped how the anisotropic filtering and mip level selecting works,thanks to your explanation. But I still have a question though..What is the difference of using SetSamplerState(0,D3DSAMP_MAGFILTER,D3DTEXF_ANISOTROPIC);SetSamplerState(0,D3DSAMP_MINFILTER,D3DTEXF_ANISOTROPIC);SetSamplerState(0,D3DSAMP_MIPFILTER,D3DTEXF_ANISOTROPIC);and SetSamplerState(0,D3DSAMP_MAGFILTER,D3DTEXF_ANISOTROPIC);SetSamplerState(0,D3DSAMP_MINFILTER,D3DTEXF_ANISOTROPIC);SetSamplerState(0,D3DSAMP_MIPFILTER,D3DTEXF_LINEAR);AFAIK, the D3DTEXF_POINT for D3DSAMP_MIPFILTER makes Direct3D to just choose the mipmap LOD with the nearest texel size to the current pixel. D3DTEXF_LINEAR takes the two closest LODs, does a min filter on the larger and a mag filter on the smaller and then linearly interpolates the two results according to pixel's size. But what does D3DTEXF_ANISOTROPIC for the Mip filter? I still don't understand that.

I'm reasonably sure that most graphics hardware won't consider that a valid setting. Try setting the mip filter to anisotropic with the debug runtimes active, it will probably complain that it's an invalid setting.

##### Share on other sites
That combination

SetSamplerState(0,D3DSAMP_MAGFILTER,D3DTEXF_ANISOTROPIC);
SetSamplerState(0,D3DSAMP_MINFILTER,D3DTEXF_ANISOTROPIC);
SetSamplerState(0,D3DSAMP_MIPFILTER,D3DTEXF_LINEAR);

looks like a reasonable one (if you want anisotropy + trilinear between levels). Note that in order to get anisotropy you also need to set the max anisotropy level to something more than 1. And that trilinear is probably less important with anisotropy than without (because transitions between levels will be less abrupt/visible). you can try with SetSamplerState(0,D3DSAMP_MIPFILTER,D3DTEXF_POINT); and see if that improves your perf or reduces your image quality.

LeGreg

1. 1
Rutin
44
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632984
• Total Posts
3009713
• ### Who's Online (See full list)

There are no registered users currently online

×