Sign in to follow this  
Maskotti

Sharing depth buffer with off-screen render targets

Recommended Posts

Hello, I'm having a little problem with the glow effect. I'm rendering glowing objects into a non-screen-size texture, and then adding some blur via pixel shader. Then I render this texture with screen-size quad, and the effect works just fine. Only problem is that the glowing shows even if there was a wall between camera and glowing object - I guess the depth buffer should be shared with the off-screen render target, but I'm not sure how to do this. I appreciate if someone could give me any help or comments.

Share this post


Link to post
Share on other sites
You should be able to use the same depth buffer then you render to the glow map as long as long as it is the same size as the back buffer (or larger but it will match pixels and depth buffer entries one-to-one). If the glow map is smaller I'm afraid that this is not going to work.

When all other geometry has been drawn to the back buffer and the corresponding depth buffer you switch render target to a glow map that is equal in size to the back buffer, and render all glow with ZWRITE set to FALSE. Then what ends up in the glow map will be correctly occluded at places where other geometry would be. Then you apply blur and render it back to the back buffer as you described.

I'm not sure though how you would go about it if you have a glow map which is smaller than the depth buffer, and thereby not compatible with it.

Share this post


Link to post
Share on other sites
Quote:
Original post by staaf
You should be able to use the same depth buffer then you render to the glow map as long as long as it is the same size as the back buffer (or larger but it will match pixels and depth buffer entries one-to-one). If the glow map is smaller I'm afraid that this is not going to work.

When all other geometry has been drawn to the back buffer and the corresponding depth buffer you switch render target to a glow map that is equal in size to the back buffer, and render all glow with ZWRITE set to FALSE. Then what ends up in the glow map will be correctly occluded at places where other geometry would be. Then you apply blur and render it back to the back buffer as you described.

I'm not sure though how you would go about it if you have a glow map which is smaller than the depth buffer, and thereby not compatible with it.


Yep, that's exactly my problem. I was just thinking if there's some kind of 'hack' doing this with different size depth buffers...

Edit: I want to use smaller off-screen-target because screen-size texture becomes real bottle neck.

Share this post


Link to post
Share on other sites
I'm afraid that this 'hack' would be using a lockable depth buffer and manually copying the data from the fullscreen depth buffer to a smaller one corresponding to the off screen render target. I guess it would work but I don't think it's any better than using a full size off screen target. If I'm not mistaken a lot of cards don't support lockable depth buffers, so you'd have to do it all in software.

Share this post


Link to post
Share on other sites

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