foumfo Posted March 21, 2018 Share Posted March 21, 2018 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 Quote Link to comment Share on other sites More sharing options...
kurhlaa Posted March 21, 2018 Share Posted March 21, 2018 Hi, What about setting light.range = 20; to a smaller value? 20 looks too much for your scene. Quote Link to comment Share on other sites More sharing options...
foumfo Posted March 21, 2018 Author Share Posted March 21, 2018 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. Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted March 21, 2018 Share Posted March 21, 2018 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). adam 1 Quote Link to comment Share on other sites More sharing options...
foumfo Posted March 22, 2018 Author Share Posted March 22, 2018 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? Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted March 22, 2018 Share Posted March 22, 2018 I don't know how to detect near meshes, but I think it's possible (by comparing position values?). About the includeOnlyMeshes, here an example: https://www.babylonjs-playground.com/#1DLERH#5 But you can already try by activating shadows, I don't think your FPS will be dropped very much. Quote Link to comment Share on other sites More sharing options...
foumfo Posted March 22, 2018 Author Share Posted March 22, 2018 4 minutes ago, V!nc3r said: I don't know how to detect near meshes, but I think it's possible (by comparing position values?). About the includeOnlyMeshes, here an example: https://www.babylonjs-playground.com/#1DLERH#5 I have an idea on how to detect that. Thank you for the link. Do you think I'll gain any fps from doing that? Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted March 22, 2018 Share Posted March 22, 2018 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. Quote Link to comment Share on other sites More sharing options...
foumfo Posted March 22, 2018 Author Share Posted March 22, 2018 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:\ To clarify, wallsFinal is the group of walls. The ground tiles are part of a different group Quote Link to comment Share on other sites More sharing options...
JohnK Posted March 22, 2018 Share Posted March 22, 2018 1 hour ago, foumfo said: Is there some sort of tutorial for using includeOnlyMeshes? http://doc.babylonjs.com/babylon101/lights#choosing-meshes-to-light Quote Link to comment Share on other sites More sharing options...
foumfo Posted March 22, 2018 Author Share Posted March 22, 2018 1 minute ago, JohnK said: http://doc.babylonjs.com/babylon101/lights#choosing-meshes-to-light Thanks for the link John but this won't fix the above issue right? Quote Link to comment Share on other sites More sharing options...
JohnK Posted March 22, 2018 Share Posted March 22, 2018 5 minutes ago, foumfo said: Thanks for the link John but this won't fix the above issue right? Correct, just responding to earlier request. Sorry but not able to help with shadows. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 22, 2018 Share Posted March 22, 2018 There is a mesh.isBlocker = true; property that blocks light that does not cross the wall Quote Link to comment Share on other sites More sharing options...
adam Posted March 22, 2018 Share Posted March 22, 2018 5 minutes ago, Dad72 said: There is a mesh.isBlocker = true; property that blocks light that does not cross the wall It looks like that is just for lensflare: https://doc.babylonjs.com/search?q=isblocker https://doc.babylonjs.com/how_to/how_to_use_lens_flares Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 22, 2018 Share Posted March 22, 2018 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. Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted March 22, 2018 Share Posted March 22, 2018 This could be a nice feature, making it easier than using includeMeshesList. For now it seems isBlocker doesn't allow that. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted March 22, 2018 Share Posted March 22, 2018 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:\ 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(); Quote Link to comment Share on other sites More sharing options...
foumfo Posted March 22, 2018 Author Share Posted March 22, 2018 35 minutes ago, Pryme8 said: Whats wrong with this? add scene.clearColor = new BABYLON.Color3.Black(); I've already done that from the start: scene.clearColor = new BABYLON.Color3(50/255,50/255,50/255) Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted March 22, 2018 Share Posted March 22, 2018 But that is gray not black... if you are trying to hide the unlit walls turn it to black. Quote Link to comment Share on other sites More sharing options...
foumfo Posted March 22, 2018 Author Share Posted March 22, 2018 You can see the issue here if you compare my first screenshot and my second. The merged meshes that cast the shadows turn black Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted March 22, 2018 Share Posted March 22, 2018 ahh gotcha! Sorry I miss understood. Quote Link to comment Share on other sites More sharing options...
foumfo Posted March 22, 2018 Author Share Posted March 22, 2018 I think that the issue is caused when a mesh is both receiving shadows and is used in shadowgenerator's renderList. I've checked with every mesh in my project Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted March 22, 2018 Share Posted March 22, 2018 https://www.babylonjs.com/demos/selfshadowing/ Quote Link to comment Share on other sites More sharing options...
foumfo Posted March 23, 2018 Author Share Posted March 23, 2018 12 hours ago, Pryme8 said: https://www.babylonjs.com/demos/selfshadowing/ I added these lines: player.playerBox.isVisible = false; shadowGenerator.bias = 0.0016; this playerBox is a mesh that acts as parent to my pointLight. And I still get, a similar if not the same, issue: Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted March 23, 2018 Share Posted March 23, 2018 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.