fenomas 205 Report post Posted February 20, 2018 Hi, quick questions. I have a big scene (500+ meshes), over a reasonably large area, which uses octrees. My use case is, I'd like to add many short-range point lights to the scene - think fireflies - that have a small "range" property and thus only affect a small number of meshes. In other words, the scene would have more than 4 lights, but each mesh will be lit by fewer than 4 lights. My questions: Is it correct to assume that a light's range property does not interact with the "4 lights per mesh" limitation? In other words, if I add a point light with range=1 to my scene, every mesh in the scene is "lit" by that light even if they are far away, right? It looks like the correct/only way to do what I'm asking for is to add meshes to each light's includedOnlyMeshes array. Is this right? Is it correct to assume that includedOnlyMeshes doesn't know about octrees or parent/child relationships? In other words, if I want a point light to only affect the meshes in a particular octree, I need to add all those meshes to the light's includedOnlyMeshes array, and their children, right? Thanks! Quote Share this post Link to post Share on other sites
JohnK 991 Report post Posted February 20, 2018 Slow response to question 1. The demo is a little rough and ready but in the following scene a number of 'planets' are each lit by their own 'sun'. The range on the 'sun' is such that it lights only its own planet. https://www.babylonjs-playground.com/indexstable#2KUJS7#1 Quote Share this post Link to post Share on other sites
JCPalmer 725 Report post Posted February 20, 2018 I see nothing involving the .range of a light where they get bound. There is a _lightSources property of AbstractMesh. It can updated in. I would look into that first, cause I am not sure when / if this gets called. IncludeOnlyMeshes for each light seems like another way to go. If it helps, the max can also be changed at the material level. One thing I do is attach a point light to a camera, which moves / rotates to match the light to the camera in a scene.beforeCameraRender. This can really reduce the number of lights needed in the first place. Does a part of the scene really need to have a light when it is not on the frame. Quote Share this post Link to post Share on other sites
Deltakosh 4315 Report post Posted February 20, 2018 1. Unfortunately no. The range is used to compute the quantity of energy received but not to remove a mesh from a light's activeMeshes list (mainly because the cost to evaluate to distance to the mesh is prohibitive) 2. Correct 3. Correct More about how lights are tied to meshes here: https://github.com/BabylonJS/Babylon.js/blob/master/src/Lights/babylon.light.ts#L406 Quote Share this post Link to post Share on other sites
JCPalmer 725 Report post Posted February 20, 2018 canAffectMesh in link from @Deltakosh (where the includedOnlyMeshes is evaluated) is in done in a loop of this.getScene().lights, so you need to make sure that lights with the includedOnlyMeshes are early in the array or all the slots could get filled up with lights that are too far away. Quote Share this post Link to post Share on other sites
fenomas 205 Report post Posted February 21, 2018 Thanks folks, I think I have the general idea.. Lots o' lights: https://playground.babylonjs.com/#WJWSNL Follow up question for @Deltakosh: If a light has an includedOnlyMeshes array, and all of the included meshes are not rendered (e.g. due to frustum culling), that light won't have any performance impact on the scene since it's not bound to any meshes, right? Or in other words, if I maintain an accurate list of included meshes for a light, I assume there's no need to disable the light when its outside the view frustum? Quote Share this post Link to post Share on other sites
Deltakosh 4315 Report post Posted February 21, 2018 This is correct. Lights are only impacting performance at render time 1 fenomas reacted to this Quote Share this post Link to post Share on other sites