No shadows with custom projection matrix

Hi,

We are building a project that requires a custom projection matrix to render on a tiled viewport across multiple machines. So far so good, I have been able to fed the FSceneViewProjectionData with a custom projection matrix, accounting for a custom matrix from ULocalPlayer::GetProjectionData if one is provided.

Although, we have noticed some issues this causes to shadows. It looks to me that once the projection matrix is changed, object outside a “certain bounds” are not taken into account, and they do not cast any shadow. This doesn’t seem to depend on the shadow settings, cascades, quality or fade out values, and so on. In fact, if I increase the bounds of a static mesh I can manage it to cast shadows. Although I don’t feel artificially increasing the mesh bound is the way to fix it. The following image hopefully clarify what is the problem.

On the image above, objects on the red areas do not cast shadows. The camera is originally positioned on the centre of this set up, and its projection is enlarged 3 times on the X axis and moved by an offset to accommodate the displacement.

On the image above, instead, objects at the edge of the scene are correctly taken into account for shadow projection.

Hopefully you can advice us on what to look at, and why giving a custom projection matrix can cause shadows not to be cast properly.

Thanks,
Fabio

A projection matrix that contains translation is off-center, and in the past there have been a lot of assumptions in the renderer that the projection matrix will be centered. Some of these have been fixed for VR, which uses translation in the projection matrix to implement the eye positions. However those are small offsets so bugs may show up with larger offsets.

Since the casting or not is per-object, it’s almost certainly due to the CSM cull plane setup in FDirectionalLightSceneProxy::GetViewDependentWholeSceneProjectedShadowInitializer which doesn’t know about your projection matrix translation. That’s all I can guess at without debugging it myself.

Thanks Daniel, it sounds a good starting point. I will have a look and let you know.

Cheers,
Fabio