Burton Radons
05-05-2007, 02:08 PM
Hey all, what I need to do is allocate sub-textures from a main texture and discard them as needed. What I currently use is a quadtree with leaf nodes being coloured with a pointer to which subtexture that leaf is used by; I search for any region containing only null pointers to add a new subtexture. Quick and easy.
The problems are that this creates a LOT of nodes that are hard to optimise and that searching for new subtextures can require visiting every node multiple times. About the only benefit is that it's easy to remove nodes, but everything else gets exponentially more expensive as more subtextures are created from the texture.
So does anyone have or can think of a good design for this? The requirements are:
- Needs to be able to add new subtextures of any size to the texture, meaning both quick insertion and searching for unoccupied areas.
- Needs to be able to remove subtextures and then reuse that space if possible.
- Needs to do this in realtime.
- Does not need to be pixel-perfect.
I've encountered these packing problems before (such as in generating a graph for texturing a model) but they haven't been realtime.
The problems are that this creates a LOT of nodes that are hard to optimise and that searching for new subtextures can require visiting every node multiple times. About the only benefit is that it's easy to remove nodes, but everything else gets exponentially more expensive as more subtextures are created from the texture.
So does anyone have or can think of a good design for this? The requirements are:
- Needs to be able to add new subtextures of any size to the texture, meaning both quick insertion and searching for unoccupied areas.
- Needs to be able to remove subtextures and then reuse that space if possible.
- Needs to do this in realtime.
- Does not need to be pixel-perfect.
I've encountered these packing problems before (such as in generating a graph for texturing a model) but they haven't been realtime.