I think that the ue4 projection matrix has some “requirements” …i have fixed all rendering problems doing these “magic stuffs”:
result.M[2][2] = 0.0f;
result.M[3][0] = 0.0f;
result.M[3][1] = 0.0f;
result *= 1.0f / result.M[0][0];
result.M[3][2] = GNearClippingPlane;
where result is your off-axis proj matrix
Other important point: be sure to update all related matrices:
View->ProjectionMatrixUnadjustedForRHI = CalculateOffAxisProjectionMatrix(Viewport, location);
FVector viewOrigin(0.0f, 0.0f, View->ProjectionMatrixUnadjustedForRHI.M[3][3]);
View->ViewMatrices.ViewMatrix.SetOrigin(View->ViewMatrices.ViewMatrix.GetOrigin() - viewOrigin);
View->InvViewMatrix = View->ViewMatrices.ViewMatrix.InverseSafe();
View->ViewMatrices.ViewOrigin += View->InvViewMatrix.TransformPosition(-viewOrigin);
View->ViewMatrices.PreViewTranslation = -View->ViewMatrices.ViewOrigin;
View->ViewMatrices.ProjMatrix = _AdjustProjectionMatrixForRHI(View->ProjectionMatrixUnadjustedForRHI);
View->ViewProjectionMatrix = View->ViewMatrices.GetViewProjMatrix();
View->InvViewProjectionMatrix = View->ViewMatrices.GetInvProjMatrix() * View->InvViewMatrix;
FMatrix TranslatedViewMatrix = FTranslationMatrix(-View->ViewMatrices.PreViewTranslation) * View->ViewMatrices.ViewMatrix;
View->ViewMatrices.TranslatedViewProjectionMatrix = TranslatedViewMatrix * View->ViewMatrices.ProjMatrix;
View->ViewMatrices.InvTranslatedViewProjectionMatrix = View->ViewMatrices.TranslatedViewProjectionMatrix.InverseSafe();
View->ShadowViewMatrices = View->ViewMatrices;
//View->InvDeviceZToWorldZTransform = CreateInvDeviceZToWorldZTransform(View->ProjectionMatrixUnadjustedForRHI);
GetViewFrustumBounds(View->ViewFrustum, View->ViewProjectionMatrix, false);