Question regarding cascaded shadow map

1.can cascaded shadow map be implement with out using texture array ?

I try to run the sample code provide in NVIDIA OpenGL SDK 10 on my ATI 4670 video card with latest driver but the application report loaded of shader compilation error.

Look like the error are from the code using array texture.

If I dont using array texture in fragment code but just using hardcode declaration of multiple depth texture (I only plan to use 2 split anyway) will some thing like this work ?

uniform sampler2D shadow1;
uniform sampler2D shadow2;

if(//some selection logic based on z value){
//compare depth using texture 1
//compare depth using texture 2

2.about how to set up view matrix for directional light source (for basic shadowmap and not related to above question) ?

I alway use perspective projection and treating my direction light source as a point in the air that shine to certain point (in this case origin) thus the look up code become

//view matrix
                                Matrix lightViewMatrix;

//projection matrix

Matrix lightProjectionMatrix;				lightProjectionMatrix.createPerSpectiveMatrix(45.0f,(float)shadowWidth/(float)shadowHeight,nearPlane,farPlane);

the createLookAtMatrix and createPerspectiveMatrix above is just a emulation of glLookAt/gluPerSpective for use with my GL 3.2 code.

It give a somewhat correct result and easy to understand. but every where I read they suggest using orthogonal projection wide enough to capture the scene and glLookAt code that involed negative light direction,this is the part that I dont understand.

Please someone give me an idea for how to set up view/projection matrix for directional light source.

  1. Yes, layout your cascades in a texture-atlas (often 2x2).

  2. A directional light is an orthographic projection, you can’t sensibly use a perspective projection instead. I don’t know what you’ve read, but I suspect the “negative light direction” you mention arises from calculating the direction FROM the vertex TO the light, not the light-direction from the light.