5 Replies Latest reply on Nov 9, 2010 10:12 AM by neure

    Reading depth buffer

    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.
        • Reading depth buffer
          neure

          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?