Hello all. I am working on a 2d game and was thinking about using mipmaps to display correct 2d images for the game running at different resolutions.
So far it works pretty well and displays the correct res texture for the size of the screen, however I’m wondering if this is the best way to go about for performance.
Sometimes people choose to run their game at a lower resolution to increase performance, and although opengl draws the lower res mip-map do you think there is still too much overhead in loading the .dds that includes higher res textures.
Do you think I should just create a number of texture files and load the correct one manually or would mip-maps be a good idea in this situation?
On the pure rendering speed, it should be equivalent IF there is enough memory for video card and the cpu.
That means having an option to select the texture detail level is still a good idea.
Assuming all the textures and whatever other resources fit into the video card, mipmapping improves performance. Probably because the mipmap better fits the texture cache.
Thanks for the input. In the end I suppose it will have to come down to testing on different machines. I’d rather not have multiple files as it’s easier to make and also reduces file size.
A full mipmap chain only adds 33% to the size of the base texture.
Anyway you can just ship the highest res, then at load time reduce it first before using it as base texture.
Ideally, generate mipmaps with high quality tools (NVTextureTools is good), avoid basic averaging filters that get gamma wrong and thus darken smaller mipmap levels. Also be aware of the type of the content, for example normal maps need different treatment than color textures. For load time optimization, generate mipmaps offline, not during load time.
At load time, when you know your target resolution, you can choose to skip loading mipmap levels which are not going to be used. This will save you some loading time and texture memory.
All of this is optimization that you can add any time later, so I would not worry about it too much unless your target includes some very constrained systems. If you are memory constrained, you can get away with a single CPU memory buffer where you load one mipmap level at time, upload it to OpenGL, then load next mipmap level; This buffer needs to be big enough to contain the largest mipmap level you are going to upload during the load time.