Automatic Texture Pack Generation at Build Time.

Hello All,

I’m wanting to automatically generate lower resolution textures at build time for each texture for an FBX model. Essentially generating the texture packs at compile time in a custom pipeline.

I’ve been playing around with the pipeline extensions but have been having trouble finding a way to shrink a texture during the TextureProcessor call and then saving this modified texture separately. If MipMaps are generated, is there a way to save each one separately?

Thanks in advance.

I think Mipmaps are stored within the original file and used by the rasterized when needed/specified by a shader. If they could be accessible each as single file would require more 'load" calls in loadcontent and be wastefull…

FYI:
https://books.google.fr/books?id=kbYYAAAAQBAJ&pg=PA426&lpg=PA426&dq=xna+textureprocessor+texture+creation&source=bl&ots=D5rPUpciwq&sig=OHJt017tDGWiJgcCx2bAqM4EzVs&hl=fr&sa=X&ved=0ahUKEwjpwsTP5-LUAhUIEVAKHYXVBCQQ6AEIKzAB#v=onepage&q=xna%20textureprocessor%20texture%20creation&f=false

https://books.google.fr/books?id=08fx86eFQikC&pg=PA223&lpg=PA223&dq=xna+textureprocessor+create+texture&source=bl&ots=0BtkjJURBl&sig=65u0IzrW8c6onWlkGeMhvc3ATAI&hl=fr&sa=X&ved=0ahUKEwj__8Pk5uLUAhUGfFAKHf3MBCYQ6AEINjAB#v=onepage&q=xna%20textureprocessor%20create%20texture&f=false

Thanks for your response @Alkher.

Yes, it would mean more Load calls, but the idea is to split the texture automatically into different sizes at build time. This is so that at runtime a user could choose different Texture size for a model. i.e. On a less powerful machine a player could load a ‘Low Quality’ texture pack of 64x64 px textures, where as someone with a higher end machine can choose a ‘High Quality’ at 512x512 px textures.

I think the only thing I still need to do is figure out how to call BuildAsset multiple times using the texture data during the Process() call.

I think it is the best way to save memory and bandwidth. But nowadays having 8Go of RAM or more is common.
If you target mobiles it sure can help these devices.

I assume it is something not far from what I did to generate normals from textures automatically. (better than not having one with deferred)

Here:
http://xboxforums.create.msdn.com/forums/t/4053.aspx
it talks about powerof2 resize, but it is I think a good start.

and
https://blogs.msdn.microsoft.com/shawnhar/2006/11/22/customizing-how-models-build-their-textures/

You could also set the mipmap level to be mapped to the quality the user chooses, and use this value.
But I suddenly have a doubt, I’m not sure if the mipmap is accessible with shaders in monogame, I remember having read about that somewhere here…

The mipmaps are saved individually in the XNB. Maybe you can make an custom Importer and a contentLoader to load your textures starting from any mip level.

There’s a discussion on this at Pipeline automatic texture size reduction · Issue #5111 · MonoGame/MonoGame · GitHub