Shadow not behaving as expected

See this doc page for some solutions to host the files you want to reference from the Playground.

Something you can try:

  • put this.light.position = new BABYLON.Vector3(0, 8, 8); after creating the light

By default, the position of a directional light is the negated viewDirection vector you pass in, so (0,1,1) in your case. It’s likely that this position is too close of the house (or even inside), and this.light.position.y -= 0.01 will stuck it even more.

Try to use the inspector to debug your shadows. With a directional light, the “Display frustum” switch is of a great help for debugging purpose (see bottom right of the screenshot):

Also, some advices to help debugging shadows:

4 Likes