FNA-XNA / FNA

FNA - Accuracy-focused XNA4 reimplementation for open platforms
https://fna-xna.github.io/
2.65k stars 272 forks source link

Add extension method for loading mipmap texture from stream #481

Closed tomcashman closed 8 months ago

tomcashman commented 8 months ago

We're working on a project that relies heavily on mipmaps and would like to have access to a variation of FromStream that can load mipmaps.

public static Texture2D FromStream(GraphicsDevice graphicsDevice, Stream stream)

I propose adding an extension method

public static Texture2D FromStreamEXT(GraphicsDevice graphicsDevice, Stream stream, bool mipMap)

flibitijibibo commented 8 months ago

Does DDSFromStreamEXT handle this? AFAIK it's the only format that natively supports mip levels.

tomcashman commented 8 months ago

Looks like it would. We'd need to change our asset pipeline. Is there a recommended way to generate DDS files?

flibitijibibo commented 8 months ago

I'm aware of the NVIDIA Texture Tools, but most image editors have an exporter for DDS - for an automated solution it may be enough to throw together a quick DDS spewer, as the format is a small header followed by byte chunks with lengths prepended:

(This is also a good place to compress the texture data to DXT5/BC7, if VRAM usage becomes an issue)