The only difference between tex2DProj and tex2D is that tex2DProj should do the perspective divide (by w) for you, while tex2D does not. If tex2DProj doesn’t work correctly, that sounds like a driver bug, or your w coordinate is not right.
I found the push bias thing to be totally unnecessary.
My golden rules for shadows:
Disable color write for the shadowcam render. This gives at least a 300% performance increase. You can try to disable shaders for the shadowcam render too, if they don’t do any deformation.
The shadowcam render MUST be backwards culled. Only the backsides of surfaces must cast shadows, this completely entirely removes the artifacts, as the backfaces of objects are dark anyways (if you cut off the dot product at 0, which should be done anyways)
This won’t fix it for objects which are infinitely thin, use glPolygonOffset for those. E.g, something like:
Or, in 1.7.0, you can write:
(you can also specify this in the egg file, with the “depth-offset” scalar)
After this, the self-shadowing artifacts / moire patterns should be gone entirely and makes you able to set the push bias to 0 (get that ugly code out of your shader! )
PS. The shadow system found in latest CVS Panda does all these things for you.
treeform, that’s because you only have shadows, not shading. The back faces of objects are always shadowed anyways, so making polygons facing away from the light black solves the artifacts - normal dot product shading does this.