TL;DR: Best way to handle level-specific textures without overkilling memory usage and killing performance and keeping things clean in OpenGL for mobile (also lower-end devices) and desktop using power-of-two-textures. Any thoughts? (Check my idea in the update).
I'm developing a game for desktop and mobile using OpenGL and I've come to the point where I would like to add textures that are specific to one single level. Adding these textures to the atlas that is used in all levels feels wrong and is eventually a bad thing, since the amount of levels could become arbitrary large and so could be the amount of level-specific images, soand thus the atlas would become totoo big.
Use two textures: one global atlas and one level specific atlas. I don't like this because this would make it impossible to use textures of both atlases in one texture render batch. Using a cool shader that uses two samplers is something I don't like either, since samplers accessing by dynamic index is not allowed in a shader. The solution to this is to introduce an if-statement in the fragment shader. I would rather avoid that since I'm targeting a wide range of devices, so I would like to avoid branches in the shader.
Use one big texture that contains the global atlas and a level-specific atlas. I don't like this because I don't know in advance how much space will be required for the level-specific textures. So I would have to greatly oversize this big atlas while not using it 95% of the time. The oversizing might be huge, since I'm using power-of-two-texture dimensions. Given the fact that my current atlas at lowest texture quality is already 1024x256 pixels large, and texture quality for iPad is already 2048x1024 pixels large. This approach would allow me to update a sub-area of the texture when loading the level and would require constant memory usage.