In my project I have to draw damage sprites (hull breaches, smoldering twisted metal, etc.) over ships depending on where they are hit. The problem is, I want those damage sprites to be drawn only over non-transparent parts of the ship, because drawing a burning piece of bulkhead over empty space looks plain weird. So I'm asking for help on how should I do this.
Stencil masks? Render to texture? Shaders?
Currently, I'm thinking along the lines of the following:
1. Draw hull(s) normally, but also draw to stencil all pixels which has alpha==255.
2. Draw damage sprites, using stencil mask.
3. Reset stencil so that subsequent draws will not be affected.
But how, OpenGL and code wise? Many thanks in advance!