# Make displayed textures appear less jagged?

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

## Recommended Posts

My images when displayed (on two 3d triangles) appear jagged: I'm already using antialiasing setting on the d3dDevice, Also I've got mipmapping turned on like so: D3DXCreateTextureFromFileEx(d3dDevice, "cards.png", 1024, 512, D3DX_DEFAULT, 0,D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, D3DCOLOR_XRGB(255,0,255), 0, 0, &image); Is there anything else I can do to reduce the jaggedness of the images? Thank you. Edit: I don't much about shaders, but could using them some how help?

##### Share on other sites
Multi-sample anti-aliasing only affects the edges of geometry, it won't do anything for textures. To reduce aliasing in textures you need to enable texture filtering. Each texture stage has a group of sampler states you can set using IDirect3DDevice9::SetSamplerState. You have to set sampler states for the minification filter (used when textures are smaller on-screen than they are originally), the magnifaction filter (used when textures are bigger on-screen than they are origignally) and the mip filter (which controls how different levels of the mipmap chain are blended together)

-For D3DSAMP_MAGFILTER you can set it to either D3DTEXF_POINT, or D3DTEXF_LINEAR. LINEAR is bilinear filtering, and is what is commonly used for material textures. Bilinear filtering will "smooth out" the texture when it's enlarged, making it appear less jaggy.
-For D3DSAMP_MINFILTER you can set it to either D3DTEXF_POINT, D3DTEXF_LINEAR, or D3DTEXF_ANISOTROPIC. Point will give you the ugly aliasing you're getting. Bilinear will look alright when you're looking at a texture "head on", but will break down pretty badly when a texture is slanted with respect to the ground. Anisotropic will correct that issue, with the quality improving based on the value of D3DSAMP_MAXANISOTROPY (16x is typically the max for single GPU's).
-For D3DSAMP_MIPFILTER you can set it to either D3DTEXF_NONE, D3DTEXF_POINT, or D3DTEXF_LINEAR. The default is D3DTEXF_NONE, which disables mipmaps. POINT will use mipmaps, but will cause visible "mip lines" where a transition from one mip level to another occurs. LINEAR will use bilinear filtering to smoothly transition between mip levels.

I'm not sure if you're using effects, but if you are you can specify these sampler states right in the definition for your sampler. See the documentation for the corresponding effect states.

##### Share on other sites
Thank you its looks much much better, although it does have some artifacts similar to what appears on jpeg images, but that is very bearable if there are no solutions to that.

..
d3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER,D3DTEXF_LINEAR);d3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER,D3DTEXF_ANISOTROPIC);d3dDevice->SetSamplerState(0, D3DSAMP_MIPFILTER,D3DTEXF_LINEAR);d3dDevice->SetSamplerState(0, D3DSAMP_MAXANISOTROPY,d3dCaps.MaxAnisotropy);

..

Quote:
 Original post by MJPI'm not sure if you're using effects, but if you are you can specify these sampler states right in the definition for your sampler. See the documentation for the corresponding effect states.

I haven't used effects before, from the link it looks like they allow various states to be set via files...

I'll have to do more reading.

Thanks!

##### Share on other sites
Another option is the .dds exporter plug in that nvida has for photoshop (free if you have photoshop)- it builds all your mipmaps for you before loading. It speeds up loading time at the expense of files size (but not memory use).

##### Share on other sites
Quote:
 Original post by andaI haven't used effects before, from the link it looks like they allow various states to be set via files...I'll have to do more reading.Thanks!

Yes that's one big part of what they do: they allow you to associate render-states and sampler-state with "techniques", which generally represent a certain method of drawing something. Typically these techniques also contain a vertex shader and pixel shader, but you can use fixed-function if you'd like by setting those to NULL.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

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

• Total Topics
633722
• Total Posts
3013546
×