How make three.js shadow more darkness? I dont want set directLight intensity too big

How make three.js shadow more darkness? I dont want set directLight intensity too big…

1 Like

Shadow doesn’t really exist. The shadow map is black and white, can’t get any blacker or whiter :smiling_face_with_tear: Brightness of the surface (in the shadowed area as well) depends on the intensity of all lights illuminating that specific area (keep in mind - each shadow is bound to their own light, so shadow of lightA does not darken lightB etc.) To make shadow darker, it should be enough to just lower the intensity of all other lights in the scene / environment map of the scene.

1 Like

To control the darkness of shadows, you can use a light and an antilight.

https://codepen.io/boytchev/full/GRavNbd

image

5 Likes
THREE.ShaderChunk["shadowmap_pars_fragment"]=THREE.ShaderChunk["shadowmap_pars_fragment"].replace(
"occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );",
"occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 0.1 );"
);

Or

THREE.ShaderChunk["shadowmap_pars_fragment"]=THREE.ShaderChunk["shadowmap_pars_fragment"].replace(
"occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );",
"occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 )*0.1;"
);

3 Likes

Starting with r166, it will be possible to configure the shadow intensity per light by setting a new intensity property like so:

light.shadow.intensity = 0.5;

Some history about this issue: We could have added this change earlier but the previous implementation of MeshLambertMaterial was a blocker. Now that is uses per-fragment lighting and thus the same shadow code like other lit materials, shadow intensity could be properly added per light. The previous workarounds are not required anymore.

Related PR: LightShadow: Add `intensity`. by Mugen87 · Pull Request #28588 · mrdoob/three.js · GitHub

8 Likes

This is good news.

Is the intensity unclamped, so we could outweigh ambient light with shadow intensity 2?

(the goal it to make the shadow darker than “normal”)

Yes, there is no clamping in place.

In the documentation we state a range of [0,1] for PBR reasons since environmental lighting brightens everything, even areas affected by shadow mapping. However, since the intensity value is used in a mix() GLSL statement, you can technically use values outside this range [0,1] to produce pitch-black shadows.

3 Likes