How to handle transparent objects

Started by
3 comments, last by nickwinters 17 years, 4 months ago
I just got a transparent cube rendering correctly, but as it rotates, sometimes it flickers. I'm aware that objects that are not fully transparent need to be sent to the vid card front to back. How do I handle this if things in a vertex buffer are not in that order? Do I really need to break it down triangle by triangle? Thanks. -Nick
Advertisement
If you turn on backface culling, and only render the triangles that are facing the camera, then any convex object (like a cube) will render correctly (but you won't see the back-side, of course).

You can also split front- and back-faces into two separate primitives, and then sort all faces using a DAG, so that, no matter what direction you view the mesh from, the visible faces (depends on backface culling!) are drawn back-to-front. This works for convex shapes, and many, but not all, concave shapes (a "T" shape works, a "X" shape does not, because there are cycles in rendering order).

You can also sort each triangle, each time you draw. That works for most non-self-intersecting shapes. However, if two triangles cross each other, the only way to draw that right, transparently, is to split the triangles along the plane of intersection, and then draw.

Yes, this is complex.
enum Bool { True, False, FileNotFound };
hmm.... I do have backface culling turned on. Is there anything else that could cause flickering? All I have is a cube.
Could you explain flicker a bit more? If you only adjust the code so as to draw it opaque, does the problem persist or no?
Here's what the flickering looks like.

http://picasaweb.google.com/nikhilhs1110/Flickering

It does not happen when it's opaque.

This topic is closed to new replies.

Advertisement