Shadows passing through objects, why?
Hi, I'm using Unity 2018.2.17f1 without HDRP or LWRP. Just a regular base.
I have this problem when there are objects one above other one and the directional lightning set up like this.
The shadow of the object above the cube is passing through this cube and causes shadow to be visible on the cube way below (see screenshot).
What's wrong with my lightning/shadows/materials or something else. I've spent a lot of time trying to figure it out and I have no idea what's wrong.
Thank you for your help.
Answer by GhostlyFedoras · Jul 16, 2019 at 02:20 PM
I believe this might be an issue with your model, I may be wrong but looking at it The only model with the issue seems to be the one it is coming from, Alternatively You could add a different rotation to your directional light though I feel this might ruin the whole look of your game a bit.
Hi!, thank you for your answer. Unfortunately it's not just that model, every other has the same issue it's not visible on that screen tho. But the guy on the upper-left side casts the same shadow passing through the white tile.
Answer by Styro8 · Mar 22, 2020 at 01:38 AM
I have same issue, did you fixed it?
Unfortunately not. The "best" solution I haven't stick to was "fake projection of shadows" with some asset but it wasn't very well optimized for mobiles so I am going to search more.
Answer by ahsen35813 · Jul 11, 2020 at 04:43 PM
I found this answer: https://stackoverflow.com/questions/21666776/shadows-going-through-objects
I wasn't able to find the necessary shader, but I think it might work for you if you can.
Thanks for the reply. When I did my research I found this post but it wasn't the best solution to me. I decided to give up on Unity Shadows and switched to the fake blob shadows (projectors) or faking the static elements with textures. Works well for my game.
Answer by Ishnubarak · Dec 15, 2021 at 11:42 PM
Many years later now, and I ran into this same issue. In my case, the problem was that the floor itself was supposed to be casting the shadow which would cover up the shadow of the dynamic object. This is probably the line of investigation you should go down.
There are many reasons why this may be happening, but in my case it's because the floor was a static object whose shadow was cast using the lightmapper, while the dynamic object's shadow was... Realtime (i.e. Lighting Mode: Subtractive).
The lightmapped shadow coupled with the floor's lightmap resolution being too low to display a proper shadow caused the dynamic shadows to show up where the floor's shadow should be instead. Once I had the static object's shadow properly cast, this was no longer a problem