Jump to content

Lights and light.range and max lights per mesh


fenomas
 Share

Recommended Posts

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:

  1. 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?
     
  2. 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?
     
  3. 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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

Thanks folks, I think I have the general idea..

Lots o' lights: https://playground.babylonjs.com/#WJWSNL  :D 

 

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?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...