Depth Buffer and deferred rendering

Started by
12 comments, last by dingojohn 13 years, 8 months ago
I forgot to say a couple things.

1) Turn off color writes for stencil volumes.
2) Turn off depth writes for stencil volumes and lights.
3) Turn on depth reads for stencil volumes.
4) Turn off depth reads for lights. (doesn't really matter here)
Advertisement
Yeah, that was what I was thinking. However, "solved" my depth problems is not exactly right, as I still have no clue as to how I am going to utilize the texture as the depth buffer for the second pass, as I am not using MRT for that, due to the fact that I render to the window. Depth testing that I have to use for the stencil generation works with the current depthbuffer unless I am mistaken. In this case as I do not use MRT that would be the window's own depth buffer, and not my custom texture that I just rendered to in order to use the info to reconstruct position.

I might be missing something quite simple, but I'm still not getting anywhere.

Quote:Original post by dingojohn
For this I need to utilize the depth that is written to the texture to do depth testing against backfaces of the light volume (and perhaps also front faces), but I'm not sure how I can do that, as for the second pass I draw directly to the window's default framebuffer.


To do depth testing using a depth texture that you've previously written to, you need to attach it to your FBO. As far as I know, you can't attach depth textures to the special framebuffer FBO 0. Your options are:
1) draw your second pass to an FBO with your depth texture attached (which will make opengl use it for depth testing) and also a new color texture attached, then do a third full-screen pass to simply write the color texture to the framebuffer. This is what I do, and it's when I apply my tonemapping.
2) insert a full screen pass before your second pass. In this new pass, draw to the special framebuffer FBO 0 and you read from your depth texture and in your fragment shader set the fragment's depth to what you read from your depth texture.

I'd strongly recommend option 1 because then you have you scene's color in a texture, which is useful for all kinds of post-processing.
Thanks for the info. There's flying some rate++ towards you!

I'll try this now and hopefully everything will work out brilliantly.

Thanks a bunch!

This topic is closed to new replies.

Advertisement