Light going thru walls


I am facing the same problem discussed at Spot light passing through objects - Questions & Answers - HTML5 Game Devs Forum

I have designed an apartment with 6 rooms. Light is going thru walls from 1st room to 6th room :disappointed:
This is not the behavior of light in reality. It should stop at walls unless:

  1. The wall is set to be transparent.
  2. If there are any windows of doors to that walls.

How can I make the light stop at walls?.

I could not understand the renderList stuff. Do I need to mention all my mesh IDs in the renderList of every light?

I have 100s of meshes and I have around 10 lights in every room. 60*100=6000 GUIDs in file.

Please help me.

Why not turning on shadows? This way light will be stopped :wink:


and which renderlist do you think about?

You mean, setting receiveShadows property to true for every mesh?

I am talking about renderList of ShadowGenerator

You mean, scene.shadowsEnabled = true/false ?

yes if you want to enable light occlusion (e.g. shadows)

I set the shadowsEnabled to true.

Do I still need to use ShadowGenerator?
If I need to use ShadowGenerator, Do I need to create one ShadowGenerator for each light and all all the meshes to the renderList of each ShadowGenerator?

I just :

  1. Added one spot light to my scene in 1st room.
  2. set the shadowsEnabled property of the scene to true.

Light is going thru the wall to 2nd room.

I highly encourage you to first read this: Shadows - Babylon.js Documentation

1 Like

For your walls and rooms, are you using primitives (box, sphere, ext…), or meshes built in 3d software and exported using the exporter?

If exporter, what format were the files exported in and what software was used.

If primitives, are there any negative scales applied to the wall between the rooms?

Maybe check to make sure you did not exclude that wall from the lights influence list with exclusion lightname.excludeMeshes.push(array) or explicit inclusion of other objects using lightname.includeOnlyMeshes.push(array)

Deltakosh is right as usual. Learning the dark ways of shadows will stop light from misbehaving.

The whole plan is generated on the fly with code.
Everything is perfect in terms of the normals. The only thing is, the thickness of the wall meshes is Zero

Don’t forget you’re in a realtime engine, and so everything around you is fake :wink:
PointLight always works like that, example in Unity3D:

Using shadows could help but - I think - this will probably be more compute intensive than using the includedOnlyMeshes method (easy to script by using a right naming convention).