I’m using three SpotLights to light up my scene. I want shadows from all the three lights. Problem is, shadow generated by one light is removed by the other ie. the shadowed area created by one light is lighted up by another.
How do I get shadows from all three lights at the same time ?

Hello, we will need a repro in the Playground to help you.

Sorry.

You can switch on and off the lights in lines 56 and 57. When both lights are on, the shadows naturally disappear. But I want them to say. I basically want to reproduce the shadow arrangement from threed.io. Please check attached pic.

Hello this is because each light boost the intensity to the max level and thus the additional light cannot boost it more

Here is an example (I added blurred shadows as well) with less powerful lights:
https://www.babylonjs-playground.com/#5LY1CB#2

1 Like

Only directional lights can cast shadows and they also need a position to define from where the shadows come

source: stackoverflow

If something doesn’t work the way you want it to, change your point of view and it works best by asking yourself questions: How would you solve the problem in an other (unusal) way?

A solution with the universal language of the universe: mathematics.

You have a base and an object with known dimensions. You have the position of the three light sources. So you have enough information to calculate the shadows yourself. All that remains is a little paint and a clean brush dipped in grey to draw the shadows…

Wenn etwas nicht so funktioniert, wie man es möchte, dann ändere dein Standpunkt und das funktioniert am besten, in dem man sich Fragen stellt: Wie würdest du das problem (ungewöhnliche) weise lösen?

Ein Lösungsansatz mit der universellen Sprache des Universums: Der Mathematik.

Du hast eine Grundfläche und ein Objekt mit bekannten Ausmaßen. Du hast die Postion der drei Lichtquellen. Somit hast Du genügend Informationen, um dir die Schatten selbst zu berechnen. Übrig bleibt nur noch ein wenig Farbe und ein sauberer in grau getunkter Pinsel, um dir die Schatten zu zeichnen…

1 Like

Hi,

I am kinda thinking that you can cheat that effect. Just a theory tho. You can use 1 light instead of 3 (lights are expensive) and maybe place a sphere somewhere in between the ground and light, and use shadow from the sphere instead shadow from the phone.
Shadow from the sphere will be beneath the phone, with some parameter tweaking maybe you can get that effect.

something like this (i just played around with few parameters)
https://playground.babylonjs.com/#99XUYS#1

Also for this to work, you cannot set sphere.isVisible = false, there will be no shadow. Instead you assign a material to sphere, and set alpha of that material to 0; And then you set shadowGenerator.setTransparencyShadow(true);

You can play with
spotLight angle (line 17)
light intensity (line 19)
blurKernel (line 28)
sphere size, (line 34)

to see some different results.