How to add more than 4 lights in gltf model

My gltf model has more than 50 lights but can only load up to 4 lights in the scene, I refer to this example:

But this method doesn’t seem to be able to be used in the gltf model

The amount of lights in a scene will be limited by the amount of Uniform Buffer Objects that can be processed by the shader: Uniform Buffer Object - OpenGL Wiki (khronos.org), but I think that should be more than 4. I’m not sure if GLTF itself has some kind of limitation on the number of lights @bghgary is there any?

The number of lights available actually is defined at
material.maxSimultaneousLights = 16; // 4 by default

So you need to choose which materials will have more lights, then test performance. With 50 lights browser may crash. Usually when there is a lot of lights in the scene one may use some logic to reduce the number of active lights (for example, making them dynamically change their placement depending on conditions).

2 Likes

glTF has no limitations on the number of lights.

Thanks for your answer, I know what you mean but this API cannot work in the gltf models,I find gltf models’ light’s attribute not belong to the material node. so It seem that I can’t achieves it by this way. Arguably, it will be find at KHR_lights | Babylon.js Documentation (babylonjs.com)