Using Stencil Buffer for Transluscency

reanjr

Member
Joined
Jul 25, 2003
Messages
19
Has anyone tried/had any success with using the Stencil Buffer to do Translucency. The primary benefit as I see it would be that you wouldnt have to render polygons behind a transluscent object prior to rendering the transluscent object. It seems like this would be a viable way of doing a front to back method of transluscency, but Ive never heard of it, so I was wondering if anyone else has seen it done.
 
Ive never seen it tried, though Ive only studied the basics of the stencil buffer. I would think using the built in alpha channel transparency (to do transluncey, like cloudy windows) would be easier, and probably supported better. Plus you could use pixel shaders to do even more complex translucency (if the card supported it). As you pointed out, it would require sorting polygons to work right, but you should already be doing that, right? :)

-Ner
 
I was actually hoping to sort them the other way. If you draw from front to back, then alot more polygons will be cut out due to the z-buffer; you would only draw to each pixel once. I wanted to play around with the idea for performance reasons. It seems that a scene with only a few translucent polygons would render better front to back with a stencil buffer, while one with lots of translucent polys would run better back to front with the more efficient alpha.

In addition you could play with only doing real easy (processor wise) sorts and not worrying about testing certain polys which may or may not be an efficient way of doing things, Im not sure.

I was just kind of floating the idea around and wondering if anyone else has tried it or thinks it might work in some cases. For instance what I am working on right now will rarely have translucency, so it would be nice to be able to speed up the rest of the engine for when there arent.

Its still in the early stages which is why I havent really tested the theory.
 
Back
Top