   Depth Map texture generation
  Hello!As a part of a game that I'm working on I need to use shadow maps to create our shadow effects. For that I need a depth map. The technique I've used before works fine using the fixed pipeline, but it has one obvious flaw: It doesn't work well with transparent occlusion, like trees for example. The trees will be basically a group of intersecting quads on the trunk, with either 1.0 or 0.0 alpha values. We're not having any mid-values.I need to create a depth map that calculates the depth of fragments behind those "holes" in the original texture, so that they will pass the depth test for the 2nd pass.I'm not sure exactly how to do that though I tried one way that didn't really work. For now this wasn't even handling the transparencies, but eventually it will:In the vert program I transformed the vertex with the modelview matrix, got its magnitude and divided it by the max-clip to min-clip ratio to get a 0.0-1.0 value, and passed it through a varying float.Then in the frag program I used the float from the vert program as the color like this vec4(ratio,ratio,ratio,1.0);In the final version I'll be sampling the bitmap and check for the alpha to determine whether it is 1.0 or 0.0.So far, using the way I explained I got a blank white picture. I tried changing the clipping ranges, but it didn't work.   
  Maybe I'm not understanding your problem, but why don't you just render your shadow map with alpha testing turned on? That way the pixels under a certain alpha (say 0.5) will get discarded and not written to the depth map. This will work the same regardless of shader vs fixed function.  Also if for some reason you can't use the alpha channel (maybe your using it for bloom amount or something) you can just go if (textureColor.a < 0.5) discard;in your shader to achieve the same effect at a small performance cost.Now, if you're trying to do translucent stuff you need to use a more complex algorithm like layered shadow maps. But with only 0 or 1 values the simple solution should be ok.[Edited by - LucasM on April 27, 2009 8:32:58 PM]