0

Good day, I'm playing with webgl using Babylon JS and I need an advice concerning lights. I created a test cave and I placed a torch (BABYLON.PointLight) on one wall. But the light lits also walls that is behind the corner. See screenshot:

enter image description here

var light = new BABYLON.PointLight("light1", new BABYLON.Vector3(x, y, z), scene);
light.intensity = 0.5
light.range = 50;

The cave is not a single mesh but it's made of individual rectangular faces. How can I ensure that the lit doesn't lit walls behind the corner please?

Thank you in advance. Vojtech

gman
  • 100,619
  • 31
  • 269
  • 393
Vojtech
  • 2,533
  • 9
  • 34
  • 65

2 Answers2

1

As has been suggested, you could add shadowing to your light. Apparently shadows for pointlights have been introduced in v2.3 (see http://www.html5gamedevs.com/topic/18285-point-light-shadow-mapping/). Another thing to try might be to set the range to a lower number, so that the light does not reach the back wall. Something like yourLight.range = 0.5 might work.

One thing to keep in mind is that you can only have a maximum number of 4 lights in the scene (a limitation to ensure performance).

David Basalla
  • 2,996
  • 3
  • 18
  • 22
0

Lights only colors pixels based on the direction from the pixel to the light, the normal (surface angle) of the pixel and the viewing direction. Thus, lights by themselves do not taken into account whether the light source actually reached the pixels and that must be calculated separately with a shadowing algorithm.

WacławJasper
  • 3,284
  • 14
  • 19