Jump to content

Prevent light from escaping through planes/meshes


foumfo
 Share

Recommended Posts

Hey everyone, I'm back with yet another question.

I have a scene that contains a labyrinth with walls and ground tiles and a pointLight:

//light
    var light = new BABYLON.PointLight("light", new BABYLON.Vector3(0, 0, 0), scene);
    light.intensity = 1.9;
    light.range = 20;
    light.diffuse = new BABYLON.Color3(150/255,150/255,150/255);
    light.specular = new BABYLON.Color3(180/255,150/255,100/255);

As you'll see in the following screenshot (sorry no playground because I'd have to copy a lot of code from many different files), the light escapes through the walls - planes.

Is there any way to prevent that? I think it also causes low fps for me when i move the light and the camera

Screenshot-2018-3-21 http 127 0 0 1.jpg

Link to comment
Share on other sites

22 minutes ago, kurhlaa said:

Hi,

What about setting light.range = 20; to a smaller value? 20 looks too much for your scene.

if I use a value smaller than that then the reach is to short, you wont be able to see ahead.

Link to comment
Share on other sites

10 hours ago, V!nc3r said:

The classic way is to activate shadows (even in a raytrace engine, if you doesn't activate shadows in your lamps, light go through all objects).

But maybe a more optimized way could be to dynamically update the includeOnlyMeshes list, by detecting and including only near meshes (and activate shadows too if needed).

You mean detecting the meshes that are in the players line of sight, correct? Is there some sort of tutorial for using includeOnlyMeshes?

Plus, will all this add any fps gains?

Link to comment
Share on other sites

The less meshes receive dyn light, the less the engine have to work. As your scene is probably already at 60fps, you will not see gain, but maybe you will win some microseconde? :) You can't be sure before having testing it.

Link to comment
Share on other sites

I added a shadow generator:

var shadowGenerator = new BABYLON.ShadowGenerator(1024, light);
shadowGenerator.getShadowMap().renderList.push(wallsFinal);

wallsFinal is a group of merged planes.

after adding this line:

wallsFinal.receiveShadows = true;

I get this:image.thumb.png.eda76d498ebc154c238a51382a837ce8.png\

To clarify, wallsFinal is the group of walls. The ground tiles are part of a different group

Link to comment
Share on other sites

I had read this somewhere in a subject where Deltakosh proposed to use isBlocker so that light does not pass through the walls.

If it works for lensflare, it should also for the light I suppose.

Maybe I'm confusing with something else, but I know I've read something about the light passing through the walls.

Link to comment
Share on other sites

6 hours ago, foumfo said:

I added a shadow generator:


var shadowGenerator = new BABYLON.ShadowGenerator(1024, light);
shadowGenerator.getShadowMap().renderList.push(wallsFinal);

wallsFinal is a group of merged planes.

after adding this line:


wallsFinal.receiveShadows = true;

I get this:image.thumb.png.eda76d498ebc154c238a51382a837ce8.png\

To clarify, wallsFinal is the group of walls. The ground tiles are part of a different group

Whats wrong with this?
add scene.clearColor = new BABYLON.Color3.Black();

Link to comment
Share on other sites

I think it will be a way more simple to help if you success to append your .babylon/.gltf into the playground (a simplified version of your scene if you prefer), or at least an online version where we can try playing into the browser console.

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