I am trying to experiment between different shadow mapping approaches:
I really only need global illumination in my game, and it has to be vast. My idea is to use
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:
palmleaves.setAttrib(DepthOffsetAttrib.make(1))
Or, in 1.7.0, you can write:
palmleaves.setDepthOffset(1)
(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.
That does produce much better stuff - but there is still problem with paterns on the back faces - its not very noticeable but the artefacts is still there.
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.
that is true, but the backface is not 100% black, what if i have ambient lighting and stuff. That causes problems. I want to solve that with shadows only.