- Home /
Shadows produced by non-static objects are lighter than baked shadows
I created a scene from scratch in 2019.3.7f1. So the relevant lighting settings are default:
Default Skybox
Shadowmask Baked Gl setting enabled
Intensity Multiplier set to 1 for both Env Lighting and Reflections
Bounces set to 1 for Env Reflections
In addition, like any default scene, there is one Directional Light set to Mixed mode.
I added a cube in an enclosed room (made up of 6 cubes stitched together so that no light can pass through).
The following is the lighting situation inside the room without baking. All objects are non-static:
Now I make all the walls static (and leave the enclosed cube dynamic). I would expect Unity to calculate the same light situation and simply apply it as a lightmap. Instead what I get is a proper dark room.
The questions are the following:
Why the difference?
Why the enclosed room is so bright in the non-static example in the first place? Nothing should get through and the only light should be the Ambient.
How do I make so that the dynamic object inside the enclosed environment will receive the shadows from the walls/ceiling?
Thanks!
Answer by Namey5 · Apr 06, 2020 at 11:13 AM
What you're seeing here aren't shadows; this is global illumination (GI). In reality, light doesn't just stop once it hits something - some is bounced, some is absorbed, etc. In this case, the light you are seeing is ambient lighting from the environment/skybox. That doesn't really make sense, because you can't actually see the skybox from inside the room - no light can enter from the outside, so the room should be black. GI is fairly difficult to do in realtime due to the sheer amount of information processing required, so most GI has to be baked and can therefore only effect static objects. More recently some new realtime GI techniques have been proposed, but this is still emerging technology. If you want your dynamic objects to be effected by global illumination, you can use light probes;
https://docs.unity3d.com/Manual/LightProbes.html
You can think of these as small pre-baked panoramic captures of the scenes static lighting - place a group of them and a dynamic object is able to blend between the closest probes to approximate local GI.
Answer by collederas · Apr 06, 2020 at 12:37 PM
Thanks @Namey5 ! I have been doing some more reading and experimenting in the meanwhile and mixing that to your answer I think I get it.
In the first case nothing is baked so even if my Directional Light is set to Mixed, there is basically no GI impact in the scene; at that stage it is behaving like a Realtime Light and therefore contributing only direct lighting to my Scene.
Then, when I set objects to static and go through the baking process, GI is applied. This contributes to much richer details (indirect light is now part of the game) and the scene looks darker. At this point changing any Ambient light setting will only affect Dynamic objects as the rest is just a texture.
So Answers are:
Because of the impact of GI which is visible only after baking the lights.
Because it is lit by the Skybox without GI at all. Apparently the Skybox only produces indirect light that it is not at all considered unless some sort of GI is enabled.
Using light probes!
Also watch out for reflections with the standard shader. Light is split into a few different paths - direct lighting (from light sources), indirect lighting (GI) and reflections. Even though it may look better, there is still a bit of light leaking because the scene is only reflecting the skybox. You can also use reflection probes (baked or realtime) to get around this.
Your answer
Follow this Question
Related Questions
What am i doing wrong with Lighting? 1 Answer
Shadowmask shadows not showing 0 Answers
HDRP double sided light problem 0 Answers
Baked lights with realtime directional causes black shadows 0 Answers
Lightmapping Problem 0 Answers