Is there any way adding hemispherical light or Environment light without affecting the blackness of the shadow

Hello.In the process of making a large 3D scene, it is often necessary to have a directional light, and add a hemisphere light or Environment light to light the place where the directional light does not shine, such as the back of the house.
However, adding hemispheres or Environment light can cause the shadows to become very faint, even if the Intensity increases only a little. I want to ask is there any way adding hemispherical light or Environment light without affecting the blackness of the shadow.

PG:https://playground.babylonjs.com/#IFYDRS#722

Hi, is this a similar discussion to what you’re talking about here?

If using a very low value doesn’t work for your visual needs, using the very light shadows as you are and using post-processes to achieve your desired result is also an option : )

I want to keep IBL only for reflections.I tried this,but PG reported an error.
image

or tried this,but I can’t see any change.

Here is my PG:https://playground.babylonjs.com/#IFYDRS#727

the api has changed ig, it’s now scaleInPlace but even that doesn’t make much of a difference.

does controlling exposure not do the same thing as you want?
like here, https://playground.babylonjs.com/#IFYDRS#729

I had some sort of the same issue.
I bumped up the directional light intensity and lowered the IBL.
The harder the dir light the stronger the shadows.
If you use IBL it so much depends on your texture, there is a lot of wiggle room.
Best.w.

A large 3D scene is composed of many objects. If I enable post-processing solely for the shadow, many effects will not meet my expectations. Moreover, if the scene is provided to users for scene customization, many people do not have a professional understanding of 3D scenes, materials, etc., and cannot independently adjust the scene.
So I hope I can turn multiple options into simple options , so that users can more easily adjust the scene.

1 Like

I examined expossure carefully, but I felt that the impact on the shadows was not so much as the overall effect of the scene.

1 Like

" The harder the dir light the stronger the shadows." This is the method I use now.
However, this method will lead to too strong exposure in the direction of light, and need to adjust the light intensity on the material of the object. The experience is very bad, and it will increase a lot of work in the large 3D scenes.

In addition, the relationship between various factors is so strong that it is difficult for people who do not know enough about rendering to understand how to adjust various parameters to achieve the desired effect.

Hi.
I always use PBR materials instead of the standard materials (is this the way its meant to be with IBL?)
Quickly replaced the grass with a PBR and lowered environment intensity.
As mentioned, it is very dependent on the .env texture you will be using, but it is a very good way to design the scene. Gives way more realism and plays well together with the PBR materials (reflection, roughness …)
As well the environment can be dynamic, either animated or rendered cubemaps to create e.g. sunmotion/env. lighting like sunset etc.

https://doc.babylonjs.com/guidedLearning/createAGame/extraFeatures#ibl-image-based-lighting

Best. Werner

I don’t know if I fully understand what you mean. But the environment light affects the whole scene, I can’t make the ambient light very dark ,just to avoid affecting the shadow effect, because many objects in the scene need to be illuminated by the environment light.
I wonder if it is possible to change the order in which PBR fragment shader calculate reflections and shadows so that reflections do not affect the effect of shadows.

Well, as there is no “global” solution for lighting or physically realistic behavior, I guess you can be creative.
There is a possibility to control the Environment intensity per material as well.
Also depending on your scene, you could consider local light sources, prerendered lightmaps or prerendered lighting with GI aso.
You could bake everything into a albedo and/emmisive texture, you could use vertex colours …
Really depends on the scene you need to create.
An outdoor scene would use some sort of environment lighting as HDR from the .env and one directional for the sunlight.
Indoor scenes may be using no environment, but prerenderes textures or many local point lights, rendered shadow maps …
huh.
Sry I may have gone too far, but there are so many concepts.
For sure, the PBR workflow is standard and I would recommend using it.

The issue you mentioned here I think is solveable like described (I have only this idea as I am not an Babylon expert per se. ;)) but there are surely others …
All the best.
Werner

@Evgeni_Popov Hello, I wonder if it is possible to change the order in which PBR fragment shader calculate reflections and shadows so that reflections do not affect the effect of shadows.

I am not sure to understand what you mean :frowning:

The current reflection of environment light affects the blackness of shadows too much.I wonder if someone could provide a way to keep the environment light from affecting the blackness of the shadow.
Here is an idea I have, but I don’t know if it’s feasible. so I would like to ask if PBR fragment shader can modify the drawing order and then draw the shadow after drawing the reflection.

In your case, you can set a negative value for ShadowGenerator._darkness:

This will work only for lights that generate shadows through the shadow generator, though, not the environment light.

If you want more control, you could use a node material. There’s a shadow output from the PBRMetallicRoughness block: you could set the final color to black as soon as shadow is strictly < 1.

1 Like

Just figured it out too after looking at the pbr fragment shader includes.
It took me a while to go trough all the light, shadow functions to figure it out but now I know how exactly the shadow rendering works :slight_smile:

@Evgeni_Popov how do you guys write so complex shaders with lots of dependencies? In a plain editor or do you have some tool with autocompletion/error checking?

I think we are all using Visual Studio Code for Babylon.js development. There’s no help from code completion for shader code, so we are all on our own :slight_smile:

Thank you very much for your reply.
I found this solution in other topics of the forum . Using ShadowGenerator._darkness can solve the problem of insufficient shadow blackness caused by factors such as hemispherical light. However, there is no use for the problem of insufficient shadow blackness caused by IBL.
Because the objects in my scene default to PBR material,so node materials don’t help me much.The solution I have now found is to manually adjust the intensity of reflection of the PBR material on each object to the environment light, but this way is not very friendly, and it will cause my reflection to be weaker,I feel a little troubled.
So I want to ask for your help,because your professional has given me a lot of very valuable and useful advice and help.

You can try to use a material plugin to remove the irradiance contribution when the pixel is in shadow:

See lines 219-221. When aggShadow is strictly less than 1, it means the pixel is at least partially in shadow.

2 Likes

Maybe we could to add more injection points to the shaders so we can more precisely control them? Does it make any sense to you?