|
From: bose <bo...@pa...> - 2002-01-01 06:27:03
|
> -----Original Message----- > From: ope...@li... > [mailto:ope...@li...]On Behalf Of Damian > McGuckin > Sent: Friday, December 28, 2001 4:55 PM > To: ope...@li... > Subject: [openvrml-develop] Transparency > > > > This has been open for over a year. I'd like to close it. > > There are two issues with transparency, one associated with materials and > one with images that have transparent parts. Apparently neither work. > > I have looked at the bug page and it doesn't give me much of a hint except > to say that with z-buffers it is a problem. > > In 'ViewerOpenGL::insertTexture', it mentioned > > // Enable blending if needed > if (d_blend && (nc == 2 || nc == 4)) > glEnable(GL_BLEND); > > Don't we need an extra > > glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); > > or does the one in ViewerOpenGL::initialize cover us forever. There is a > glDisable(GL_BLEND) in ViewerOpenGL::redraw() and I thought that this > clobbered the glBlendFunc(). If you define it once then again you don't need to redefine, unless you want to change the source and destination parameters. glDisable(GL_BLEND) has no effect on these two parameters. > Heaven only knows what to do with Material transparency. > > Can anybody direct me to where there are some simple files to try this > out? And/or any theory that might be useful especially in the context of > OpenVRML and its usage in the context of OpenGL. > Rendering code for OpenVRML is based on OpenGL. For implementing transparency one can make use of OpenGL "Alpha Test" features. Render your object list twice, the first time accepting only fragments with alpha values of one (all the opaque objects), and the second time accepting fragments with alpha values that aren't equal to one (all translucent objects). Turn the depth buffer on during both passes, but disable depth buffer writing during second pass (Read only). When the translucent objects are drawn, their depth values are compared to the values established by the opaque objects (Z-buffer algo.), so they aren't drawn if they are behind the opaque ones. If they're closer to the viewpoint, however, they don't eliminate the opaque objects, because the depth buffer values can't change (Read only). Instead, they are blended with the opaque objects. But mind that there will be drop in performance due to two passes for the same scene. For more details you can see the Chapter 10 of "The Official Guide to Learning OpenGL" red book (Addison-Wesley Publishing Company). Happy New Year Thanks, S. K. Bose |