Shadow starts at adjacent edge of receiving voxel

This commit is contained in:
Richard Zink committed 2026-10-06 18:08:41 +02:00
1 parent 5ae08e1368
commit 1c0c785e3e
1 file changed
+18 -18
+18 -18
View File
@@ -204,40 +204,40 @@
if (shadowFromRight > 0) {
var shadowW = Math.min(shadowFromRight * 2, TILE);
var tt = shadowW / TILE;
var target2 = project((wx - TILE) + GAP/2, wy + TILE - GAP/2, h * HEIGHT_UNIT);
var target3 = project((wx - TILE) + GAP/2, wy + GAP/2, h * HEIGHT_UNIT);
var origin4 = project(wx + GAP/2 + shadowW, wy + TILE - GAP/2 - shadowW, h * HEIGHT_UNIT);
var origin1 = project(wx + GAP/2 + shadowW, wy + GAP/2 + shadowW, h * HEIGHT_UNIT);
var edge1 = project(wx + GAP/2, wy + TILE - GAP/2, h * HEIGHT_UNIT);
var edge4 = project(wx + GAP/2, wy + GAP/2, h * HEIGHT_UNIT);
var mid1 = project(wx + GAP/2 + shadowW, wy + TILE - GAP/2 - shadowW, h * HEIGHT_UNIT);
var mid2 = project(wx + GAP/2 + shadowW, wy + GAP/2 + shadowW, h * HEIGHT_UNIT);
renderList.push({
type: 'shadow',
points: [
{ x: target2[0], y: target2[1] },
{ x: origin4[0], y: origin4[1] },
{ x: origin1[0], y: origin1[1] },
{ x: target3[0], y: target3[1] }
{ x: edge4[0], y: edge4[1] },
{ x: edge1[0], y: edge1[1] },
{ x: mid1[0], y: mid1[1] },
{ x: mid2[0], y: mid2[1] }
],
depth: (wx - TILE) + wy + h + 0.999
depth: wx + wy + h + 0.999
});
}
if (shadowFromFront > 0) {
var shadowW = Math.min(shadowFromFront * 2, TILE);
var tt = shadowW / TILE;
var target1 = project(wx + GAP/2, (wy + TILE) - GAP/2, h * HEIGHT_UNIT);
var target2 = project(wx + TILE - GAP/2, (wy + TILE) - GAP/2, h * HEIGHT_UNIT);
var origin4 = project(wx + GAP/2 + shadowW, wy + GAP/2 + shadowW, h * HEIGHT_UNIT);
var origin3 = project(wx + TILE - GAP/2 - shadowW, wy + GAP/2 + shadowW, h * HEIGHT_UNIT);
var edge3 = project(wx + TILE - GAP/2, wy + GAP/2, h * HEIGHT_UNIT);
var edge4 = project(wx + GAP/2, wy + GAP/2, h * HEIGHT_UNIT);
var mid1 = project(wx + GAP/2 + shadowW, wy + GAP/2 + shadowW, h * HEIGHT_UNIT);
var mid2 = project(wx + TILE - GAP/2 - shadowW, wy + GAP/2 + shadowW, h * HEIGHT_UNIT);
renderList.push({
type: 'shadow',
points: [
{ x: target1[0], y: target1[1] },
{ x: target2[0], y: target2[1] },
{ x: origin3[0], y: origin3[1] },
{ x: origin4[0], y: origin4[1] }
{ x: edge4[0], y: edge4[1] },
{ x: edge3[0], y: edge3[1] },
{ x: mid2[0], y: mid2[1] },
{ x: mid1[0], y: mid1[1] }
],
depth: wx + (wy + TILE) + h + 0.999
depth: wx + wy + h + 0.999
});
}
}