Binding images to ofMesh

Hi,

I’m having a some problems rendering pngs with alpha channels when bound to a rectangular ofMesh made of two triangle strips.

From the front side the images render fine but from the opposite side of the mesh the alpha channel doesnt translate to other images bound to meshes behind it.

The first image (grey silhouette) is fine and is rendered from the ‘front’ side of the mesh. But the second image shows the problem.

TIA

Thanks to @bgstaal for the solution.

I’m using ofxGrabCam (camera) to orientate the scene and I need to call glDisable(GL_DEPTH_TEST) after

camera.begin();

heya!
you probably want to keep your depth testing, but the problem is, those see-through bits of your png’s are writing to the depth buffer, stopping objects behind from being drawn.

the trick is to use something called ‘alpha testing’, which completely abandons any fragments below a certain alpha (not drawing them to the screen since they’re barely visible anyway, but more importantly, not drawing them to the depth buffer).

try putting this after the camera.begin():

  
  
glAlphaFunc(GL_GREATER,0.1f);   
  

1 Like

Hey,

Thanks Elliot. As you suggest I am now having problems when turning off depth testing, although I can see through the alpha to the object behind their is no stacking order.

I have tried glAlphaFunc(GL_GREATER,0.1f); and turned depth testing back on but the problem persists? The call to glAlphaFunc(GL_GREATER,0.1f); is right after camera.begin():

could you try adding in

  
  
glEnable(GL_ALPHA_TEST);    
  

also?

Perfect! That did the trick

Thanks very much for your help

or sort it by hand without GL_DEPTH like so ->http://forum.openframeworks.cc/t/depth-sorting-without-gl-depth-buffer/11891/0
greetings ascorbin