Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


I must be misuing the stencil buffer

This topic is 5860 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''m trying to implement the shadow stencil volume method reversed in my engine, but it doesn''t work at all... I have tested my shadow volumes separately to see if they were wrongs, but they seem fines thus I must misuse the stencil buffer. Could you have a look at my algorithm? All the flags which aren''t mentioned are set to default. Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, D3DCOLOR_XRGB(0, 0, 0), 1, 0); //Render ambient color to fill the z buffer SetRenderState(D3DRS_STENCILENABLE, FALSE); RenderScene(); //Fill the stencil buffer with the shadowed area SetRenderState(D3DRS_COLORWRITEENABLE, 0); SetRenderState(D3DRS_ZWRITEENABLE, FALSE); SetRenderState(D3DRS_STENCILENABLE, TRUE); SetRenderState(D3DRS_CULLMODE, D3DCULL_CW); SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_INCR); RenderShadowVolumes(); SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_DECR); RenderShadowVolumes(); //Render the lighted part of the scene SetRenderState(D3DRS_COLORWRITEENABLE, 0x0000000F); SetRenderState(D3DRS_ZWRITEENABLE, TRUE); SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP); SetRenderState(D3DRS_STENCILFUNC, D3DCMP_EQUAL); RenderSceneWithLight(); //Set back render state value SetRenderState(D3DRS_STENCILFUNC, D3DCMP_ALWAYS);

Share this post

Link to post
Share on other sites

  • 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!