Jump to content
  • Advertisement
Sign in to follow this  

Shadow Volumes (depth-fail cap issue?)

This topic is 4731 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

I have been experimenting with shadow volumes based off the demo from codesampler.com the demo implements the depth-pass varient while I extended it to use depth-fail. I have ran into a few problems with getting my depth-fail to work correctly. Depth-pass with one light looks fine until the camera enters the shadow volume. Depth-pass One light To fix the problem of the camera in the shadow volume I used the depth-fail which fixed the problem but there are more serious ones now. Depth-fail One light no cap As you can see from the picture things look really messed up. I then relized that I needed to cap the shadow volume. This only fixed one of the problems... Depth-fail One light no cap There are still issues with the shadow over the object itself. This is where I am stuck and looking for the input from others. What could the issue be? Here is the section of code that renders the shadow volume:
g_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE,  FALSE );
g_pd3dDevice->SetRenderState( D3DRS_STENCILENABLE, TRUE );
g_pd3dDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_FLAT );
g_pd3dDevice->SetRenderState( D3DRS_STENCILFUNC,  D3DCMP_ALWAYS );
g_pd3dDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP );
g_pd3dDevice->SetRenderState( D3DRS_STENCILFAIL,  D3DSTENCILOP_KEEP );
g_pd3dDevice->SetRenderState( D3DRS_STENCILPASS,  D3DSTENCILOP_KEEP );
g_pd3dDevice->SetRenderState( D3DRS_STENCILREF,       0x1 );
g_pd3dDevice->SetRenderState( D3DRS_STENCILMASK,      0xffffffff );
g_pd3dDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0xffffffff );

// Make sure that no pixels get drawn to the frame buffer
g_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
g_pd3dDevice->SetRenderState( D3DRS_SRCBLEND,  D3DBLEND_ZERO );
g_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
//PASS 1--------------------------------------------------------
g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW );
g_pd3dDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_INCR );

g_pd3dDevice->SetTransform( D3DTS_WORLD, &m_matTeapot );
m_pShadowVolume->render( g_pd3dDevice );

//PASS 2--------------------------------------------------------
g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
g_pd3dDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_DECR );

g_pd3dDevice->SetTransform( D3DTS_WORLD, &m_matTeapot );
m_pShadowVolume->render( g_pd3dDevice );

// Restore render states
g_pd3dDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_GOURAUD );
g_pd3dDevice->SetRenderState( D3DRS_CULLMODE,  D3DCULL_CCW );
g_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE,     TRUE );
g_pd3dDevice->SetRenderState( D3DRS_STENCILENABLE,    FALSE );
g_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );

Any ideas??

Share this post

Link to post
Share on other sites
bump... I have still not been able to figure this out anyone out there know a thing about working with shadow volumes?

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!