Point Light Unexpected Behaviour (some light, some don't?)

This is hard to describe, but I feel like the (badillion) point lights I generated aren’t equally affecting the sculpture in the scene. Please see here (Login • Instagram) (cool, right?). What I think I’m noticing is that it doesn’t look like some of those lights are lighting the sculpture (?), and I think they’re lighting it less towards the top (?). It’s hard to discern, but I think something is subtly incorrect, here is my code:

Is there anything I should be on the lookout for?

            //light experiment
            //generate some random positions based on the architect movement;
            var lpx =
              this.body.position.x - Math.random() * 50 * randomFlip(flips);
            var lpz =
              this.body.position.z - Math.random() * 50 * randomFlip(flips);
            var lpy = 0 + Math.random() * 400; //* randomFlip(flips);
            //create a lightsphere
            lightSphere = BABYLON.Mesh.CreateSphere("Sphere0", 16, 0.5, createScene.scene);
            lightSphere.material = new BABYLON.StandardMaterial("red", createScene.scene);
            lightSphere.material.diffuseColor = new BABYLON.Color3(0, 0, 0);
            lightSphere.material.specularColor = new BABYLON.Color3(0, 0, 0);
            lightSphere.material.emissiveColor = new BABYLON.Color3(1, 0, 0);
            //give it the position
            lightSphere.position.x = lpx;
            lightSphere.position.y = lpy;
            lightSphere.position.z = lpz;
            //add it to the array
            lightSphereHolder.push(lightSphere);
            //create the light
            light = new BABYLON.PointLight("Omni0", new BABYLON.Vector3(0, 10, 0), createScene.scene);
            light.diffuse = new BABYLON.Color3(1, 0, 0);
            light.specular = new BABYLON.Color3(1, 0, 0);
            //give it the position
            light.position.x = lpx;
            light.position.y = lpy;
            light.position.z = lpz;
            //add it to the array
            lightHolder.push(light);

Because of performance reasons there is a limit for the amount of active lights. The default is 4. You can try to increase the maxSimultaneousLights property of your materials. The maxium possible value for this depends on your GPU if you use WebGL 2 (on my onboard Intel GPU it stops working with more than 9).
I think with WebGL 1 you can go much higher but the performance may be bad.

4 Likes

Oof, yes, I saw this in the docs and then promply forgot about it, thank you!

1 Like