# How can I disable mipmapping on textures loaded from .X files?

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.

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;
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?

• @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: imgur.com/OFbYAqE – childonline Mar 31 '13 at 11:58

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.
• 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).