sphereCenter = Vector3::Zero;
for (int i = 0; i < NUM_CORNERS; i++)
{
sphereCenter += frustumCorners[i];
}
sphereCenter /= NUM_CORNERS;
sphereRadius = Vector3::Distance(sphereCenter, frustumCorners[0]);
sphereBounds = sphereRadius * 2.0f;
float nearClip = 1.0f;
float backupDist = 20.0f + nearClip + sphereRadius;
float farClip = backupDist + sphereRadius;
camPosition = sphereCenter - light->direction * backupDist;
view = Matrix::LookAt(camPosition, sphereCenter, Vector3::Up);
proj = Matrix::Orthographic(sphereBounds, sphereBounds, nearClip, farClip);
viewProj = view * proj;
[attachment=9724:s1.JPG]
[attachment=9723:s2.JPG]
EDIT:
I compiled a Release from the code, here is the binaries, if someone would like to try it.
[attachment=9725:ShadowTest.zip]