A few questions

Hey all!

I have a few questions about BGE. (I am using Blender 2.73)

  • For lights, is the option saying “This Layer Only” not working? I have a point light and two rooms close to each other, so I placed them in two different layers - still the light coming from the point light in the first room is visible in the second room.

  • If I have several spotlights, each in different places, do they make my game run slower, even when they are not in my viewport?

  • Currently the project I am working on is a bunker with several floors and rooms. Am I assuming it right, that the whole place is in the memory, when the game is running? (I didn’t do anything that could change that.) And if that is so, how do I make it better? :slight_smile:

The BGE doesn’t use layers the same way that the Blender interface does. Once the game starts, the BGE takes all the objects on layers that are currently selected and makes them “active”. All other objects are considered “inactive” and can be added to the game with the Edit Object actuator or a Python call to the addObject method. The “This Layer Only” option is exclusive to the Blender Render and has no effect on the game engine. Generally whenever you’re working on a game, you should be in Blender Game mode (selected from the drop down menu at the top center of the Blender window). This will remove most options that aren’t available in the game engine and show other options that are.

Adding more lights to your game will increase the time it takes to render each frame. If rendering is your bottleneck, you will see a decrease in performance as you add more lights. Lights not in your view obviously still need to be handled while rendering since they still may be casting light on objects in the current view. I do not know if the BGE will automatically skip over lights that are too far away to have any effect on your current view, but regardless you should make it a habit to remove any lights you no longer need. You can always re-add them later if you have them as inactive objects.

All active objects take up memory. Generally, memory won’t be a bottleneck for most users, so I wouldn’t worry about it unless you actually start running into issues. As for rendering performance, the BGE will only render objects that are currently in the camera frustum, so you shouldn’t have to worry about objects out of view slowing down your game.

I never used that option, but as far as I remember the BGE used to separate the layers on rendering. Which means the lights are only used on objects of the same layer
… It still is like that:
-> in Multitexture mode by default,
->in GLSL mode you need to switch the “This Layer only” option at the lamp settings

Yes more lights = more to calculate = more processing time

Yes, the BGE performs static loading. Once loaded the complete scene is in memory. Be aware, scenes are loaded when you switch/add to them. That is the reason, why the BGE does not provide you the names of not-loaded scenes.

Thank you for theeó answers!

May I ask, whether you have any tips for solving my first problem?

Erm, it looks weird and interesting.

I placed the light sources all to a different layer from where my objects are - for easier editing.
Then I checked my game again (in the Standalone Player). The room I first checked didn’t receive any lights, except for a table. Then I checked the table: It had the same material as one part of the lamp. Then, realizing this, I moved an object with the same material as the wall to the layer of the lights. The walls now received the light.
So it seems that those and only those objects receive the light, that have a material, that is also present in the layer where the light source is.

I have a new question:
Is BGE still computing the lights, even when they are removed? I “End Object”-ed all of my light sources, while running the game, but the FPS rate didn’t change.

@@bergandil Yes, according to many users, bge cannot remove any light source once it started but you can try to improve your fps by similar approach to LOD so that the same light sources are constantly and only replaced to objects near you

Lighting, the thing that every user thi ks will be easy. After all, modern games have hundreds of lights, right?

Lighting is devious. Particularly in blender:

  • Lights cannt be created nor destroyed (except for libload/libfree)
  • Lights always occupy vram and gpu, even when not visible/energy=0/whatever else
  • The processor a light eats is partially dependant on what it’s lighting
  • Only spot lights have shadows.

To work around these lots of tricks can be done, such as using a limited number of lights and moving them so they only illuminate the places near the player (I’ve found 5x actual lights, 2x 512 variance shadow only and 3x 256 simple shadow only works well and looks good)

What I want to do one day is to create a proper lighting manager. I have one that kind-of-works, and I will be revisiting it shortly as I integrate it into my current project…