Sign in to follow this  

Render to texture, depth info lost

This topic is 3310 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 3310 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this