- Home /
Dynamic object is not casting shadow to static object after baking GI using subtractive mode
I am baking the lighting for a scene and my character is not casting shadow after I bake the lighting. The character is casting shadow before baking.
I am using URP
Answer by HaruLee932001 · Jan 12, 2021 at 03:56 PM
Hi @lokesh5shelva_unity ! I got the same problem as you.
Static objects, after baking, no longer RECEIVE shadows from Dynamic objects. To fix this, find the Mesh Renderer components on Static objects that you need to bake, then check Contribute Global Illumination. After that, at the drop down Receive Global Illumination, choose Light Probes instead of Lightmaps. Recap: Mesh Renderer -> Contribute Global Illumination -> Receive Global Illumination -> Light Probes
Brief explaination: when you bake your Static objects, all their lighting data (including shadows) is now stored in the Lightmap. Then, at runtime (play mode), Baked Static objects will take the data from Lightmap to lit objects themselves (imagine when you bake Static objects, they don't have any shadow on them, so Baked Lightmap doesn't contain any shadow data on the Static objects, when play, Static objects take that data and lit themselves which doesn't have shadows on them). If you follow my solution above, Baked Static objects now will take the data from Light Probes to lit themselves instead of Lightmap.
What I just explained is not 100% accurate, it bases on my knowledge. So if you want to know more, I think you should dive in Lightmap and Light Probes. I found out how to fix this while testing and reading: https://blogs.unity3d.com/2019/08/28/static-lighting-with-light-probes/
Another similar problem you might encounter in the future is Baked Static objects don't CAST shadows on Dynamic objects. Solution for this, you can read at: https://support.unity.com/hc/en-us/articles/207820473-Mixed-mode-lighting-my-baked-objects-are-not-casting-shadows-on-RealTime-objects
Answer by Hossam_justDice · Feb 17 at 10:30 AM
I had the same issue. The solution for me was to assign the main directional light as my "Sun Source" under Windows>Rendering> Lighting> Environment> Sun Source
In Subtractive Lighting Mode, all Mixed Lights in your Scene provide baked direct and indirect lighting. Unity bakes shadows cast by static GameObjects into the lightmaps. In addition to the baked shadows, one Directional Light, known as the Main Directional Light, provides real-time shadows for dynamic GameObjects.
As stated in Unity's documentation.
Your answer
