Camera custom matrix, shadows not working anymore - Unity5

Hello,
First time I have to ask people to help me with a problem, I usually try to find by myself but here I think it could take a lot of time.

Some months ago I made a custom matrix projection for my camera (Camera.projectionMatrix) and it always worked perfectly, no shadows filckering, no objects disappearing so near and far clip planes work finely. I just had to increase the values for the far plane and in Quality settings increase the value for max distance shadow to avoid having them flickering.
I can’t avoid to use my custom camera it’s the “key” to play my game, the matrix is ajusted to give a specific view of the scene according to the position and orientation between the mobile screen and the user face.

The problem appeared with Unity 5, now I don’t have shadows anymore whatever the values applied to far plane and max distance for shadows, when I switch back to the normal mode by deactivating my matrix modification in real time I can see the shadows but with my custom matrix I have no shadows.
My objects are ~100 unity far from my camera, my near plan is 0.3 and far plane 1500
I found my shadows reappear when increasing the NEAR plane to ~20 but their behaviour is really strange, they rotate according to the camera orientation.


Do you know if there have been changes with the way shadows are computed between Unity 4 and 5? If so what had been changed or is there a way to go back to the way they acted in Unity4.
If I find nothing I will have to go back to Unity 4 but Unity5 seems more interesting and next updates won’t happen on 4 so it would really be better to find a way to make it work with u5.


I don’t think it would be useful to let my code on this work with matrix projection since it’s not simple at all to understand why I put this or that value here or there but I can at least give for an example my custom matrix and the original one but I don’t think it will help.

29 fov, 27 near, 1500 far.

Here is my matrix with a normal behaviour :

2.17622	0.00000	0.00000	0.00000
0.00000	3.86671	0.00000	0.00000
0.00000	0.00000	-1.03666	-54.98982
0.00000	0.00000	-1.00000	0.00000

and here is the custom one with the same situation :

2.13346	0.00000	0.00000	0.00000
0.00000	3.79075	-0.00144	0.00000
0.00000	0.00000	-0.51833	-27.49491
0.00000	-0.00038	-1.00000	0.00000

As you can see no big differences but it seems like the way shadows are computed with the matrix projection changed between Unity 4 and 5.

See the fix here:

Only good though if you are on 5.4 or higher