PDA

View Full Version : Blending Problem



jono_123
07-08-2002, 02:01 PM
hi there
i have made a cube with a texture on it
then before the cube is drawn i enabled blending and set it to (GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
then i had glColor4f(1.0,1.0,1.0,0.5);
then i drawed the cube. it looks fine like it is untill you rotate it and the blending goes all funny what is going wrong???

[This message has been edited by jono_123 (edited 07-10-2002).]

[This message has been edited by jono_123 (edited 07-11-2002).]

[This message has been edited by jono_123 (edited 07-11-2002).]

secnuop
07-08-2002, 07:47 PM
Are you explicitly drawing your polygons back-to-front? If not, this would definitely explain why your cube would look fine from one orientation but would look wrong as it rotated around and faces were drawn front-to-back.

jono_123
07-08-2002, 10:54 PM
i think that is the problem because when you rotate 180 it looks completly around the wrong way
how do i get around this problem?

Bob
07-09-2002, 02:29 AM
Before drawing the primitives, sort them according to the distance from the viewpoint, with the longest distance first, an then draw them. This mean you have to draw them in different order depending on angle of rotation.

Deiussum
07-09-2002, 04:20 AM
You can also display the blended polys last, and disable depth writes before drawing them.

secnuop
07-09-2002, 07:11 AM
(credits to Nutty (http://opengl.nutty.org) , where I saw this first)

Another nifty trick that works for convex objects (like a cube, or a sphere, but not a torus):

Cull all front faces and draw your object, then cull all back faces and draw your object again.

jono_123
07-09-2002, 10:30 PM
yes that might work but is it possible to get actual values straight from the depth buffer???