View Full Version : union of two transparent objects

04-10-2006, 02:41 AM

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?


Claus Matthiesen
04-10-2006, 03:05 AM

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.


04-10-2006, 02:25 PM
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.

Claus Matthiesen
04-11-2006, 02:05 AM
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.

04-11-2006, 03:03 AM
thanks for explanations. i also found this paper:
Hardware accelerated rendering of CSG and transparency (http://portal.acm.org/citation.cfm?coll=GUIDE&dl=GUIDE&id=192196)

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

Claus Matthiesen
04-11-2006, 07:24 AM
Thanks, looks interesting. :)