Jump to content
  • Advertisement
Sign in to follow this  
DizzERR

depthbias or not depthbias?

This topic is 5409 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 using stencilshadows with z-fail technique. light facing polygons are reused to create front and back caps of shadowvolume. there is a problem with coplanar occluder polygons and shadowvolume polygons. i use depthbias then: //scene render ... m_pd3dDevice->SetRenderState( D3DRS_DEPTHBIAS, 0x1); m_pMesh->Render( m_pd3dDevice ); ... //shadowvolume render ... m_pd3dDevice->SetRenderState( D3DRS_DEPTHBIAS, 0x0); m_pd3dDevice->DrawPrimitiveUP( D3DPT_TRIANGLELIST, m_dwNumVertices/3, m_pVertices, sizeof(D3DXVECTOR3) ); ... D3DRS_SLOPESCALEDEPTHBIAS is default. but depth artifacts still present!!! when i change depthbias in shadowvolume render wonders begin: //scene render ... m_pd3dDevice->SetRenderState( D3DRS_DEPTHBIAS, 0xf); // <--DOESNT MATTER 0x0 or 0x1 or 0xf ... //shadowvolume render ... m_pd3dDevice->SetRenderState( D3DRS_DEPTHBIAS, 0x1); // <--DOESNT MATTER if non zero ... i mean that if in shadowvolume render depthbias != 0 all shadow occluders are INSIDE the shadowvolume i.e. shadow is everywhere. increasing depthbias in scenerender gives nothing. wtf???

Share this post


Link to post
Share on other sites
Advertisement
I heard the depth bias amount varies a lot between graphic cards, that's why it's no longer even supported by some modern ones. It was on a thread in this forum actually, can't seem to find it though.
I guess a small offset to fix coplanar volmes against its own polygons would be the easiest way, I always hate doing doing hacks like that though.

Share this post


Link to post
Share on other sites
You can 'fake' depth bias by tweaking the near and far clip planes further out, which causes a slightly lower depth value to be calculated for the same world space coordinate.

Share this post


Link to post
Share on other sites
have you tried this:


//scene render
Depthbias = -0.01; //biased visible
//shadow volume render
Depthbias = 0.0 //off


//ALTERNATIVELY:
Depthbias = 0.01; //biased occluded
//scene render
Depthbias = 0.0; //off
//shadow volume render


you should be able to use just the first one.
use F2DW() to pass the floats to your renderstate.

Share this post


Link to post
Share on other sites
Quote:
Original post by Lee_
I heard the depth bias amount varies a lot between graphic cards, that's why it's no longer even supported by some modern ones. It was on a thread in this forum actually, can't seem to find it though.
I guess a small offset to fix coplanar volmes against its own polygons would be the easiest way, I always hate doing doing hacks like that though.

ZBias is what varied between cards and drivers. However, with DX9, Depth bias and slope-scaled depth bias states have been added to correct that - and indeed, they work as they should. But they aren't supported on everything.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!