- Home /
Lighting on a room-by room basis
Ok, I've been wandering about looking for something that meets my need, but I can't find it so here goes:
I currently have a setup of modular rooms. Each room is it's own mesh and contains lights which must be able to be toggled on and off using that room's light switch. The problem I encounter is running the lights is that I need the light to only light the room that they are in.
There are many solutions I've seen but I can't seem to make them work for my setup, so I'll rattle off what I've tried:
Shadows: If I set the lights to cast shadows, yes, it solves this problem, but it takes a hefty toll on my fps. If there were a way of turning lights off when you can't see their illumination, that would probably work, but I can't find a decent way of doing that
Layers: Unfeasible due to the number of layers I'd need to use. Even if I'm clever and set rooms whose lights don't touch to the same layer, I'm still using a great many layers, possibly more than the engine allows
Lightmaps: If I just had on/off lighting maps for each room, and the ability to switch between them, that could also work, though it would be least preferred as it would still require dynamic lights to illuminate moving objects. Problem is lightmaps are applied per scene, and I'd need a method to combine light maps, or I'd have to make a lightmap for every possible combination of rooms being lit/unlit, and that's just dumb.
So there we have it, if you can solve my problems with any of these methods, or even point me at something else that would work, I'd be very grateful. Thanks,
Answer by yekush · Sep 30, 2014 at 06:08 PM
If each room is a gameobject in the Hierarchy, and the Lights are children of that room, you could write a simple script that checks the parent of the switch, and toggles its light siblings
I'm sorry, but I don't think you understood my question, I'm not asking how to create a light switch, what I need is to prevent lights in one room lighting things up through walls, but just having shadows on everything is too expensive and there are too many rooms for layers