Hi, I’ve been looking around for an answer to this for a while but haven’t found anything.
I’m working on putting together a top-down 2d game. I’ve put together a scene that contains an orthographic camera, a directional light angled downwards by about 40 degrees, a quad that I’m using as a background and a cube (that I’ve stretched into a long box.
At certain light angles and/or box positions in the viewport shadows stop being cast. See this image:
You can clearly see the shadow below the box in the scene view (which is showing perspective) and see that it is missing in the game view (which is showing the view of my orthographic camera).
Can anyone shed any light on this? I’m interested in creating a game with top down 2d gameplay but that still uses 3d models so that it can take advantage of Unity’s inbuilt lighting and shadows. However the shadows in particular seem to be problematic with an orthographic projection. Is the orthographic projection simply not meant to be used with 3d elements? I understand that the ortho projection “flattens” everything, but even so, I would’ve expected the shadow to still be cast in the same place in the scene I posted above.
I’ll also point out that I’d like to avoid using a perspective projection, mainly for game design reasons. This image will help to illustrate what I mean:
The image shows a perspective projection with a box and a sphere at the far left. At this camera position the box partially obscures the sphere. This is something that I very strongly want to avoid. You can imagine that in the final game the sphere could be an enemy character or item and the long box would be a wall. If the wall were tall enough the sphere might be obscured completely which would be completely unacceptable as it would be hiding information from the player which should not be hidden. But even if I don’t extend the wall height, having things partially hidden for no good (gameplay) reason is something I want to avoid.
The fact that I could find no info on this issue after extensive searching was quite surprising to me. Has no one ever in the history of Unity ever tried to use a directional light with an orthographic projection? The lack of information suggests to me that I’m looking at this wrong and shadows are not supposed to work reliably with ortho projections. Is this the case?
It’s just happening to me aswel, on some angles all work, on some none and on some angles the shadows appear in only a part of the screen…
very confusing.
same for me in 3D view, certain camera/light angles and deffered rendering make the shadows disappear for a split second.
looks to me like there is a problem with deferred rendering more then 3D or Orthographic view.
EDIT: Buy Shadow Softener or Sunshine and your shadow problems are gone,
those guys have rewritten the lighting shaders.
If anyone finds this thread without solving their problem. See shadow distance under Quality in project settings or if you are using URP/HDRP it can be found in the RenderPipelineAsset again under shadow → Distance.
This works, until you want the orthographic camera to be a large distance from the working area, to allow for a lot of working room before objects start clipping. Shadow resolution in urp seems to be designed to lower depending on distance from the camera, even though distance shouldn’t matter in an orthographic view. You can fudge the shadow cascade settings to make it work, but only at a fixed depth, before things start breaking again. I wish you could turn off shadow cascades in favor of a fixed shadow resolution…
My understanding is that one cascade essentially achieves this? Cascades let you split the resolution based on distance, so with one cascade it should be even no matter distance. I’m still unable to how make shadows look good with orthographic so I may be wrong