- Home /
Transforming Lightmaps at Runtime
Hello!
I have a situation where I have a rotating platform with lights on it, existing in a sunny exterior. I'd like to use lightmaps/probes to bake lighting on the rotating platform, while having the "exterior" sunlight casting dynamic shadows on the platform. Is there a way to somehow rotate a lightmap/probe at runtime? Or perhaps transform the lookup based on the world transform of the platform?
Thanks!
Answer by AlejoLab · Feb 10, 2014 at 01:23 AM
Light probes cannot be rotated but you can use a trick setting up light probes anchors for every object in your scene in an off-camera space and rotate those instead of the lightprobes. It can be easy depending on how flexible you want the system to be. The simplest version would be to have a script attached to every object that will move the anchor counterpart inside the local space of a gameobject-parent. That parent will be rotating in the oposite direction of your rotating platform, apparently lighting your real objects in front of the camera as if the lightprobes were rotating.
The lightmaps are a different matter. But I assume for your question that the sunlight is going to be dinamic and will be dominant. Anyway, the trick may work for very obvious visual features, such as coloured lights, since the dominant lighting would still comes from sunlight and will make any other lightning very subtle.
If you really need this to work across different situations and scenes in your game you will probably need to find a proper way (like transforming yourself the light data you get from GetInterpolatedLightProbe). But if it is a simple scene in a specific situation maybe you can just use some trick like this one.