How to disable lightmaps at runtime

Hello,

I have a system in my game where the environment, under certain conditions, becomes pure black and is illuminated only by a direct local light. The standard environments are lightmapped, so I need to figure out some hackery to disable the scene’s normal lightmap data and replace it with blackness. I’ve tried a number of potential hacks to no avail (replacing the level’s lightmap data with an empty array, grafting the lightmap data from a pure black dummy scene, baking multiple lightmaps for the same scene and swapping them, transparent overlays, etc.)

What are my options here?

Yeah LightmapSettings.lightmaps = new LightmapData[]{}; removes the lightmap textures but doesn’t set the renderer back to using realtime environment ambient color, fog, etc.

I hackily solved this in Unity 2020 by setting Renderer.lightmapIndex to -1 on every Renderer (also Terrain) that uses baked lighting. I’d love to know if you ever found a better solution.