PDA

View Full Version : Selective Opaqueness



bobberkid
07-03-2002, 10:45 AM
Hi,
I am painting several objects, each of which consists of a "translucent"
cone (alpha < 1), and a LINE_STRIP. I want thecone to act as if it were
opaque with respect to the line. That is, I don't want to see the line
where it is "behind" the cone. But I also want the cone to act translucent
with respect to all of the other objects. If I enable the Depth Buffer when I
draw the cone, the line draws the way I want, but all of the other objects
"behind" the cone also don't display. It's as if I want a separate depth
buffer for each object and one more for the entire scene. Can anyone
help me?

knackered
07-03-2002, 11:27 AM
Draw the cone into the stencil buffer as well, then enable stencil test for the line, then disable stencil test for all other objects.

edit:
or rather, sort your objects (including the cone) for alpha blending - draw all objects, alpha blending and writing into the stencil buffer when drawing the cone. Then, after all that drawing, enable the stencil test and draw the line.

[This message has been edited by knackered (edited 07-03-2002).]

V-man
07-03-2002, 12:56 PM
Don't think you need stencil here.

Just sort and render back to front evrything excpet for the line and other things that are to be z rejected, then draw those in the end.

Even if I misunderstood and the problem is more complicated, you will need to group object and render them basically one group after the other.

V-man

bobberkid
07-03-2002, 03:48 PM
I had tried the Stencil buffer solution
earlier, but since the line exactly
coincides with the base of the cone, I had
to draw the line with extra thickness,
resulting in an ugly display. Besides, the
Stencil buffer enabling dropped my
performance drastically.

Perhaps I can try a 3-phase scheme?
1) Enable depthMask and draw the opaque objects, but not the "lines".
2) Disable depthMask and draw the translucent objects (including the cones).
3) Enable depthMask and redraw each pair of cones/lines.

What do you think?

Jambolo
07-04-2002, 11:13 AM
Originally posted by bobberkid:
Perhaps I can try a 3-phase scheme?
1) Enable depthMask and draw the opaque objects, but not the "lines".
2) Disable depthMask and draw the translucent objects (including the cones).
3) Enable depthMask and redraw each pair of cones/lines.


Assuming that a cone is opaque only to its line strip. This works, doesn't it?

1. Draw all opaques.
2. Sort the cones back to front.
3. For each cone:
A. Draw the cone.
B. Draw the line strip.

Use depth-write and depth-test.
Use polygon offset if necessary.

bobberkid
07-08-2002, 05:09 AM
The solutions involving sorting my translucent objects would work, except that I am unable to properly sort them, due to the fact that they are all large and irregularly shaped, and therefore I can not
determine whether or not one is in front of, or behind, another (or both).

The 3-phase scheme I mentioned above seems to work fine. I have not yet noticed any performance impact.

Thanks to all for your suggestions!