Search code examples
javalibgdx

LibGDX how do I get a depthbuffer from FrameBuffer?


now I'm working at a depth of field shader. Here's how it works:

I render the whole scene to a FrameBuffer then apply the shader on it. But, there's a problem: How do I pass the depthbuffer as an uniform to the shader? I couldn't find it anywhere in FrameBuffer's methods.

Any help is appreciated.


Solution

  • Not a LibGDX user (I use LWJGL), but in OpenGL you need to pass framebuffers as textures to a shader. In LibGDX, FrameBuffer extends GLFrameBuffer. In order to get the depth texture of a FrameBuffer, you need to call getDepthBufferHandle(), then treat it as you would a texture.