So, I have CSM working. Looks great. In order for it to work properly, I need to figure out the cascade index in the pixel shader and then do the multiply with it's 1 of 4 matrices (one for each map) again in the pixel shader. I'd rather do this in the vertex shader, but then I get shadows with lines across it (shadow, no shadow, shadow, no shadow, etc.).
Is this possible to do in the vertex shader? If so, any ideas how?
Maybe I can't do this because of the nature of the shadow, it really does need to be a pixel operation. It just sucks I have to pass all 4 matrices into my pixel shader for the operation.
You cannot generally do it in the VS because a triangle can cross over cascade boundaries. If you can guarantee that it doesn't (using frustum checks on the CPU) then you can do it on the VS.
Typically for orthographic projected cascades you only need to do a single vector by matrix transform. Each cascade can then be done via a bias and scale operation which is a single MAD operation per cascade check.
To elaborate more on what Alias said...all of your cascades are going to use the same light direction, which means that the bounding boxes formed by the projection for each cascade will all be aligned to the same axes. With that in mind you can transform from the coordinate space of one cascade to the coordinate space of another cascade by figuring out how much to translate, and how much to scale. Ultimately it should be just a just a bit of math in shader, and it shouldn't even be a blip in terms of performance on GPU that's not more than 5 years old.