depth buffer

Just installed iOS 9 on the iPad Air 2.


Problem is, I do not seem to be able to access a depth attachment from my fragment shader. Things where chipper in iOS 8.


In OpenGL ES 2, I create a frame buffer object ( fbo ) with a color and depth attachment. glCheckFramebufferStatus is ok. Later on in the fragment shader, I bind the depth texture to a texture unit. Its a npot texture which is ok in OpenGL ES 2 and I can use GL_TEXTURE_2D. In the shader, I would then access the depth -- its just sampler2D. Seems like I can get at the color attachment without a problem. Once I get the depth I would then linearize it and do fun stuff.


Other people having this issue?


I did see some of my shaders break because #extension was not the first line. For instance,


precision highp float; //Cant put this before the extension line now in iOS 9. Put it after #extension.

#extension GL_EXT_shader_framebuffer_fetch : require


Though fixing that did not seem to fix the depth issue. But it did compile...

I don’t know if this is related, but I’d like to add my experience in the off chance that it is.


On iOS 9.3.2 using an iPhone 6s Plus, I uploaded data to a depth texture using glTexSubImage2D. I then attached that texture to an FBO and did a draw. Based on the output, it was clear that the depth texture was ignored.


On iOS 9.3.2, using an iPhone 5s, the same code worked. The output used the depth texture and appeared as expected.


I finally did get the 6s Plus to work by first attaching the depth texture to an FBO and then calling glClear to clear the depth buffer. Next, I uploaded data to the depth texture. Finally, I did the draw and the output was as expected.

Oh, my original post was from a while ago. I had to do some repository digging and see what I did.😁


There was an issue with my fragment shader. So, I had rendered an initial scene into a fbo with color and depth. Later on, in a final render pass, I was doing some depth comparisons. I think the linearization of the depth was causing problems which I took out. ( related other recent changes )


To be more particular, I was drawing in my final pass with a transparency ( for tree leaves ) but I had to have gl depth turned off during the draw -- or the tree leaves would clip each other out and the tree would look funny. But there was a background with rolling hills and the hills need to clip the trees -- top of tree poking above a hill for instance. The hills are just one mesh with trees on top of it. So, there was a conundrum with depth. I ended up taking the tree leaf vertex and converting it to clip space and passing the clip space value to the fragment shader. Then in the fragment shader, I converted clip space to screen space which would give me an x,y and z in screen space. From there, since I have x,y I looked up the depth in my previous texture color and depth fbo render to get the depth of the hill. Then I compared it to the depth I found on the screen space z plus a little offset when drawing the leaves. So now, I could clip my tree leaves with the hills ( one mesh ) eventhough gl depth comparison is disabled. The problem was I was also linearizing one of my depths and not linearizing the other which caused an issue comparing the depths -- I took linearizing out...old code. Also, I had a little depth offset for z fighting that I adjusted which might have caused issues too.


I think around the same time iOS 9 came out and there were other issues happening as noted in the first post. Runs nice on my iPhone 6s+ now.

depth buffer
 
 
Q