- Home /
Mixing baked and real-time shadows and real-time performance
Hello everyone.
I have a two-part question about lightmapping and dynamic shadows which I haven't been able to find a good answer to.
Question 1: How would you mix baked and real-time shadows if you want them to be cast by the same light source? I've tried using the same light source for first baking the lightmap and then setting it to real-time for it to render dynamic shadows of moving objects. This just causes the same light source to be cast a second time on top of the lightmap making it even brighter than it was before. Am I doing something wrong?
Question 2: What is the most performance hungry part of real-time lighting with shadows? Is a small scene with a lot of small shadow-casting objects more demanding than a large scene with a small number of large shadow-casting objects if there is only 1 light source?
Answer by MakeCodeNow · Sep 21, 2014 at 03:43 AM
1) The whole idea behind dual lightmaps is to support this kind of workflow. Near the camera the dual lightmaps only store bounce lighting and the local lighting + shadows comes from the dynamic light. Far away, the dynamic shadows are disabled and the lightmaps switch to baked versions. Is there a reason dual lightmaps don't work for you?
2) The specifics vary depending on a lot of specifics, but usually the main cost is the draw calls for all of the shadow casting objects. You basically have to have one draw call per shadow casting object per light source that casts shadows from that object. Directional light shadows use cascaded shadows which basically act like a unique shadow casting light source per shadow slice. Basically, the former is probably more CPU intensive while the latter is maybe more GPU intensive, but on most platforms CPU time is harder to come by than GPU time.