PDA

View Full Version : Depth buffer and stencil buffer / Alpha test



greg2
08-04-2004, 05:49 AM
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.

Thanks.

plasmonster
08-04-2004, 01:57 PM
Have a peek at this, it might just answer your questions.

http://fly.cc.fer.hr/~unreal/theredbook/chapter10.html

greg2
08-04-2004, 10:35 PM
I have already read this chapter.
But it's not very clear.

They write that a fragment passes or are rejected with stencil test and alpha test.

For me, a fragment stores color, depth,...
Isn't it ?

The stencil and alpha test should affect the depth buffer?

Sumpfratte
08-04-2004, 10:51 PM
Hello,

Yes, you're right.
If a fragment fails at a test, there shouldn't be drawn values in the buffers, usually.

Do you have some sample code?

Sumpfratte

greg2
08-04-2004, 11:08 PM
Yes, you're right.
If a fragment fails at a test, there shouldn't be drawn values in the buffers, usually.
Ok. Thanks.
If i have the time i will try to code a simple test tonight.

plasmonster
08-05-2004, 12:50 AM
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.