Render to texture, depth info lost

Started by
4 comments, last by deadstar 15 years, 5 months ago
Hi, I'm trying to do the following: 1) Render some geometry to an FBO 2) Render the FBO's texture in ortho, through a pixel shader 3) Render some more geometry The problem is, there's no depth information kept, so anything rendered in step 3 is superimposed directly over the top. Any solutions to this, or do I need to sit and rethink the process? Thanks in advance

"The right, man, in the wrong, place, can make all the dif-fer-rence in the world..." - GMan, Half-Life 2

A blog of my SEGA Megadrive development adventures: http://www.bigevilcorporation.co.uk

Advertisement
The depth component is rendered separately to the depth attachment on FBO. You can copy it back to depth buffer in your second pass, or you can bind it as texture and output the depth value from the pixel shader (writing to gl_FragDepth).
Thanks very much for your reply. I think I've got the first bit set up correctly, I now have a texture with depth info. I can't find any info on doing the second part though:

Quote:Original post by snoutmate
copy it back to depth buffer


I'd like to keep this step out of shaderland if possible.

"The right, man, in the wrong, place, can make all the dif-fer-rence in the world..." - GMan, Half-Life 2

A blog of my SEGA Megadrive development adventures: http://www.bigevilcorporation.co.uk

Still struggling with this one, anyone got any tips?

My FBO setup gives me colour and depth textures, and the depth texture looks all nice and depthy!

How can I copy the depth texture back into the depth buffer?

"The right, man, in the wrong, place, can make all the dif-fer-rence in the world..." - GMan, Half-Life 2

A blog of my SEGA Megadrive development adventures: http://www.bigevilcorporation.co.uk

Quote:Original post by deadstar
1) Render some geometry to an FBO
2) Render the FBO's texture in ortho, through a pixel shader
3) Render some more geometry


is (3) actually rendering to the back-buffer?

If so, I think that FBO's depth buffer and the default back-buffer's depth buffer cannot be used together. So at step 3, you have to be rendering into another FBO (or reuse the one from step 1) with the same depth attachment.
I don't want to render back into an FBO, I want to display the FBO previously created by drawing to a quad, but I want the depth info in there too.

I've created and rendered to my FBO (colour AND depth textures), put it through a shader for some effects, and I can draw it back to the screen. What I want to do now is put the depth buffer back too, so I can continue drawing primitives and have the depth calculated properly.

I hope it makes sense. All I want to do is render a texture to the depth buffer.

"The right, man, in the wrong, place, can make all the dif-fer-rence in the world..." - GMan, Half-Life 2

A blog of my SEGA Megadrive development adventures: http://www.bigevilcorporation.co.uk

This topic is closed to new replies.

Advertisement