Loss quality while scaling down large textures

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

Recommended Posts

Hello together

I have the following problem. I have a texture which is 512x512 in size. When I draw this texture smaller (e.g. 120x120) the quality is not as good as it should be. When I use textures that where scaled in "gimp" they look significantly better. I tried to work with the SetSamplerState Method as this seems to be the right thing (by searching the forum). But still I don't get a difference. My initialization looks like this:

m_pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_ANISOTROPIC);m_pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_ANISOTROPIC);m_pDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);m_pDevice->SetSamplerState(0, D3DSAMP_MAXANISOTROPY, 16);

I tried serveral different possibilities, but all where looking bad. It seems a little bit as the code is ignoring the filtering completely.
Just for information: I'm using Direct3D to draw 2D Sprites (by using a texture on a polygon). Maybe there is a restriction here - as with lightning?

Share on other sites
Anisotropic filtering only helps when you view your texture from an angle, so that it's compressed more in the X than in the Y direction for example. If your scaled sprite has the same proportions as the original, then it won't make a difference.
The reason it looks better in Gimp could be that it uses a different filtering method for scaling down, for example bicubic, possibly with extra sharpening or feature detection, while D3D will simply use bilinear filtering when scaling down.
Also, when scaled to a size that is not exactly the same as a mip-level (in your case 512, 512/2, 512/4...), D3D will interpolate between two mip-levels which could make your image look blurred.
Does it look bad also at exactly a size of 256 or 128 pixels?
You could manually create the mip-maps with Gimp and load them on texture-creation instead of letting D3D create them automatically. For sizes in between mip-levels it's harder.. you could try using point-filtering as your mip-filter, but it might also look worse.

To manually create mip-levels, you could use the DirectX Texture Tool that comes with the DX SDK, which allows you to manually choose an image for each mip-level, and then save it as a DDS texture file for loading in D3D.

Share on other sites

What really wonders me, is that it really looks as when I'm using the D3DTEXF_NONE filter for the D3DSAMP_MIPFILTER. There is no difference between the settings.
I also wrote a kind of editor for my application which is written in C# and MDX. There I'm using the posted setup and I see an improvement in drawing (compared to the a setting with D3DTEXF_NONE). I thought that this is because of the "carefull" behaviour of MDXm, which sometime performes steps that you actually don't see directly. So my first guess was that I missed some initialization in C++.

Quote:
 Original post by Erik RufeltAnisotropic filtering only helps when you view your texture from an angle, so that it's compressed more in the X than in the Y direction for example.

When I understand it right then D3DTEXF_LINEAR should be sufficient for 2D drawing?
That would match my experience with the editor which did show only an improvement up to D3DTEXF_LINEAR (when I remember right). D3DTEXF_ANISOTROPIC did not show an enhancment when comparing the images.

Thanks again.

Share on other sites
Uuuuuups!

Problem identified. While loading the texture I restriced the miplevels to - guess what - 1 :-((((

Sorry my fault. Thank you for helping. The good thing is that I know now why I don't have an enhancemant with anisothropic ;-)

Sorry again...

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• Forum Statistics

• Total Topics
633725
• Total Posts
3013559
×