Sign in to follow this  
DaJudge

Problems with reusing z-buffer during multipass rendering

Recommended Posts

Hi all, I am currently trying to implement multipass rendering into my engine. Everything went nice up to the point where I wanted to reuse the zbuffer for all passes (actually this is required for the technique I am trying to achieve). A little explanation of my setup: I am rendering a scene which has a view space depth of around 200 units. I limited the z range to [1;200] for testing in order to have a good z resolution there. I am using a depth stencil surface with the format D24S8. So I have 24 bit resolution for 199 units which should definitely suffice to get some decent results. I took care to use the same position-transformations in all vertex shaders used for the different passes (in order to avoid different z-values due to different ways of transforming the vertices). I am using a z-bias during the passes where I want to use the finished z-buffer - again to avoid z-fighting. However, I am experiencing something that looks like _heavy_ z-fighting when using the z-buffer during the lighting pass. You can find a screenshot of the problem at: http://www.dajudge.com/shot2.jpg The top left image is the texture only pass which is rendered first- this is where I do my depth writes (cheapest pass). The top right image is the diffuse lighting pass. Here I want to use the depth buffer generated by the first pass - there you can see my problems. The bottom right image is simply the modulation of the two passes' framebuffers. Any ideas what I am doing wrong? I really have no clue what to do anymore... Thanks, Alex

Share this post


Link to post
Share on other sites
Okay, got it... The NVidia driver didn't like it when I cleared the stencil bits without clearing the z-bits (like I said it's D24S8). Since this is somewhat unwanted behaviour for my effect anyway I just skipped clearing the stencil bits as well... works well now.

Btw, you were right. ZBias doesn't make a difference...

For those who are interested - the fully blown 3-light source per pixel diffuse and specular screenshot (note it's DX8 & works nicely on XBOX):

www.dajudge.com/shot1.jpg

Thanks,
Alex

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