ATI 4670 , catalyst 10.1 driver.
change all FBO code to core doesn’t help.
May be the problem is I tried to read depth when it attach to the same FBO.
Actually my g-buffer and final shading-buffer are on the same FBO It setup like this.
depthbuffer = depth_component24
color attachment 0 = g-buffer(normal)
color attachment 1 = g-buffer(diffuse/albedo)
color attachment 2 = g-buffer(specular)
color attachment 3 = final-shading buffer
In g-buffer creation state I enable depth test and use the first three (0-2) color attachment to store g-buffer content.
In final-shading state , I switch draw buffer to color attachment 3 of the same FBO and do deferred shading there (disable depth testing,texel fetch from color attachment 0-2 + depth texture).
The process above work fine for non-multisample FBO.
Why I setup my FBO like this is so that I dont have to switch FBO and make a copy of depth texture when do final shading and forward rendering pass.
I will try to make a copy of depth texture and feed it to final shading state instead of using the attached one and see if the problem are still there.
I have to disable depth testing right after I switch draw buffer for final-shading state (switch to color attachment 3).
If I do some depth testing before the fetching even if I disable depth testing after that the fetching will always failed.
this will not work
-switch to color attachment 3
-enable depth testing
-do some rendering (ambient pass)
-disable depth testing
-do some texelFetch of depth (shading pass)
this work
-switch to color attachment 3
-disable depth testing
-do some rendering (ambient pass)
-do some texelFetch of depth (shading pass)