Can AlphaTest not update the Z-buffer?

I’m currently using MS DirectX to draw terrain maps, but it has a big problem and I’m thinking of changing to OpenGL.

I’m using AlphaTest to remove background pixels from a bitmap, but I need the removed pixels to not update the Z-buffer.
Is the OpenGL AlphaTest able to do that?

In DirectX, removed pixels appear to update the Z-buffer, which requires objects to be sorted in Z-order, which I can’t do. Is OpenGL any better at this? DirectX and OpenGL appear identical, I’m hoping they’re not in this instance.

I see a post from a few days ago asks a similar question, but I’d like a more definitive answer.

Mike Henry

In the OpenGL rendering pipeline, alpha testing occurs before depth (z) testing during fragment operations.

I believe if a pixel fails the alpha test, it is discarded and no further processing is done on it. So, it shouldn’t have a chance to get to depth testing and write to the z-buffer.

No, it definitly doesn´t. A pixel which gets rejected by the alpha-test does not change the depth-buffer. This is because the depth-test is the last one in the pipeline (at least in OpenGL).

You can render lots of geometry using the alpha-test without bothering about back-to-front rendering.
BTW: It´s the same behaviour for stencil-testing.

However, it surprises me, that Direct3D should not be able to do this. Are you sure about that?

Jan.

From Jan: " However, it surprises me, that Direct3D should not be able to do this. Are you sure about that? "

Mike: No I’m not sure. Two sources claim that a failed alpha test should not update the z-buffer but in my tests it does. Maybe I should look closer at my code or test results before making a drastic change.

Mike