cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

neure
Journeyman III

Reading depth buffer

 

Is there a way to read depth buffer values?

I have tried the following (using OpenTK bindings)

  GL.ReadPixels(px, py, 1, 1, PixelFormat.DepthComponent, PixelType.UnsignedInt, depthsi);
  GL.ReadPixels(px, py, 1, 1, PixelFormat.DepthComponent, PixelType.Float, depthsf);

Both of these work on NVidia. Unfortunately on AMD the first one only gives me 0 and the second gives me INVALID_OPERATION. Querying the framebuffer attachment says the depth attachment has float component type.
I am trying to do this on my ID buffer, which is setup like this:
  idFramebuffer = new Framebuffer(Width, Height);
  idFramebuffer.AttachRenderBuffer(
  FramebufferAttachment.ColorAttachment0, 
  PixelFormat.RedInteger, 
  RenderbufferStorage.R32ui,
  0
  );
  idFramebuffer.AttachRenderBuffer(
  FramebufferAttachment.DepthAttachment, 
  PixelFormat.DepthComponent, 
  RenderbufferStorage.DepthComponent32,
  0
  );
Any ideas? Reading the ID from the ID buffer works from this FBO, but I can't get any depth.
0 Likes
5 Replies
neure
Journeyman III

I have converted my app to read ID from the ID buffer framebuffer color attachment and depth from the default back framebuffer. This works. So it appears on AMD reading depth from non-default framebuffer is not supported at least on my framebuffer configuration - or I am doing something else wrong..

Should I be able to read depth with glReadPixels() on non-default framebuffers? Are there framebuffer configurations that are known to or not to work with this?

0 Likes

there is no known limitation with reading from the depth buffer from a fbo (the code is largely shared between the two). it would help if you could send us a standalong .cpp app which reproduces the issue.

regards,

Pierre B.

0 Likes

there is no known limitation with reading from the depth buffer from a fbo (the code is largely shared between the two). it would help if you could send us a standalong .cpp app which reproduces the issue.

regards,

Pierre B.

0 Likes

there is no known limitation with reading from the depth buffer from a fbo (the code is largely shared between the two). it would help if you could send us a standalong .cpp app which reproduces the issue.

regards,

Pierre B.

0 Likes

Unfortunately my code is C# and more than just a few small files. I might be able to make a standalone .cpp test eventually though.

0 Likes