I’m looking for a way to have a piece of geometry occlude only one specific other piece of geometry.
For example, presume that we have objects A, B and C, which could be drawn in any order. Presume that we also have a fourth object, D. I want D to occlude A, for example, without occluding B or C.
To be a little more specific, I have a set of objects that I intend to draw additively to an off-screen buffer, but I also want each object to potentially have regions “removed”. At the moment the best idea that I have for removing these regions is to overlay black objects of the appropriate shape on the additive objects, meaning that when drawn additively the objects should only have an effect outside of those regions.
However, I don’t want the regions of one object to affect any other object.
I could perhaps use an offscreen buffer for each addtive object, but, given that this is already being rendered into an offscreen buffer and that I don’t know how many additive objects I’m going to have, doing so seems as though it might be a little expensive.
I’ve also considered generating only the parts of the additive objects that are not in the regions removed, but since this is intended to happen each frame, that might get a little slow.
Does anyone have any suggestions?