Skip to content

[Feature]: Shaded Relief: set how soft the cast shadows' edges are #3144

Done

Description

@elpidioassinaturas

Problem

Cast shadows (#1796) have a soft edge fixed at 5° either side of the sun's altitude (SOFT_EDGE, crates/map/src/shadow.rs:23), chosen for a soft edge at map scale. One width doesn't suit every map. A large-scale map of a cliff wants a crisp shadow line; a small-scale map of a mountain range wants the shadows to fade so they don't read as dark patches. Relief shading tools (Eduard's cast shadows have a blur setting) let the user choose. #1796 listed this as a possible setting.

Proposal

A new setting, Shadow softness (raster.symbology "shadowSoftness", degrees, 0.5 to 15, default 5): half the sun's apparent size used to trace cast shadows. The default draws today's pixels.

Choices in this proposal

  • The sun's apparent size, not a blur. The soft edge is already the share of the sun's disc hidden. Widening the disc keeps a shadow sharp where its caster is near and soft where it is far, as real penumbras are. A blur would soften both alike.
  • 0.5° to 15°. I tried 1.5°, 5° and 10°. The bounds are a guess to check in review: a much smaller disc should step at the cell size, and a much larger one blur the shadows away.
  • Part of the shadow grid's key. The grid is traced again when the softness changes, as it is when the sun moves.
  • No setting for the sky's reach. I measured it: 25, 100 and 300 cells give the same picture (no pixel moved by more than 8 levels) on a 90 m DEM of the Caparaó at 1:200,000. Only the cost changed: one run each took 4.3 s at 25 and 9.6 s at 100. A cheaper default reach could be considered separately, but not a setting.

Measured (local prototype)

Copernicus DEM GLO-30 of Ouro Preto, the Itacolomi and its scarps, 1:120,000, sun 315° / 20°, Z factor 1.5, shadow 0.8. Against today's 5°:

Softness Pixels changed by more than 8 levels Mean change
1.5° 4.9% 1.10
10° 7.2% 1.67
1.5°, 5° (today) and 10°

DEM: Copernicus DEM GLO-30, © DLR e.V. and Airbus, provided under COPERNICUS by the European Union and ESA.

🤖 Generated with Claude Code

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