LibLoad, Linked objects and Lights. It sounds nice but it seems they don’t mix very well.
I was hoping to build a nice lighting setup where I could assign different lights that should affect different objects to optimize real time performance by baking complex lighting setups and having only selected group of objects cast shadows. There are couple of alternatives for selective lighting such as layers and lighting groups that should enable me to do so but turns out when you have a file structure that involves linking, addObject() and LibLoad the performance is less than ideal.
I thought I have quite a standard plan to my game architecture:
- There’s a base.blend that adds levels via LibLoad. Mainly contains one empty and overlay scene containing HUD.
- There are level.blends that has level meshes (mostly linked), colliders, prop objects, lights and game entity spawn points.
- Characters are in their own .blend files that are added via LibLoad to base.blend. (also tried to add them linked in each level but doesn’t work any better)
=> I need to have lights in the level.blend illuminate linked/LibLoaded meshes in character.blend when everything comes together in base.blend.
What works in terms of selective lighting:
- lighting groups when light and meshes (or material?) are in the same .blend.
- “this layer only” when light and meshes are in the same .blend
- “this layer only” when meshes are linked from different .blend and linked object link is on the same layer as the light
What doesn’t: (tested on 2.71)
A1) Lighting groups when you link object into another .blend. Even if you check “Local” that is specifically there for this functionality doesn’t work in BGE. The object simply receives no lighting from a light that you can see is in it’s lighting group. It works for rendering (F12) and after that also for game until you reload the .blend file so I think there’s some slight hickup.
A2) Lighting groups when you LibLoad. The matching groups aren’t recognized.
B1) “this layer only” when meshes are linked from different .blend and linked object link is on an inactive layer and you use addObject() to bring the object to visible layer.
B2) “This layer only” when you LibLoad. Matching layer in the different .blend files isn’t recognized. In fact only way to get working lights with LibLoad is to have them illuminate everything.
So I’m a bit confused how I should go about this after couple hours trial-and-error. There’s not enough pieces to assemble a selective lighting system in this environment. I can’t place a link to my player and enemies on an active layer, I need to be able to put them on an inactive layer so I can spawn them to certain locations when appropriate.
Did I get some part of what doesn’t work wrong by screwing something on my own?
More importantly I’m asking: Does anyone have a working selective lighting setup in distributed .blend system I could take a look at? I can change some things around in my architecture, I’m still in proof of concept phase (and it’s not looking good :P) but I wouldn’t think it’s too much to ask?