   Alpha Testing in Direct3D10
  Hello,I'm writing a 3D simulation with a large number of particles. I want to apply a texture with an alpha channel to the particles, to make them appear spherical. I wanted to use simple alpha testing in order to draw only the "solid" pixels of the texture, but according to the DirectX documentation:"Direct3D 10 does not implement an alpha test (or alpha testing state). This can be controlled using a pixel shader or with depth/stencil functionality."I tried implementing alpha testing using with alpha blending, but it does not work correctly unless I sort the particles by distance. Here's why: if there are two particles, one closer than the other, and the closer one is drawn first, then the other particle is not fully drawn because the depth buffer has been updated on the ENTIRE area of the first particle (even the transparent part). Disabling depth writing also looks wrong unless I use additive blending, but that's not the effect I'm looking for, as I want to draw spherical-looking distinct particles.Sorting the particles by distance is not an option because there are too many of them.So, how can I implement alpha testing in D3D10?Thanks for your help!   
  You can use the clip() intrinsic in the pixel shader to discard a pixel.  This will only work for you if your texture is either 100% opaque, or 100% transparent, anything in between is still going to require back to front drawing order which means you have to sort your particles.There are some schemes for using multiple render targets to support out of order drawing for a limited number of objects -- there may still be artifacts.  With DX11 there are full OIT samples from ATI and Microsoft.You can also implement sorting on the GPU.There are also many ways to do very fast sorting on the CPU.  Be sure to sort only position dad so as to use the cache better, be sure that you only have one position per particle to do this.  Use previous sorted result to reduce sort times by changing the sorting algorithm.  Combine several particles together in a texture, or use an animated texture to reduce the number of particle planes that need to be drawn.  There are many options, it just depends on what you're trying to do.Dieter   ;  Yeah you can't use depth writes with transparent geometry, since you need to be able to see the geometry behind it. You can use depth testing to make sure that they're still blocked by opaque geometry, but that's about it. Then you need to sort by z so that the blending occurs in the correct order, unless you use additive blending.If you want to use alpha testing, you can just use the clip() intrinsic in the shader and pass your alpha value. If you want a threshold other than 0, then you can just do clip(alpha - threshold).   ;  Since Direct3D 10 alpha testing needs to be implemented as part of your pixel shader. You can use the HLSL clip function for this purpose.   ;  The clip() function was exactly what I was looking for, thank you!   