OK, I have made a scene (HDRP) with a set of spotlights in a grid. They are all identical: static, mode:mixed, volumetric off, shadow map on. When I bake the lighting, I get random results.
The good ones show a large "spot" on the terrain. When I toggle the enable checkbox in the Inspector, the spot goes on and off. Scripts can control the intensity.
The bad ones have a small spot. Toggling the checkbox has no effect. Scripts can't control intensity either.
Attached is the baked lightmap view and the shaded view. Any clues much appreciated. Using 2019.2.0f.1.
(I tried area lights too. They are a little different, but no better. And the light spread is too wide; that is why I wanted spot lights.)
P.S. If I change mode from "mixed" to "realtime", they seem to work. But it seems to sort of defeat the purpose.
More info. The problem lamps were made from a prefab with a small plane and a spotlight, at the same location. I moved the spotlight slightly down below the plane and saw a little change, but still broken. I learned how to display some map previews which look odd.
I created a brand new project from the HDRP template, and added just a plane and 8 identical spotlights. (And of course HDRP settings and scene settings.) Almost everything has default values. When I bake lighting, I see 2 spots in the lightmap (which are stuck, I guess they really were baked) and 6 lights which work (presumably real-time). Directionality and shadowmask also look odd with different lights in each one.
Based on how I'm using the lights (adjusting them with scripts), I think they really need to be Realtime. I've changed the mode of all of them, behavior satisfies me.
[I am curious why everything seems to go wonky when I have more than 4 baked spots in a scene... Happens instantly if I have 4 and add/enable #5. Surprisingly, both HDRP and the default pipeline seem to have the same odd behavior. Mystery for another day, or Unity devs.]
Unity lighting is an extremely deep subject, and I'm probably out of my depth.
It could be that your lightmap resolution is too low. I mentioned it a bit in the course, but if the resolution is too low you'll lose some of the lighting information and get very low quality baked lighting. That might be the first thing to adjust.
Another thing it may be is the limit on how many shadows and/or lights that can be baked in your scene. I would first disable shadows being generated from those lights to see if that works. If you notice all your lights work with shadows disabled for some, that means you've reached your shadow limit.
You could also increase the amount of shadows/lights you can use in your scene. Since we're using HDRP you'll need to modify those settings in the HDRP asset created initially. Here is a screenshot of where you can update that info:
Click on the HDRP asset in your project panel, then in the inspector locate the "lighting" section. You'll see the settings shown in the image near the bottom of this section. On mine max shadows is set to 128. You can bump that up to see if that resolves the issue and/or use shadows for lights that actually need it.
While I doubt you have that many, you can also increase the "Maximum Punctual on Screen" light setting. Punctual lights are spot/point lights.
Thanks jgonzalez I'll try to experiment when I have time. I tweaked some of these, but there are a lot of things to try. For now, things seem to be working well.
There's a lot to the lighting system in Unity, especially with HDRP. Lots of things to look at and tweak to see where the issue could reside. Sometimes when I have trouble with stuff like this I just add in a very basic scene with just a plane and some cubes and experiment with that. It's much easier to break things down.