Ambient Light Intensity Lightens Shadows

Yo @Deltakosh

When using Ambient Light … (Hemispheric Light) to light the back sides of geometry the intensity of the ambient lights OVER POWERS and there for LIGHTENS the shadow to where you can barley see them.

Not sure to understand:)
Hemispheric and ambiant lights are indirect lights so they are not touched by the shadows.

Can you repro on the of so I can see what you mean?

Yo @Deltakosh … Here are two playgrounds. the first does NOT have ambient light and shows a nice dark shadow. The second one has a ambient light with intensity set to 0.5… The shadows are ow much lighter… If you take ambient.intensity up to full 1.0 or larger… you cant see shadow at all.

Without Ambient Light: Babylon.js Playground

With Ambient Light (But it lightens the shadows) : https://playground.babylonjs.com/#IKTJ0K#1

So it should NOT LIGHTEN shadows BUT IT DOES :frowning:

Well the shadow are blocking the light they are associated with (here the dir01 light for instance). The shadows are blocking the light from this very light and only it.

The ambient light is indirect and thus they are ADDITIVE to the shadows.

Is there any thing we can do so ambient light is not lighten shadows… if I add a ambient light to a scene exported from unity… it basically cancels out the shadow… I have to reduce ambient intensity to see shadow at all… but then you loose the ambient light brightness on the mesh itself

What can I do about that ???

well this is against all our shaders and the way bjs work.
The only way I can see would be to add an option for that but this is not on my roadmap so far. Furthermore I still need to be convinced that it is a good idea

To @Deltakosh

I’m gonna make a video a showcase the problem. Will you look at and please consider add a switch to handle ambient light with shadows

please :blush:

1 Like

Well you have to be convincing at this will be a HUGE AMOUNT of work

Sorry but in video games ambient light are there to give the shadow a color. So black aren’t so black.
Lights should interact with shadows in general.

You should light your scene with other lights than ambient light. That would solve your issue :slight_smile:

1 Like

I get that… what I am trying to do is match up the default way unity handles lights… it uses a ambient light by default… I get you can turn off ambient light and use all direction, point or spot lights in your seen.

Again trying to make a what you see is what you get for the exporter … at least as much as possible

When comes to a PBR scene, I always be confronted to this shadow darkness issue, example:

https://www.babylonjs-playground.com/#IIZ9UU#14

I have tested to keep a pure black scene environment, and assign my hdrTexture just as a reflectionTexture, not a lighting one, but result is the same:

https://www.babylonjs-playground.com/#IIZ9UU#16

As the env texture is necessary for PBR Material, I haven’t find yet how to keep global environment intensity with addition of dynamic shadows.

That said, if we take a look on Unity3D, it acts the same… BUT! we can define the env texture to influence only reflections, and this allow to keep our dyn shadows blacks

Pinging @sebavan as he may know a way to keep IBL only for reflections

1 Like

You could scale the polynomials stored in the texture to only keep the specular impact of I
BL (direct reflections and blurry reflections).

once the texture is ready:

scene.environmentTexture.sphericalPolynomial.scale(0.01);

also you could rely on the environmentIntensity which is what unity does to vary the global spec + diffuse intensity.

https://www.babylonjs-playground.com/#IIZ9UU#17

Do not forget the env is a light :slight_smile:

1 Like

Nice, that polynomials thing could be a great trick!

    scene.onReadyObservable.addOnce(() => {
        hdrTexture.sphericalPolynomial.scale(0);
    });

It could be a huge help to get my real precomputed lighting using lightmaps too:

I always had issues and pain in my PBR scenes, trying to dealing with the combination of lightmaps + envTexture. 'will see if this works great for that.

That should be documented…

Just sayin` :smiley:

1 Like

Why not, but I have a few tests to do before, to be sure about what’s I’m doing.

And for sure, I’m still absolutly not comfortable for technical understanding of what is an IBL/polynomials stuffs. But I add this on my todo(cumentation)-list :wink:

1 Like

This is basically the diffuse part of the environment light :slight_smile: