Jump to content
  • Advertisement
Sign in to follow this  
anda

Make displayed textures appear less jagged?

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 MJP

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.


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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by anda

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!


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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!