Why do we need a shadow generator?

In the beginning, we have only a dark scene with a camera and no defined lighting.

When a light source is created, rays are cast on the objects in the scene and the facets are colored according to their degree of rotation, and so on.

Shadows are all the places that the rays do not reach.

So why do we need an additional function to calculate the shadows?

An intriguing question :thinking: If it wasn’t you, I would have been tempted to give a shit answer like:
" Because we want to control our shadows (per light source and in scene) "

But then, let me attempt decode your question and share my own XP with shadowing in BJS:
I think what you mean could be somehow related to something I experienced when first studying this part in BJS, which I could resume asking: “Why is it like the shadow generation and management properties are not directly linked to the light source/properties ?”

I do not have the answer. Obviously, I’m not a code architect. Eventually, a PM or coordinator.
The one thing I can say is If this ‘constraint’ (or additional effort in code/design) is a result from keeping the best average/compromise to handle this part, keeping the best balance between expression, control and sustainability/evolution, I’d rather keep like this. Else, I admit I find it sometimes cumbersome to handle these 1 and more shadow generator(s) of different types ‘levitating’ in various parts of my script. (also because I’m a shit coder;)

Because we are not doing ray tracing :slight_smile:

4 Likes

Haha. Best answer ever. You’re my hero:)

Light is the absence of darkness
or darkenss is the absence of light… :slight_smile:

Here is an example of a scene with shadows without the use of the shadowgenerator!


-https://www.babylonjs-playground.com/#P9UZG#37

big dust particles in the air… :slight_smile:

In my mind it was stuck that we have only max. 4 light sources. during my studies i came across that i was subject to a superstition! :slight_smile:

Babylon.js allows you to create and register as many lights as you choose, but know that a single StandardMaterial can only handle a defined number simultaneous lights (by default this value is equal to 4 which means the first four enabled lights of the scene’s lights list). You can change this number with this code:

var material = new BABYLON.StandardMaterial(“mat”, scene);
material.maxSimultaneousLights = 6;

but now the shadowgenerator is offline!
answer: no, to much illumination! :slight_smile:

LoL. Yes. Important life lesson: Light only adds to light;)
Here is a more balanced lights intensity REV version :grinning:
https://www.babylonjs-playground.com/#P9UZG#45

1 Like

cheers for illumniation :smiley:

1 Like