From: Chad A. <ae...@ae...> - 2002-04-03 07:42:03
|
Your problem is that, with alpha blending, you can't use the z-buffer. :( When you draw your first polygon, you end up putting initial values in the z-buffer. When you try to draw the polygons behind the first polygon, they don't get drawn at all because the z-buffer says those pixels don't need to be touched anymore. The solution to your problem kinda sucks... when you draw alpha-blended polygons, you have to disable the z-buffer and manually sort your polygons from back to front. After drawing every solid polygon in the scene, you draw the alpha-blended ones from front to back. A simple way to do this with your cube is just take the midpoint of each face and sort by its distance from the viewer (or z value, if you're in view coordinates). If you have static, non-intersecting shapes, you can build a BSP tree. BSP trees let you quickly sort polygons from front-to-back, which makes drawing the translucent polys a simple tree traversal. You can pick up a book on graphics (Realtime Rendering is the one I recommend) for more information. > Ok, now I'm kinda fooling around with transparency (alpha blending) and I > can't get past this nagging characteristic of my program. Maybe someone knows > how to fix this: I started with a box with an open top and open bottom. All > of the four sides have alpha values of 0.5. When I rotated that box rotates, > though, the first polygon drawn is always opaque. So, I modified the box so > that there is a bottom side (also with an alpha value of 0.5), and now all > four of the walls are translucent, but the bottom is completely opaque, > despite the alpha values that I specified. Is this an OpenGL thing, or am I > missing something? I attached my code so you can see exactly what's > happening. (The program actually draws two boxes, but I'm only worried about > the one that has five sides) > > - Lou > > Name: Create_Window.cpp > Create_Window.cpp Type: Plain Text (text/plain) > Encoding: quoted-printable |