Unity 5 Shadows Do Not Render in Game View with Custom Projection Matrix

Has anyone had the issue with Unity 5 shadows not rendering when upgrading from Unity 4 to Unity 5 when using a custom projection matrix as mentioned here:

In Unity 4, as long as you had the rendering in Forward rendering and had certain quality settings the shadows would show up, but now upgrading to Unity 5, the shadows only show in the editor scene view, but not the game view with the same settings. Is there additional setup or something I need to change?

1 Like

Do they work in the editor?

Our shadows have stopped working in builds since upgrading to 5 and switching to deferred, but they run fine in the editor. But I don’t believe we use a custom matrix

I’ve yet to see shadows on terrain with the default shader. :frowning:

@Alabatross , the shadows appear in the Editor’s scene view, but not in the Editor’s Game View when not in play mode. In play mode, nothing shows up as well in game view. This is in forward lighting mode.

In Unity 4 they still kind of worked, but in 5 they don’t appear at all.

Is there a new or better way to access shadows, or make our own shadows with shaders in Unity 5? Unity 4 made it kind of a pain.

@KEngelstoft , could you ask someone on the team if this is a bug, or if this is an intended functionality in Unity 5, and there are specific steps we need to take to get shadows to work correctly with custom projection mtrices, as it does in Unity 4? I was going to file a bug report, but I didn’t want to do that unless somebody could confirm this is a bug or not. Thank you.

1 Like

Just to make sure I’m also having this same issue,
I see the amazing new lighting just fine in the editor, but there are no shadows in the build. (Aside from some shadows on trees that appear to clip through the terrain)
Is that the same issue as yours?

(Image below shows my issue, editor on the left, build on the right)

Voxel, are you on U5? We’re having the same issue

Yes, I am.
Glad to know I’m not the only one having this issue.

I thought it might be related to the DX3D version, but forcing DX3D9 or DX3D11 makes no difference sadly.

Good to know I’m not alone either, our shadows do exactly what yours do and even show through other objects

It’s odd, it seems like the terrain isn’t receiving shadows.
The trees in the build have the correct shadows, and project shadows correctly onto other trees.

I guess it’s possibly a Unity bug. What OS are you running? Not that it should make any difference but I’m on Windows 8.1 Pro, exporting my builds for Windows. (Both x86 and x64)

I also have this problem on a custom projection matrix, I don’t have shadows on Unity 5 (had them fine on Unity 4) but if I increase enough the near clip plane they appear but not correctly, they go through objects emmiting the shadows and the shadows direction changes when I rotate the camera (also in my case I recompute the projection matrix according to the camera rotation).

I don’t think it’s the terrain specifically that’s broken, our shadows are glitched and showing through buildings in a very similar way

I’m on Win 7

So, no updates from anyone at Unity?

@Aras , do you think you can take a look at this issue in Unity 5, or perhaps ask someone about the problem?

You are on to something Alkann, try setting near and far used during shadow map rendering to the same value as the camera’s near and far.

Might I ask how to access the near and far during shadow map rendering? Do we need to do this through a shader? I’m kind of unsure how to access shadow maps in Unity 5’s new shader setup.

1 Like

I’m sorry but I don’t really understand what I should do, if it’s about shaders I don’t know where to start i never tried yet to mess with them.
All I do is modifying the camera projection matrix in a LateUpdate, no render to texture (Unity free version).

I tried to find something else in the manual and api refering to a near and far plane but without success, only cameras seem to have those so I was thinking maybe you meant to set my near plane using the api rather than the editor.
Just in case I did it (set to 15f in my scene) before and after the matrix modification but no changes.
I’ll make a video of what happens normally, what it does when I activate my custom matrix then adjust the near plane to show what happens with shadows. I just need the time to encode and upload, I’ll maybe edit this post to share the link.

UPDATE:
I warn you my spoken english is REALLY bad.
Shadows direction is wrong, not depending of the directional light orientation, depends of the camera orientation. Also appearing above objects, as if depth was wrong somewhere, not able to know if an object is supposed to be in front or behind of the shadow emitter.
At the end of the video I don’t know what I want to say, it’s just to show quiclky how GL computes shadows step by step with the projection matrix, maybe someone more used to work with this will see something interesting.

https://www.youtube.com/watch?v=r6X-xzBo0dY

The video will be available once youtube encoding done.

1 Like

I setup a .unitypackage for Unity 5 with my scene here. It can be downloaded and run. You can see that no shadows appear whatsoever in Forward rendering with the custom projection matrix. To move the skewed camera left/right/up/down, just click and hold the left mouse button and drag the mouse around.

Also, it’s worth noting this is how I currently feel:

For anyone that is absolutely stuck with this issue and needs it to work now, the Sunshine plugin with the right settings will get the shadows working again in Unity 5. It’s not a cheap plugin, but it at least does what Unity 5 should be doing.

If you have questions on how to setup Sunshine to work with the custom projection matrix, I spoke with the Sunshine developer and he generously walked me through how to do it. Now that’s what I call great customer service. You can PM me if you want the steps to getting Sunshine setup correctly with the custom projection matrix.

@Alkann I’d suggest you submit your problem to Issue Tracker and try to up-vote it to get more attention.

I submitted the problem to Unity http://fogbugz.unity3d.com/default.asp?682681_sdd4me9tvi999tbv right now it’s not visible on the Issue Tracker, I hope it will be.