- Home /
How to bake a light onto a non-static object?
First off, this feels like a simple question, but I haven't been able to find the answer anywhere.
Say I have, in Unity, a desk with a lamp on it, which is always turned on, and which just illuminates the desk a bit--in other words it isn't very bright and doesn't really affect anything else except the desk top. I want to be able to move the desk around during gameplay, but the lamp can just stay where it is on the desk (the lamp is a child of the desk). As a result, I would like to be able to bake the light just onto the table. Is that possible?
Yes, I'm aware of that, but unless I misunderstood you, I don't think that's the solution. I want to be able to bake the light from the lamp onto the table, but still be able to move the table around. The reason is that no matter where the table is, the lamp light will hit it in the same way--thus I don't think the light needs to be rendered in real time.
Pretty sure @iwaldrop is correct with the first part. Bake to the table only. Good to go. If light is directional, no need to have realtime lighting unless you're rotating the table. This will bake just the table in the lightmaps, using just the baking lights.
Well, then lets assume that you misunderstood me, because statically baked objects aren't allowed to move by default. So, bake the table, then unset the static flag via code at runtime. $$anonymous$$eep in $$anonymous$$d, however, that this is a very unorthodox kind of thing to do.
$$anonymous$$ark as static in lightmaps. There's different types of static. You should be able to move it after baking if it's static in lightmaps.
No, you can't. Although there are several different flags, static is static is static. You have to unset the flag if you want to move the object.
Answer by iwaldrop · Jan 11, 2014 at 11:55 PM
You can choose to only bake selected objects. Then, in order to move the object around in the scene, it has to be reset to non-static by setting the gameObject.isStatic flag to false.
Answer by Sledzislaw · Jan 11 at 07:10 PM
Solution above is not working as expected in animated models like mine: machine with animated doors. Machine's doors are not animating anymore, no matter that they are non-static.
My fix in this case is to: 1) prepare scene as it should be set up in build, 2) disassemble machine from all moving parts, so every static surface is exposed 3) turn all problematic elements to "static" 4) clear baked data 5) generate lighting 6) undo (ctrl+z) all changes made to state from 1)
works_in_my_case :)
Your answer
Follow this Question
Related Questions
Black stains on texture after making object static 0 Answers
Can I cast real time shadows on lightmapped objects? 2 Answers
Static object not so static... 1 Answer
Lightmap and Non-Static Object 0 Answers
Preserve lightmap on instantiated object 0 Answers