I'm trying to figure out the best way to render some per-pixel destructible terrain. Right now I load my map image into a series of textures (tiles) and keep the raw texture data stored in memory. When the terrain is destroyed, I simply update my copy of the pixel data and use glTexSubImage2D to update the corresponding textures on the GPU. Of course this is terrible because I'm wasting memory keeping a copy of the images around. I'm using OpenGL ES 2.0 so I can't use glGetTexImage to grab the texels from the GPU, update them, then re-upload them.
I think a good solution would be to create and store a bitmask with the dimensions of the map image, with a single bit per pixel and simply store either a 0 or 1 depending on if the pixel has been destroyed or not. If I do that, I need some sort of method to combine the textures with this bitmask to decide which pixels need to be rendered. Is there some way I can accomplish this using blending or by uploading my mask to a pixel shader and rendering only the texels that have their mask bit set to 1?
Cheers to whoever can help me figure something out.
Edited by Jethro_T, 20 July 2014 - 09:57 PM.