Why use .xnb?

I can’t find any good resources on this. Since you can use .png, .wav etc, why would you want to compile all your assets to .xnb?

1 Like

Formats like PNG or WAV are generally not optimized for games.

For example most all GPUs have an hardware supported compressed format for textures. PNGs or JPEGs just get uncompressed when passed to the GPU. By using the hardware compression you often get 4x to 8x more textures space for your game as well as faster load times and smaller packages.

Same with formats like WAV. Most platforms have audio processing that is optimized to certain compressed formats. By not using them you loose performance and system memory.

Often this is when people resort to just using a format optimized for your current target platform. You could save the textures as DDS files and sound effects as ADPCM and run pretty optimally on Windows systems. The problem here is only apparent once you try to take your game to another platform where DDS and ACPCM isn’t optimal anymore. You need to manually re-export all your game content in the new optimal format for that platform… and you did keep your original content uncompressed right?

This is why using the content pipeline and XNBs is superior. You feed uncompressed source content to the MonoGame content pipeline, tell it what platform you’re building for, and it takes care of converting it to optimal formats. You decide to ship to another platform… it is a one click change to rebuild your content optimized for that platform.

This is what professional game development tools like Unreal do.


Ok. Thank you very much for clearing it up for me :slight_smile:

wow +1, i didn’t know it affects performance as well, thanks a lot

Just found this at the Microsoft Virtual Academy. Tom explains the xnb format a bit here too.

1 Like