Skip to main content
GameDev.net gamedev.net
🔒 Locked

Stencil buffer

Started by D_a_M_a_G_e_D Dec 19, 2005 at 2:54 AM 1 replies 750+ views
Original Post
D_a_M_a_G_e_D
D_a_M_a_G_e_D
Can any body explain to me how the stencil buffer works and how to use it with Direct3D 9.0b, i have read some articles talking about it but none helped me. Thank you.
Armadon
Armadon
a Stencil buffer is a per pixel buffer that allows the user to stencil out parts that the user don't want to render. Stencilling as it's called is like masking out parts of the scene that you don't want rendered. The most typical usage of the stencil buffers are usually mirrors and shadows. You can look at these tutorials on using the stencil buffer.
Stencil Buffer Tutorial from NVidia
Stencil Buffer Tutorial from Me

I hope this helps.
Take care.
devronious
devronious
These are some typical present params that I use:

[source lang=c#]this.presentParams.Windowed = true;//I'm using windowed modethis.presentParams.SwapEffect = SwapEffect.Discard;this.presentParams.AutoDepthStencilFormat = DepthFormat.D16;this.presentParams.EnableAutoDepthStencil = true;


but you have to remember to clear the depth buffer at the beginning of the scene:

[source lang=c#]this.device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, System.Drawing.Color.Black, 1.0f, 0);this.device.BeginScene();//...Your draw code goes herethis.device.EndScene();


Topic Locked

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

Sign in to reply to this topic.