I have tried to use the stencil buffer to render my scene only in some area of the screen.
It works with color buffer.
But it dosen’t work in depth buffer (my scene is written everywhere in the screen and not just in the area i have drawn in the stencil buffer).
Do i have make something wrong or is it simply not possible.
Same question for alpha test:
If i use alpha test to display only some part of my scene. What will be written in the depth buffer.
The stencil and alpha test should affect the depth buffer?
The relevant section from chapter 10:
The tests and operations occur in the following order; if a fragment is eliminated in an early test, none of the later tests or operations take place.
Scissor test
Alpha test
Stencil test
Depth test
Blending
Dithering
Logical operation
As you can see, stencil and alpha tests come before the depth test. So, if either of these tests fail (indeed, any test at all), then no depth value will be stored in the depth buffer.