0

I'm trying to render a vertex array with alpha values and depth test enabled (see below for code) but am getting an interference on the points in the final image (see images below).

Is there a fix for this?

enter image description here enter image description here

ofEnableBlendMode(OF_BLENDMODE_ALPHA);      //openframeworks alpha blend call
glEnable(GL_DEPTH_TEST);                            // Enables Depth Testing
glDepthMask(GL_TRUE);
glDepthFunc(GL_LESS);                               // The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);

glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo);
glVertexPointer(3, GL_FLOAT, sizeof( float4 ), 0);

glBindBufferARB(GL_ARRAY_BUFFER_ARB, cbo);
glColorPointer(4, GL_FLOAT, 0, 0);

glPointSize(1);
glDrawArrays(GL_POINTS, 0, counter);

glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
glDisableClientState(GL_COLOR_ARRAY);
  • I'm not sure what the problem in these two images are. But it sounds as if it could be related to depth sorting. Have you sorted your objects before you draw them? – Nico Schertler Jul 31 '15 at 12:05
  • I thought that calling glEnable(GL_DEPTH_TEST) did that? The problem is that half of the disk of points is not rendering – sam_mcelhinney Jul 31 '15 at 12:08
  • It does if you have either fully transparent or fully opaque pixels. It will not give you correct results if pixels need to be blended. – Nico Schertler Jul 31 '15 at 12:12
  • Aha, well, that would be the issue. How to solve? – sam_mcelhinney Jul 31 '15 at 12:12
  • Depth-sort the points. – Nico Schertler Jul 31 '15 at 12:13
  • Ok, how do you do that? + yes, the two circles and lines are also being drawn to the screen. But omitting them makes no difference – sam_mcelhinney Jul 31 '15 at 12:15
  • Calculate the depth of each point (e.g. by taking the z-component of the modelview-transformed point) and use any sorting algorithm you like. – Nico Schertler Jul 31 '15 at 12:16
  • hmmm, I think that is beyond me at the moment – sam_mcelhinney Jul 31 '15 at 12:31
  • My answer here has an overview of some common transparency rendering methods: http://stackoverflow.com/q/23280692/3530129. There are some options that work without sorting, but they all have their benefits and disadvantages. There are also more advanced and recent methods. If you want to research them, I would start by using "order independent transparency" as a search term. – Reto Koradi Jul 31 '15 at 15:18

0 Answers0