[SOLVED] Rendering problem when two faces are close to each other

Hi Matt,

my last post contained a lot of possible solutions that I never tried myself. So it inspired me to look at them in more detail. As it turned out, this required quite a substantial update to Cinder to make it support the latest OpenGL version (4.6), required for the glClipControl command.

I had to replace the current OpenGL loader (a.k.a. glLoad) with a new loader called GLAD. You can find this change in my fork of Cinder. There is currently a discussion among the Cinder devs about whether GLAD is the best choice, so keep in mind that my work on this does not mean it will be adopted in the official Cinder release.

On top of all this, I wrote additional functions to easily enable Reversed Z rendering. You can find this in my reverse-z branch. Check out the FightingPixelFighting sample.

I added a gl::enableDepthReversed( bool enable = true ) method that you call once at the beginning of your application. It will setup Cinder to clear the depth buffer with zero instead of one, set the depth comparison to GL_GREATER instead of GL_LESS, set the clip range to GL_ZERO_TO_ONE instead of GL_NEGATIVE_ONE_TO_ONE and adjust the projection matrix accordingly. Of course, there is also a gl::isDepthReversedEnabled() method.

The CameraPersp class now also supports infinite far clip distance, as well as zero-to-one clip mode and reverse depth.

Caveat: due to the fact that OS X hasn’t kept up with the times, this code will only work on Microsoft Windows and (in the near future) on Linux platforms. OpenGL ES is out of the question, too, so bad luck for iOS, ANGLE and Android.

-Paul

4 Likes