We are creating a maze for a mobile game. We want to use instanced meshes for decoration of walls, floors, arches, doors. Materials have a limit on the number of light sources (maxSimultaneousLights). That’s why we disable the point light, which is located far from the camera.
To get rid of the render delay you may use this light with zero intensity in the beginning - https://playground.babylonjs.com/#8IMNBM#368
And control all meshes in your scene (include them into light computing or exclude them):
In our scene we use a large number of instanced meshes.
Instanced mesh is one material, one texture for meshes, it’s less calculations and smaller scene size.
We tried increasing maxSimultaneousLights and using intensity (even before creating this topic on the forum). This does not work with instanced meshes.
In this example, you can see how the light stops turning on (use W and S for camera movement).
After several light sources, the limit is triggered. By increasing the limit we will break the scene.
Only intensity is used here:
This example shows how well turning on the light with setEnabled works:
In this example, setEnabled works with a smooth increase in intensity (this is what we need):
But we get frame loss at the first light switch when there are much more polygons.
We are ready to detain the player before the start of the game in order to run through the entire map for the first time to turn on the light. But it seems strange. Maybe there is another way?
Hey there, here’s an example I made from your last playground to show another approach using pooling to reuse the lights. It uses just 7 lights instead of 40 (you can check the node tree in the inspector to see how many are created). Since they’re always enabled hopefully the initial stutter will be fixed in your final project as well.
The light arrays pushing and popping as @Blake suggested is a good approach. Since you have a lot of lights in your scene you’ll need a kind of LightManager anyway, arrays are the simplest solution here.
@Blake Wow! Great idea After loading the map from Blender, I will be able to record the coordinates and properties of the points of light. I will be able to move the light to where the player expects to see it.
@labris The idea of using the intensity property works! I will try to combine this with the movement of points of light.