Depth Buffer

Hello,

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:

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

depthView = getRenderManager().createPreView(“depthView”, cam);
depthView.setOutputFrameBuffer(zBuffer);
depthView.attachScene(rootNode);
[/java]

And I do this when passing it to my shader:

[java]
material.setTexture(“DepthBuffer”, depthBufferTexture);
[/java]

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.