Shadows from right and back neighbors

This commit is contained in:
Richard Zink committed 2026-10-06 18:01:45 +02:00
1 parent b3161bb3aa
commit 7b0f5b5d67
1 file changed
+7 -7
+7 -7
View File
@@ -196,10 +196,10 @@
if (h > 0) { if (h > 0) {
var hRightNeighbor = heightMap[(wx + TILE) + ',' + wy] || 0; var hRightNeighbor = heightMap[(wx + TILE) + ',' + wy] || 0;
var hLeftNeighbor = heightMap[wx + ',' + (wy - TILE)] || 0; var hBackNeighbor = heightMap[wx + ',' + (wy - TILE)] || 0;
var shadowFromRight = hRightNeighbor - h; var shadowFromRight = hRightNeighbor - h;
var shadowFromLeft = hLeftNeighbor - h; var shadowFromBack = hBackNeighbor - h;
if (shadowFromRight > 0) { if (shadowFromRight > 0) {
var shadowW = Math.min(shadowFromRight * 2, TILE); var shadowW = Math.min(shadowFromRight * 2, TILE);
@@ -221,13 +221,13 @@
}); });
} }
if (shadowFromLeft > 0) { if (shadowFromBack > 0) {
var shadowW = Math.min(shadowFromLeft * 2, TILE); var shadowW = Math.min(shadowFromBack * 2, TILE);
var tt = shadowW / TILE; var tt = shadowW / TILE;
var top1 = project(wx + GAP/2, wy + TILE - GAP/2, h * HEIGHT_UNIT); var top1 = project(wx + GAP/2, wy + TILE - GAP/2, h * HEIGHT_UNIT);
var top4 = project(wx + GAP/2, wy + GAP/2, h * HEIGHT_UNIT); var top2 = project(wx + TILE - GAP/2, wy + TILE - GAP/2, h * HEIGHT_UNIT);
var topA = project(wx + GAP/2, wy + TILE - GAP/2 - (TILE - GAP) * tt, h * HEIGHT_UNIT); var topA = project(wx + GAP/2, wy + TILE - GAP/2 - (TILE - GAP) * tt, h * HEIGHT_UNIT);
var topB = project(wx + GAP/2, wy + GAP/2 - (TILE - GAP) * tt, h * HEIGHT_UNIT); var topB = project(wx + TILE - GAP/2, wy + TILE - GAP/2 - (TILE - GAP) * tt, h * HEIGHT_UNIT);
renderList.push({ renderList.push({
type: 'shadow', type: 'shadow',
@@ -235,7 +235,7 @@
{ x: top1[0], y: top1[1] }, { x: top1[0], y: top1[1] },
{ x: topA[0], y: topA[1] }, { x: topA[0], y: topA[1] },
{ x: topB[0], y: topB[1] }, { x: topB[0], y: topB[1] },
{ x: top4[0], y: top4[1] } { x: top2[0], y: top2[1] }
], ],
depth: wx + wy + 0.0005 depth: wx + wy + 0.0005
}); });