Lighting Layer Decided By Duplicated Object in BGE?

Check this blend file and notice that Pot 1 is in layer 1, as is the sun, whose light is set to “This Layer Only”. Thus Pot one appears lit in the editor, and Pot 2 who is in layer 2 is dark as you’d expect.

However, hit “P” to run the game engine, and notice how Pot 1 goes black too. Now change the sun to the same layer as Pot 2 and run it again, and notice they both light up, even though Pot 1 is in a different layer.

Thus It seems that in the BGE, Pot 1’s layer is ignored, and Pot 2 alone is deciding the layer of pot 1 for lighting. It’s like they’re still linked or something, but I believe I created Pot 2 by duplicating with Shift-D, not Alt-D, so they should be separate data blocks - right?

I’ve bumped into this issue a number of times in the BGE after hours of debugging, yet duplicating the default cube and lamp in the factory settings doesn’t reproduce the issue, so I’ve either found a bug in the BGE or have something to learn about of duplicated objects.

This one had me going for a while; it turns out to be the material. Both pots share the same one, and it seems that the BGE lights all objects that share a material as per only the layer of the last object to be assigned that material. Thus for example, if you create 20 different objects with the same material, place them each in the 20 different layers, create in each of those layers also a different lamp with “This layer only” checked, and the last object you made was in layer 20, all objects will only be lit with the 20th lamp in the BGE. Tracking that down 0wned a good week or two.

This means you’ll have to make a separate copy of your material for every layer that it’s going to be used in (“Polished Wood - Layer 1”, “Polished Wood - Layer 2”, etc.). A bit of a hassle cluttering your material data block list, not to mention a waste of memory when you’d like to have one material and re-use it without limit across objects, layers, scenes and even blend files.

Is this the way materials and layers have to work, or perhaps a BGE bug?