Jump to content
  • Advertisement
Sign in to follow this  
khm666

Dark Shadow Volume intresection !!

This topic is 4756 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, I'm using stencil shadows volume for my engine much like codesampler.com & z-Fail technique that described in gamedev.net, its all working fine for me except that when 2 shadows intersect i see darker shadow area for intersection, which should not be - all shadows must have same color- ,here is what i mean Click to enlarge I'm using the Big Square for shadows, does anyone has a clue for removing those dark intersection areas ?

Share this post


Link to post
Share on other sites
Advertisement
Are you using the algorithm like this :

for each shadow :
{
1 - activate the stencil
2 - draw the shadow volume
3 - change the stencil modes
4 - draw the quad
}


or like this :

1 - activate the stencil
2 - draw ALL the shadow volumes
3 - change the stencil modes
4 - draw the quad

??

If you say the first one, then use the second method. But if you already do as written in the second method, then I don't know why you have those darkened areas. And in this case, maybe a little more details about your implementations will help us helping you ^^

Share this post


Link to post
Share on other sites
i tried to use the second method,but now i have one shadow rendered only but i'm using Big Square for each mesh object i have , in the sample above i use three squares for the three meshs, should i make it one square for every objects in the scene ? or its no problem ?, also here is my effect state file for shadow:

technique ShowStencilShadow2Sides
{
pass p0
{
ZWriteEnable = false;
StencilEnable = true;
CullMode = None;
ShadeMode= Flat;

StencilFunc = Always;
StencilZFail = Decr;
//StencilFail = Decr;
StencilPass = Keep;

StencilRef = 0x1;
StencilMask = 0xFFFFFFFF;
StencilWriteMask = 0xFFFFFFFF;


AlphaBlendEnable = true;
SrcBlend = Zero;
DestBlend = One;

TwoSidedStencilMode = true;
Ccw_StencilFunc = Always;
Ccw_StencilZFail = Incr;
//Ccw_StencilFail = Incr;
Ccw_StencilPass = Keep;


}
}

technique RenderStencilShadow2Sides
{
pass p0
{
ZWriteEnable = false;
StencilEnable = true;
Zenable = false;
ShadeMode= Flat;
CullMode = None;


AlphaBlendEnable = true;
SrcBlend = Srcalpha;
DestBlend = Invsrcalpha;

StencilRef = 0x1;
StencilMask = 0xFFFFFFFF;
StencilWriteMask = 0xFFFFFFFF;

TwoSidedStencilMode = true;
Ccw_StencilFunc = Always;
Ccw_StencilZFail =Incr;
//Ccw_StencilFail = Incr;
Ccw_StencilPass = Keep;


StencilRef = 0x1;
StencilFunc = Lessequal;
StencilPass = Keep;
}
}


[Edited by - Coder on October 11, 2005 3:53:34 PM]

Share this post


Link to post
Share on other sites
It doesn't come from the render states.
It comes from the number of quads you're using ^^ For N shadow, you should only have 1 quad.

Share this post


Link to post
Share on other sites
Thanks for that ,i like the theory N shadows have 1 quad :)

I used one quad, but now only the last mesh shadow is rendered, i.e if i have three meshes just the third shadow will be drawn !! here is my code, effects are the same above:


////////Render Shadow for all mesh
for(int i=0;i<MaxMesh;i++)
{
d3d_device->Clear(0, NULL,D3DCLEAR_STENCIL, D3DCOLOR_ARGB(0, 170, 170, 170), 1.0f, 0 );
getEffect()->SetTechnique("ShowStencilShadow2Sides");
getEffect()->Begin(&numPasses,0);
for(unsigned int i=0;i<numPasses;i++)
{

getEffect()->BeginPass(i);
d3d_device->SetFVF(D3DFVF_XYZ);

d3d_device->DrawPrimitiveUP( D3DPT_TRIANGLELIST, g_NumOfVert/3,m_pVertices,sizeof(D3DXVECTOR3) );

getEffect()->EndPass();
}
getEffect()->End();
}

//////////////Then render the quad
getEffect()->SetTechnique("RenderStencilShadow2Sides");
getEffect()->Begin(&numPasses,0);
for(unsigned int i=0;i<numPasses;i++)
{
getEffect()->BeginPass(i);

d3d_device->SetFVF( ShadowVType );
d3d_device->SetStreamSource( 0, m_pBigSquareVB, 0, sizeof(ShadowVertex) );
d3d_device->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );

getEffect()->EndPass();
}
getEffect()->End();



Why do i have one shadow for the last mesh only !!??

[Edited by - Coder on October 11, 2005 3:50:52 PM]

Share this post


Link to post
Share on other sites
It looks like you're clearing the stencil buffer inside of the loop. That's why only the last mesh's shadow is displayed. The other ones (stored inside of the stencil buffer) are being cleared on each iteration of your loop.

Edit: Also it looks as though you are using two loop variables called i when redering the meshes. This may be causing some trouble.

- Neil

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!