- Home /
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?
Answer by sarahnorthway · Mar 24, 2021 at 05:40 AM
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.
Your answer
Follow this Question
Related Questions
Weird Artifacts in my game lightmaps 1 Answer
Lightmapping doesn't work 1 Answer
Why do my lightmaps look blocky? (Picture) 0 Answers
Reduce lightmap size 0 Answers
Can I export my Unity lightmaps to a texture file? 0 Answers