If i remember right, In the old xna 3.1 you could flip on the depth buffer with alpha test on.
turn multisample anti aliasing off and set the filter to point clamp or wrap and get a cheap quick zbuffered alpha test.
But i have no clue how what to do here whats the quickest way to get both at once or do i need to do this thru my shader now.
If so how do i work with the depth buffer within the shader.
I have no clue how to access and use that depth info within a shader (i suck with shaders).
What steps should i take ? Or in what order should i take them to do that or learn how to do that ?
To illustrate clearly.
The problem is shown below.
With depth testing on the order affects the gpu’s alpha discarding of pixels, i.e. the entire quad is set to the depth buffer regardless of transparent alpha pixels on the texture or not.
I guess im wondering if there is a way to just tell the gpu to not set the depth buffer while building up the buffers color on transparent pixels, until that pixel actually becomes opaque and to then set the discarding depth per pixel depending on alpha. In a easy way.
You need to read the alpha value, and if above a treshold (alphatest), you use clip(-1) to skip the pixel.
When you have the depth from the vertexshader:
output.Depth = input.Depth.x / input.Depth.y;
clip(-output.Depth + 0.9999f); //skip if "too far"
if (output.Color.a < AlphaTestValue)
If you prefer to avoid the depth buffer (sort of, who doesn’t like it ? ), you can sort your objects from the farthest to the closest based on the distance to the cam, on CPU, before drawing them, this is what is done in the particles sample from XNA (A “speed” mode without test to use with additive particles, and a sorted one for grass for ex).
Did you try to render only the depth in a rendertager to experiment ?
I would say you need to use the DEPTH semantic when you return the value in your pixelshader.