From 1c0c785e3e07bf50e20f5ef49d7434676930ec0a Mon Sep 17 00:00:00 2001 From: Richard Zink Date: Tue, 6 Oct 2026 18:08:41 +0200 Subject: [PATCH] Shadow starts at adjacent edge of receiving voxel --- assets/index.html | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/assets/index.html b/assets/index.html index 35c8a46..e5beb7f 100644 --- a/assets/index.html +++ b/assets/index.html @@ -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 }); } }