Sign in to follow this  

Strange Shadow Volume Artifacts

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

Hello all! :) I am experimenting with shadow volumes with Direct 3D 10. I actually made them work... but I have a problem... If the light is not moving the shadows are perfect. If I move the light I get some weird artifacts.. something like.. flickering edges of shadow volume. If I stop moving the light the shadow are perfect again! I can't post some screenshot because when I try .. the moment I hit the Print screen key while moving the light.. the artifacts disappear! Generally.. every action that drop the fps of the engine removes the artifacts at that moment.. I am realy confuzed :/ In order to draw the shadow volumes i use a dynamic vertex buffer.. my main code is this:

// Ambient Pass
drawSceneAmbient( camera );
for( int il = 0; il < (int)mLights.size(); il++ )
{
   renderer->clearFrameBuffer( vp->getRenderTarget(),false,false, true, 1.0f,0);
   renderer->setBlend( disableColorBuffer );
   renderer->setShaderModel( shadowVolumeShd );
   // Calc shadow volume
   // Do not cast shadows from mObjects[0].. it is the floor
   for( int io = 1; io < (int)mObjects.size(); io++ ){
   mObjects[io]->calculateShadowVolume( renderer, mLights[il]->mPosition, true, camera );}
   // Render backfaces
   for( int io = 1; io < (int)mObjects.size(); io++ )
   {
      renderer->setRasterizer( cullfront );
      renderer->setDepth( depthStencilBeforeSVINC );
      mObjects[io]->renderShadowVolume( renderer, camera );
   }
   // Render Front faces
   for( int io = 1; io < (int)mObjects.size(); io++ )
   {
      renderer->setRasterizer( cullback );
      renderer->setDepth( depthStencilBeforeSVDEC );
      mObjects[io]->renderShadowVolume( renderer, camera );
   }

   renderer->setDepth( depthStencilAfterSV1 );
   renderer->setBlend( blendOneOneAdd );
   drawSceneNormalFromLight( camera, il );
}
// Depth Stencil States:

// depthStencilBeforeSVINC:
//    Depth Test:  True
//    Depth Write: False
//    Depth Function: LESS
//    Stencil test: True
//    Stencil Mask: 0xFF
//    Stencil Function: ALWAYS
//    Stencil Fail: KEEP Depth Fail: INCR Stencil Pass: KEEP

// depthStencilBeforeSVDEC:
//    Depth Test:  True
//    Depth Write: False
//    Depth Function: LESS
//    Stencil test: True
//    Stencil Mask: 0xFF
//    Stencil Function: ALWAYS
//    Stencil Fail: KEEP Depth Fail: DECR Stencil Pass: KEEP

// depthStencilAfterSV1:
//    Depth Test:  True
//    Depth Write: False
//    Depth Function: EQUAL
//    Stencil test: True
//    Stencil Mask: 0xFF
//    Stencil Function: EQUAL
//    Stencil Fail: KEEP Depth Fail: KEEP Stencil Pass: KEEP
Do I have some mistake when I configure the stencil states? Thanks for your time!

Share this post


Link to post
Share on other sites

This topic is 3484 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.

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