opengl-esopengl-es-2.0renderzbuffer

Parts of model are occluded strangely in OpenGL


I'm rendering a barrel object in Android with GLES20. The barrel is not rendered correctly and it's not clear to me where the problem is (texture? model? culling? depth?):

I've tried debugging with Google's debugger. The model can be rendered correctly in the debugger and the texture is also loaded correctly.

I have tried various parameters related to glFrontFace, glBlendFunc, GL_DEPTH_TEST and GL_CULL_FACE. But so far none of the combinations can render the barrel successfully.

Does anyone know what's wrong with this rendering?

PS: In the debugger GAPID, the depth buffer seem to be all black (Y=1.0). But I'm not sure if this is a issue with the debugger? I have enabled GL_DEPTH_TEST with GL_LEQUAL. I've also used setEGLConfigChooser(true).


Solution

  • Credit to @HolyBlackCat!

    Both zNear and zFar need to be positive. The messed up perspective matrix produces this weired looking rendering.