Skip to content

How to enable terrain to also cast shadows? #3

Open

Description

@rumicuna

First, thanks for releasing this, you guys are the best!!
Question: is there a way to have the visibility also work with the terrain so it casts a shadow on itself?
The buildings cast shadows on themselfs and on the terrain beautifully, but the terrain does not.

Activity

  1. rumicuna commented on Jan 10, 2024

    @rumicuna
    Author

    I the Cesium Sandcastle demo:
    https://sandcastle.cesium.com/?src=Shadows.html
    The terrain can cast shadows on itself, and there is a variable on your code = exclude_terrain which seemed promising so I set it to false, but this had no effect.

  2. rumicuna commented on Jan 10, 2024

    @rumicuna
    Author

    Here's my modified sandcastle example, with added terrain and exclude_terrain = false;

  3. rumicuna commented on Jan 10, 2024

    @rumicuna
    Author

    If you run my modified sandcastle version above, what I see is below, while I'm hoping to be able to have the terrain hast a shadow on itself as indicated in the image:

    image
  4. stj29 commented on Mar 19, 2024

    @stj29

    @rumicuna How to solve the surface flicker when the perspective rotates ?

  5. xsherlockpl commented on May 2, 2024

    @xsherlockpl

    @rumicuna your sandcastle example does not load properly.
    @stj29 unfortunately I also see clipping on all surfaces as the emmiter dot being moved or viewport changed.

  6. rumicuna commented on May 2, 2024

    @rumicuna
    Author

    @xsherlockpl @TJKoury here's the updated Sandcastle demo with terrain. All that is diffrent from the repo's Sandcastle demo is that I've turned on terrain.

    The code seems to have be updated recently, but I can't get the terrain to cast shadows. The buildings cast shadows on themselves and on the terrain beautifully, but the terrain itself does not cast shadows on itself or on the buildings.

  7. xsherlockpl commented on May 3, 2024

    @xsherlockpl

    Ok, So in my case I can see building casting shadow on terrain, but the implementation is wrong.
    image

    The road behind the building is a canyon in terrain, there should be shadow there both from the building and terrain and somehow it is lit green. So there is something seriously wrong with the cesium viewshed. I'd love to see the version from their super expensive SDK.

    BTW Has anyone figured out what does the depthBias prarameter does?
    It seems it is infulencing a zoom level/distance at which i see the glitching

    image

  8. syzdev commented on Jun 24, 2024

    @syzdev

    @xsherlockpl

    BTW Has anyone figured out what does the depthBias prarameter does?

    Shadows are implemented based on depth, and when two depth values are too close, it is difficult to distinguish the occlusion relationship between objects. This can lead to Z-fighting problems. Adding offset values can cause slight deviations between the two depths, effectively alleviating the Z-fighting problem. However, the setting of this value is based on experience.

  9. StevenPG commented on Oct 8, 2024

    @StevenPG

    Does this mean this SensorShadow library just doesn't support terrain?

  10. TJKoury commented on Oct 8, 2024

    @TJKoury
    Contributor
  11. afzaale01 commented on Mar 27, 2025

    @afzaale01
    Contributor

    Guys just enable the configuration of cesium viewer. It is working in the sandcastle. LINK

    const viewer = new Cesium.Viewer("cesiumContainer", {
      shadows: true,
      terrainShadows: Cesium.ShadowMode.ENABLED,
      terrain: Cesium.Terrain.fromWorldTerrain({
        requestWaterMask: true,
        requestVertexNormals: true,
      }),
    });
    
  12. afzaale01 commented on Mar 27, 2025

    @afzaale01
    Contributor

    @TJKoury @rumicuna The PR is open please check it. Request

  13. TJKoury commented on Mar 28, 2025

    @TJKoury
    Contributor

    To fully support terrain you need to enable / use cascades, or else the shadows will not be sampled correctly. That goes for anything in the scenario, as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions