Advertisement

Quick questions about anisotropic filtering

Started by September 28, 2019 11:11 AM
3 comments, last by MJP 4 years, 11 months ago

Hey everyone,

I've got a few quick questions about my D3D9 sampler state in HLSL. I'm specifically looking at Anisotropic filtering, and was wondering if this is the correct way to do it?


sampler TerrainTextureSampler = sampler_state
{
	texture = <TerrainTexture>;
	magfilter = ANISOTROPIC;
	minfilter = ANISOTROPIC;
	mipfilter = LINEAR;
	AddressU = Wrap;
	AddressV = Wrap;
};

Should I set all three filters to ANISOTROPIC, or should it just be the first two?

Also, what happens if I don't set MaxAnisotropy? Does it default to the maximum value that the hardware can handle? I'm not setting it right now, and from what I can tell in-game the anisotropic filtering is still working.

Thanks very much!

Setting sampler states via HLSL in dx9 was a convenience feature, consult documentation for defaults and other details. Another surefire way to tell what your default anisotropic setting currently is would be to examine a frame capture with Pix. I don’t think you need to set the mip filter to anisotropic (but see if it even does anything different visually)

Advertisement

Ah, yeah I did find this which gives the allowable values for the filters. Says that anisotropic for the Mip filter is undefined.

That page's parent also has info about MaxAnisotropy which is handy.

In practice anisotropic filtering is only relevant for minification, not for magnification. You can check the TextureFilterCaps member of the D3DCAPS9 structure to see what filter types are supported for minification and magnification, and you'll find that all hardware out there will have the D3DPTFILTERCAPS_MINFANISOTROPIC bit set, but not D3DPTFILTERCAPS_MAGFANISOTROPIC. It's been a very long time since I've done any D3D9, but I believe that the debug layer will complain at you if you try to use an unsupported filter type.

As for the MaxAnisotropy value, it's been even longer since I've worked with the Effect framework but I *think* it will not set the underlying sampler state at all if you omit the value from your HLSL definition. According to this the default value for MaxAnisotropy is 1, so if you never set that sampler state elsewhere that's what you'll get. I believe you can do fancy stuff with the FX format where you can define an int variable that gets set to MaxAnisotropy, and then set the value from your CPU code using ID3DXBaseEffect::SetInt

 

 

This topic is closed to new replies.

Advertisement