• Advertisement
Sign in to follow this  

Stencil buffer help

This topic is 3927 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 having touble using the read and write masks with the stencil buffer and wanted to clarify how they're used. Here's my example setting: D3DRS_STENCILFUNC = D3DCMP_LESS D3DRS_STENCILPASS = D3DSTENCILOP_INCR D3DRS_STENCILFAIL = D3DSTENCILOP_KEEP D3DRS_STENCILMASK = 0x11 (0001 0001) D3DRS_STENCILWRITEMASK = 0x11 D3DRS_STENCILREF = 0x11 Is this what happens?
TestValue = StencilBuffer & StencilMask

If (TestValue < StencilRef)
  StencilBuffer = (TestValue + 1) & StencilWriteMask

Share this post


Link to post
Share on other sites
Advertisement
Close. You can find more exact formulations at the "Stencil Buffer Techniques" page in the docs.

Share this post


Link to post
Share on other sites
k, so it looks like the stencil test is actuall
If ((StencilBuffer & StencilMask) < (StencilRef & StencilMask))

The docs didn't explain what gets written out though,

Is it ((StencilBuffer & StencilMask) + 1) & StencilWriteMask

or just (StencilBuffer + 1) & StencilWriteMask


Thanks,

edit:
Also I should add that I'm using DX9. The docs say you can do this, but I have no clue how you're supposed to go about writing your own formula:

Quote:

You can write your own formula for the value you want written into the stencil buffer as shown in the following example.

NewStencilBufferValue = (StencilBufferValue & ~StencilWriteMask) |
(StencilWriteMask & StencilOp(StencilBufferValue))


[Edited by - Unfadable on May 25, 2007 9:23:31 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement