Hi,
I'm working on a CSM and I don't know which way should I choose. I'm using a geometry prepess which gives me a depth map from the camera's view, so I'm using a separate fullscreen pass to compute the shadows (so I can't use the clip planes as a solution)
1)
- create [numSplits] render target, render each shadow map to the right buffer
- switch to shadow calculation pass
- bind every texture to the shader
- in the shader, use dynamic branching, like
if (dist < split1) { texture2D(shadowmap1, texcoord); ... }
2)
- create only one render target and draw the shadow maps as a texture atlas (left-top is the first split, right-top is the second, etc...)
- switch to shadow calculation pass
- bind the only one texture
- in the shader, use dynamic branching, which calculates the texcoords where the shadow map should be sampled.
And here comes my problems with both way. The target platform is OpenGL 2.0 (think to SM2).
1)
If I know well, the dynamic branching in a shader under SM3 is a "fake" solution. So it will compute every branch and evaluate after. It won't be so fast to compute shadows for each split then make the decision later. Especially, I'm using PCF, and in SM2, the instruction count is not infinite.
2)
With 4 splits and 1024 shadow maps, the texture size would be 2048x2048, And maybe this is the best case... imagine 2048 shadow maps which would use 4096x4096 texture.
However the 2nd solution still looks more viable. But I'm not sure about the texture arrays in OpenGL 2, is it available?
Thanks,
csisy