Depth Buffer


I’m trying to pass a depth buffer to one of my shaders and I’m having some trouble. In the shader, if I print out texture2D(m_DepthBuffer,coords) some text are displayed at the top of the screen. Help would be much appreciated.

With this code I try to get the depth buffer:

int w = app.getCamera().getWidth();
int h = app.getCamera().getHeight();
FrameBuffer zBuffer = new FrameBuffer(w, h, 0);
depthBufferTexture = new Texture2D(w, h, Format.Depth);

depthView = getRenderManager().createPreView(“depthView”, cam);

And I do this when passing it to my shader:

material.setTexture(“DepthBuffer”, depthBufferTexture);

The code looks fine to me, but obviously something is going wrong.
How do you compute your texture coordinates?
Also try with Depth24 (or Depth16) instead of Depth, I remember that some drivers didn’t like it.

Hey, thanks for the quick reply. I managed to solve it. I’m running linux and thought I would test it on a windows computer since you mentioned drivers. So I set up a quick test for my other computer and it worked.

The problem was that I did not do the depth buffer setup in simpleInitApp but in an AppState. So it had nothing to do with the OS.