From: Lou H. <lh...@ia...> - 2002-04-11 16:56:52
|
Ok, but how do I sort the polygons if OpenGL draws them immediately when I call glVertex? The only way for me to sort polygons from back to front is if I know the transformed coordinates, but I don't know that until I call glVertex. Unless there's some other feature of OpenGL that I still don't know about (which there probably is). - Lou ----- Original Message ----- From: "Chad Austin" <ae...@ae...> To: "Lou Herard" <lh...@ia...> Cc: "gdd" <isu...@li...> Sent: Wednesday, April 03, 2002 2:42 AM Subject: Re: [isugamedev-devel] Alpha blending > 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 > |