# Stencil buffer help

This topic is 4140 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
Close. You can find more exact formulations at the "Stencil Buffer Techniques" page in the docs.

##### Share on other sites
k, so it looks like the stencil test is actuall

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

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]

1. 1
2. 2
3. 3
Rutin
18
4. 4
5. 5
JoeJ
13

• 14
• 10
• 23
• 9
• 55
• ### Forum Statistics

• Total Topics
632638
• Total Posts
3007598
• ### Who's Online (See full list)

There are no registered users currently online

×