[XNA] Mipmap generation oversampling

Started by
3 comments, last by Racky1275 15 years, 5 months ago
Having trouble with XNA 3.0's automatic generation of mipmaps... It appears that you can't control the texture addressing mode whilst the mipmap chain is created. During rendering I set the texture addressing mode to Clamp, otherwise my non-wrapping textures produce oversampling artifacts on their edges. Unfortuately these texture artifacts are still showing up at certain scalings, as they exist in the mipmap chain. My current workaround is to simply use Box filter during texture creation, as its sampling algorithm by default doesn't seen to oversample. Rendering can then use better filtering. I'd like to use something 'better' than the Box filter though, as for me quality is more important than speed. Any ideas?
Advertisement
DDS texture files (.dds) support specifying the MIP map contents explicitly. That is, you can provide a different image for each level of the chain. While this requires extra disk space (~30% more), it isn't that bad, and loading speeds should be better (no runtime MIP creation). Most importantly, XNA shouldn't mess around with the MIP data and should load the maps provided in the file.

Hope this helps.
Sirob Yes.» - status: Work-O-Rama.
Thanks sirob, unfortunately the app will never know which assets it'll need before it runs... Its got to cope with any image you care to throw at it at runtime.

I'm in two minds as to whether this should be reported as an XNA bug...

On the one hand I understand what the issue is. So can work round it.

On the other... when you render with texture clamping on you don't expect to see this top/bottom left/right texture contamination.
Why not create your own mip-map generation routine if the one provided doesn't produce adequate results? It'll take some coding, but should be fairly straightforward. There also should be plenty of resources available for such a common topic.

Also it might sound pedantic, but the term oversampling actually has a pretty specific meaning in signal processing that's not related to your problem. I know what you mean here in this case when you say "oversampling", but I just thought I'd point that out for you. [smile]

Hi MJP. No worries, as a world class pedant myself I simply feel a warm glow when I see such things pointed out. [oh]

In the spirit of not pre-optimising this project into obsolenence, I'm going to make a note of it and move swiftly on. Box filtering will be fine. [smile]

This topic is closed to new replies.

Advertisement