Sign up ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm trying to render a plane mesh textured with a simple grid pattern. The problem is that XNA keeps mip-mapping the texture in horrible, horrible ways.

enter image description here

What I'm trying to achieve is to get this grid to look as close to vector graphics as possible (so anisotropic filtering is out of the question, I must use point filtering):

SamplerState ss = new SamplerState();
ss.Filter = TextureFilter.Point;
ss.MaxMipLevel = 0;
ss.AddressU = TextureAddressMode.Wrap;
ss.AddressV = TextureAddressMode.Wrap;
GraphicsDevice.SamplerStates[0] = ss;

I'm loading the mesh, and it's textures, from an .x file so I don't have control over the specifics of the texture loads. Can I disable mip-mapping for the whole rendering process?

share|improve this question
@childonline Not sure, off the top of my head. If it's not an option for the default content importer, you may need to write a content pipeline extension. Or maybe try doing this without a .x model? (Set up the vertices by hand and load the texture independently.) – Andrew Russell Mar 31 '13 at 11:14
(There may be a way to do it at runtime - but I'm not sure - I would have thought that MaxMipLevel would have worked. But I've never played with that.) – Andrew Russell Mar 31 '13 at 11:15
@Andrew Russell: Nevermind, I've fixed it, it's sort of a dirty hack, but i've set the MipMapLevelOfDetailBias of the SamlperState to -2, i don't know why it works, but it works. Here is a screen: – childonline Mar 31 '13 at 11:58

1 Answer 1

If you're using the default content importer, there's no way to control the mipmap generation behavior of the textures.

The .x file format doesn't really provide a template that allows control over mipmapping of textures, and XNA's importer assumes you'll want mipmaps for all the referenced textures.

Your two best options are likely:

  • Build a custom importer to parse the .x file and generate the textures without mipmaps.
  • Ignore or discard the textures loaded by the content importer for the .x file, loading manual copies yourself, in which you disable mipmapping.
  • Set the MipMapLevelOfDetailBias property of your sampler state to a sufficiently-negative number to ensure mipmap level 0 is always used (in later shader models you could use SampleLevel to explicitly specify that mipmap 0 should be sampled, but I don't think XNA supports a new-enough model for this).

The last option is probably the easiest, but also wastes all the memory of the extra mip levels which you'll never sample.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.