Depth Buffer problems

Hey all,

I’m trying to get a depth buffer from an alternate orthographic camera in my scene. I eventually want to pass this information into a shader so I can get an offset of how far something has sunk below a piece of terrain. My issue so far has been with the depth buffer of that camera.

What I believe is happening is I’m not getting a high enough bit depth from the depth buffer of that camera so instead of a gradient I’m getting basically black and white. Here’s my code…

props = FrameBufferProperties()
        self.bladeDepthTexture = Texture()
        self.bladeDepthTexture.setFormat( Texture.FDepthComponent ) 
        self.bladeDepthTexture.setComponentType( Texture.TFloat ) 
        self.bladeDepthBuffer ="Blade Depth Buffer", 1024, 1024, tex = self.bladeDepthTexture, to_ram = False, fbp = props)
        self.bladeDepthCam = base.makeCamera(self.bladeDepthBuffer)

If I change my texture component type to anything like FDepthComponent16 (or anything other than FDepthComponent) I get a standard RGB color image in my buffer rather than black and white values. Hope my explanation makes some sense. Thanks

EDIT: I also get a glgsg error everytime :display:gsg:glgsg(error): c:\panda_source\panda3d\panda\src\glstuff\glGraphicsBuffer_src.cxx, line 991: GL error 1282

I think it’s unsupported operation…trouble is I don’t which operation is unsupported.


I changed this in the trunk a few weeks ago. Full floats should be supported in the CVS version. However, what you really want is 24bit depth isn’t not the float?

I recommend not use… its kind of buggy. Use makeOutput instead. Just copy it from the fireflies demo.

Then if you bind to the DepthCompnent it should automagically give you 24bit integer texture in which will lookup just fine as floats in the 2nd pass shader.

Awesome, I’ll give it a shot. Time to get the lateset snapshot again. Thanks Bei, and yes you are right…I do only need 24bit, not floats. That was a mistake on my part. Let you know if it works.