Jump to content

light includedMeshOnly meditation


pichou
 Share

Recommended Posts

Hi everyone, I come here to share with you something 

While working on a project, I had issues because of the maxSimultaneousLights for a material. Indeed my scene can have a lot of lights. Rather than increasing the maxSimultaneousLights parameter, I thought it would be more performant to check what was the mesh around the light depending on its range. So I ended up with this code

checkIncludedMeshes () {
    let includedContent = [];
    for (let i = 0; i < scene.meshes.length; i++) {
      let mesh = scene.meshes[i];
      if (mesh.absolutePosition) {
        let dist = BABYLON.Vector3.Distance(this.light.absolutePosition, mesh.absolutePosition);
        if (dist < this.light.range) includedContent.push(mesh);
      }
    }
    this.light.includedOnlyMeshes = includedContent;
  }

But then I ask myself: "Why is it not the default light behaviour in BABYLONJS?"

I guess there would be performance issues doing that.

Anyway, I wanted to have your opinion on this and I thought that could help the community! ;) 


 

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...