# draw only on stencil buffer monogame

Exactly as the question says. Is there a way i can draw vertices only into the stencil buffer.

Basically i want to perform some operations on some vertices of a mesh and based on the result, draw passing vertices only onto the stencil buffer of the screen

This is part of the GraphicsDevice.BlendState. Set ColorWriteChannels to none. (https://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.blendstate_members.aspx)

• ok that disables write to the color buffer , but how do i enable write to the stencil ? Oct 5 '16 at 9:13
• use GraphicsDevice.DepthStencilState w/ StencilEnable = true. All the stencil ops are in there (and depth ops) Oct 5 '16 at 17:17

I have to do like this:

//Disable writing to screen
BlendState disableColorBufferState = new BlendState();
disableColorBufferState.ColorWriteChannels = ColorWriteChannels.None;

spriteBatch.Begin(SpriteSortMode.Immediate, disableColorBufferState, null, stencilAlways, null, alphaTestEffect);
//draw here
spriteBatch.End

//Enable it again to draw another model
BlendState enableColorBufferState = new BlendState();
enableColorBufferState.ColorWriteChannels = ColorWriteChannels.All;
spriteBatch.Begin(SpriteSortMode.Immediate, enableColorBufferState);
spriteBatch.End();

//Draw another 3D model here