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

PIX HLSL debugging....pixels failing depth test?

Started by danromeo Jul 4, 2009 at 11:39 AM 1 replies 3.2k views
Original Post
danromeo
danromeo
Hey, thanks for reading this. I'm trying to test pixels for position in my shader to determine if they're on the edge of my terrain. When I debug pixels in PIX, quite often I get a message "This pixel was eliminated because it failed the depth test", and whenever that happens the pixel has this bizzare position that can't possibly be correct. Apparently this is due to a pre-test in the Z buffer to eliminate as many pixels as possible before sending them to the shader. SO... 1. What is this position info? Am I reading defunct information from a deleted pixel? 2. If the pixel is being eliminated by a depth test, why is it hitting the vertex shader at all? 3. In my shader, when I test the pixel for position, how can I tell if I'm reading bad info from an eliminated pixel (i.e., how can I tell if the pixel I'm reading has failed the depth test), so that I can discard the info? Thanks again for your help.
RDragon1
RDragon1
Quote:
Original post by danromeo
2. If the pixel is being eliminated by a depth test, why is it hitting the vertex shader at all?

3. In my shader, when I test the pixel for position, how can I tell if I'm reading bad info from an eliminated pixel (i.e., how can I tell if the pixel I'm reading has failed the depth test), so that I can discard the info?

Thanks again for your help.


2.: depth testing happens way after the vertex shader. How can you know the depth of a fragment without first transforming the verts to figure out where the primitive lies on the screen at all?

3. If the fragment fails the early-Z test, the fragment shader won't be run at all. The early-Z test is coarse and isn't per-pixel (it's usually per block of pixels). There's a real per-pixel depth test that happens after the fragment shader. If this test fails, the results of the fragment shader won't be written, so why do you need to do anything special for failed fragments? Their results won't be written, so it doesn't matter what color you output for them.
danromeo
danromeo
I know that theoretically you are correct, but...

> depth testing happens way after the vertex shader

Then why am I getting the message "This pixel was eliminated because it failed the depth test" when I debug the vertex shader?

> If this test fails, the results of the fragment shader won't be written, so why do you need to do anything special for failed fragments?

So that I can discard the info. I'm testing for position...I don't care about color. I don't want to read the position of a failed fragment, I just want to discard it. How can I tell if it failed so I can ignore it?

Topic Locked

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

Sign in to reply to this topic.