neure

Reading depth buffer

Discussion created by neure on Nov 2, 2010
Latest reply on Nov 9, 2010 by neure

 

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.

Outcomes