Skip to main content
gamedev.net
🔒 Locked

Using the stencil buffer

Started by B_old Feb 16, 2007 at 11:26 AM 4 replies 2k views
Original Post
B_old
B_old
Hello, I want to use the stencil buffer to mask out parts of the screen while drawing my scene. But I don't understand how to setup the different renderstates. Almost all articles about "stencil" describe shadow volumes. Anyway, I want to draw a quad (or any shape) to the stencil buffer, then when I draw my scene it should only appear inside this quad. Can you help me to setup the stencil test in such a way?
B_old
B_old
Thanks, that was actually helpful.
I still don't know what D3DRS_STENCILMASK and D3DRS_STENCILWRITEMASK are for though. But I did not need them anyway.
x452Alba
x452Alba
I think setting D3DRS_STENCILWRITEMASK to true will write to the frame buffer as well as perform stenciling. Whereas setting it to false will only perform stencillng.
B_old
B_old
Wouldn't SetRenderState(D3DRS_COLORWRITEENABLE, false) do that?

MSDN says:
Quote:

D3DRS_STENCILMASK
Mask applied to the reference value and each stencil buffer entry to determine the significant bits for the stencil test. The default mask is 0xFFFFFFFF.
D3DRS_STENCILWRITEMASK
Write mask applied to values written into the stencil buffer. The default mask is 0xFFFFFFFF.

I guess I just don't really need it.


Nedelman
Nedelman
Disabling color writes does not enable stencil writes. Just like enabling depth writes does not enable color writes. These are all things that you can enable or disable as you choose. The best practice is to explicitly enable the things you need and disable the things you don't need.
www.gameprojects.com - Share Your Games and Other Projects

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.