Sign in to follow this  

dx10 how to enable stencil test???

Recommended Posts

Hi i´m making a shadow volume implementation and i´ve some doubts how can i render something with stencil test enabled??? i mean, i can change the depth stencil state. The stencil buffer is supposed to be filled with a previous render pass. Now i want to draw pixels only where the stencil is greater than zero i´m using this state ID3D10DepthStencilState *dx10_ds_state = NULL; D3D10_DEPTH_STENCIL_DESC ds_desc; ds_desc.DepthEnable = true; ds_desc.DepthFunc = D3D10_COMPARISON_LESS; ds_desc.DepthWriteMask = D3D10_DEPTH_WRITE_MASK_ALL; //stencil D3D10_DEPTH_STENCILOP_DESC stencil_op_front, stencil_op_back; ds_desc.StencilEnable = true; ds_desc.StencilReadMask = 0xFF; ds_desc.StencilWriteMask = 0xFF; stencil_op_front.StencilFunc = stencil_op_back.StencilFunc = 3D10_COMPARISON_GREATER; stencil_op_front.StencilDepthFailOp = stencil_op_back.StencilDepthFailOp = D3D10_STENCIL_OP_KEEP; stencil_op_front.StencilFailOp = stencil_op_back.StencilFailOp = D3D10_STENCIL_OP_KEEP; stencil_op_front.StencilPassOp = stencil_op_back.StencilPassOp = D3D10_STENCIL_OP_KEEP; ds_desc.FrontFace = stencil_op_front; ds_desc.BackFace = stencil_op_back; HRESULT hr = idevice->CreateDepthStencilState( &ds_desc, &dx10_ds_state ); if (FAILED(hr)) return; else idevice->OMSetDepthStencilState( dx10_ds_state, 0 ); is this the way of preventing a pixel to be drawn in the screen if the stencil has a value grater than zero??? thanks edit: how can i debug each pixel value in the stencil buffer???

Share this post

Link to post
Share on other sites

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