foundryvtt icon indicating copy to clipboard operation
foundryvtt copied to clipboard

Lights below the minimum elevation are not occluded by roofs at the minimum elevation

Open dev7355608 opened this issue 3 years ago • 0 comments

What happened?

If the elevation is below the minimum, mapElevationAlpha needs to return a value less than 0.2 and greater than 0.15; mapElevationAlpha should never return values less than 0.15 because of Tile#renderOcclusion.

  mapElevationAlpha(elevation) {
    const {min, max} = this.#elevation;
    if ( min === max ) {
-     if ( elevation < max ) return 0;
+     if ( elevation < max ) return 0.19;
      else if ( elevation > max ) return 1;
      return 0.5;
    }
+   if ( elevation < min ) return 0.19;
    const pct = Math.clamped((elevation - min) / (max - min), 0, 1);
    const alpha = 0.2 + (0.8 * pct);
    return (alpha || 0).toNearest(1 / 255);
  }

The documentation of the return value of mapElevationAlpha also needs some adjustments.

What ways of accessing Foundry can you encounter this issue in?

  • [ ] Native App (Electron)
  • [ ] Chrome
  • [ ] Firefox
  • [ ] Safari
  • [ ] Other

Reproduction Steps

Place two roof tiles on top on a light source and execute:

canvas.tiles.placeables[0].document.elevation = 0
canvas.tiles.placeables[1].document.elevation = 20
canvas.lighting.placeables[0].document.elevation = -10

Result: Tile 1 doesn't occlude the light; tile 2 does. Expected: Both tiles occlude the light source.

What core version are you reporting this for?

Version 10 Stable 4 (build 288)

Relevant log output

No response

Bug Checklist

  • [X] The issue occurs while all Modules are disabled

dev7355608 avatar Oct 21 '22 17:10 dev7355608