How to prevent cast shadows from the second floor to the ground?

Top-down light

With some light rotation

Directional light, useBlurExponentialShadowMap. Only avatar casts shadows.
The problem could be partially solved with (for example)
shadowGenerator.frustumEdgeFalloff = 3.0;

but seems this setting could be quite individual and depends on model parameters (like size, for example) as well.

Is there any way to prevent further shadow casting from Directional light if the shadow already presents on some upper (or closer) mesh?

What you could do is tightening the light frustum (shadowMinZ / shadowMaxZ) so that it fits the character closely:

Then you need to add a bit of shader code to remove shadows when the pixel to be shaded is not in the light frustum in the z direction. Fortunately, there’s a shader variable (vDepthMetricX) which gives you this information for the light with index X: the value is between 0…1 for points inside the frustum.

So, here’s how you can do it with a material plugin:

Which yields to:

Note that you need to indicate the light index that casts shadows: in the PG it is the second light, so I set lightIndex=1.