Issue with Shadows on Terrain – Shadows Not Occluded by Terrain

Hi,

I am encountering an issue with shadows cast by entities on the terrain in Cesium.
Specifically, when part of the entity is occluded by the terrain, the shadow from that part is still visible, even though it should be hidden by the terrain.

Here is an example of the issue:

You can also observe the issue it in this Sandcastle demo

To disable the terrain shadows and show only the entity’s shadow, I am using the following configuration:

viewer = new Cesium.Viewer("cesiumContainer", {
  shadows: true,
  terrainShadows: Cesium.ShadowMode.RECEIVE_ONLY,
  terrain: Cesium.Terrain.fromWorldTerrain(),
});

Am I missing something in how shadows are configured, or is this behavior a limitation of Cesium’s shadow system? The goal is to show only the entity’s shadow and ensure the terrain occludes it where appropriate.

I would greatly appreciate any guidance or suggestions.
Thank you in advance!