Problems with reusing z-buffer during multipass rendering
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
What does it do without zbias? Z is usually setup to accept values <= to what's alredy there. When using the same geometry, no bias is needed to draw the next pass, as all acceptable pixels will have a Z that's equal to what's already in the buffer.
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement