PDA

View Full Version : do not see the object in Transparency



Numan.pk
07-14-2013, 11:37 PM
Hi every body.
i have made the transparent glass in OpenGl but the problem is this that any other object do not see in the glass, so any one can help me what's the problem.

void glass()
{
glPushMatrix();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glShadeModel(GL_SMOOTH);
glTranslatef(d1x, d1y, d1z);
glRotatef(zAngleB3, 0,0,1);
glRotatef( -90.0, 1.0, 0.0, 0.0 );
glDisable( GL_CULL_FACE );
glColor4f(0.9f, 0.9f, 0.9f, 0.2);
drawGluSlantCylinderWithCaps( 2.5, 0.8, 0.8, 20, 1);
glPopMatrix();
}

GClements
07-15-2013, 06:13 AM
i have made the transparent glass in OpenGl but the problem is this that any other object do not see in the glass
Translucent objects have to be drawn after whatever is behind them.

In general, opaque objects should be drawn first, then translucent objects drawn afterwards from back to front with depth writes and tests disabled. Non-convex objects may need to be split into convex sections (possibly into individual polygons).

If objects are far apart relative to their size, sorting by nearest/farthest/average Z may suffice. Otherwise, you need to perform a topological sort, which can be quite complex (e.g. in the case of cyclical overlap).

An alternative is "depth peeling", which uses shaders, framebuffer objects and multiple passes, but that's not exactly simple either.