union of two transparent objects


i’m trying to get the union of two transparent spheres. my first idea was to solve it at the geometry level but refused it afterwards because I think it will get too slow. then i thought about doing it with the stencil buffer and stumbled about CSG with stencil buffer.

would it be possible to get the union of two transparent spheres with help of the stencil buffer? maybe someone can point out the first steps or can give me a rough overview?



I believe the following technique would be useful for your particular problem:


To implement this, you also need these two papers:


The process is a bit involved but rather efficient and neatly incorporates both transparancy and csg rendering.


Thanks for the links! I skipped through the first paper and it seems to be exactly what i was searching for.

but i wonder if their might not be a simpler way, because i have to deal only with spheres, that are all at the same z-coordinate.

I’m not sure that you can use the fact that they’re the same z coordinate easily (though I haven’t exactly thought it through, it’s just a little difficult to imagine the precise advantage) but you probably can make use of the fact that you’re only calculating a union. Most of the paper, if I recall correctly, deals with intersections and differences and reducing them to a tree with “easy” union renderings at the root; since you’re only calculating unions you might be able to skip most of the tricky bits.

thanks for explanations. i also found this paper:
Hardware accelerated rendering of CSG and transparency

in case you or somebody else is also interested in it.

Thanks, looks interesting. :slight_smile: