When generating the shadow maps you are enclosing only the “visible” area (created by the view frustum). This doesn’t make sense, as things above the player, even if not directly visible to the player, can still cast shadows visible to the player.
Lock the near plane of the shadow-map projections to include any objects above the player that can cast shadows visible to the player.
Right, thanks. I've changed the bounds for each cascade to be large enough to encompass the entire scene, just for testing purposes, and that does give me better results:
The other problems (self-shadowing and different intensity) are directly related with the other problem I believe:
I'd like to see the whole fragment shader. Are you performing a comparison between the fragments position and the shadowmap value somewhere?
The return value from GetShadowCoefficient is literally just multiplied with the diffuse color. I've tried a comparison like so:
[...] shadowCoord.w = shadowCoord.z; shadowCoord.z = float(index); shadowCoord.x = shadowCoord.x *0.5f +0.5f; shadowCoord.y = shadowCoord.y *0.5f +0.5f; float z = shadow2DArray(csmTextureArray,shadowCoord).x; if(z < shadowCoord.w) return 0.25f; return 1;
However that only gives me proper results for the first cascade, after that it's just cut off: