From 0e1b9495c52f515f01abb898546847c1252b6c0c Mon Sep 17 00:00:00 2001 From: Hans Kokx Date: Sun, 30 Aug 2026 13:44:19 +0200 Subject: [PATCH] Add some simple shading to the walls Signed-off-by: Hans Kokx --- raycaster.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/raycaster.c b/raycaster.c index 75f22c0..7134e7e 100644 --- a/raycaster.c +++ b/raycaster.c @@ -282,22 +282,28 @@ void drawRays3D() // * Compare shortest horizontal and vertical line, then use the shortest // This is what actually determines our ray that hits a wall! + + // Vertical wall hit if (disV < disH) { rx = vx; ry = vy; disT = disV; + // Vertical walls are drawn a little brighter than horizontal walls + glColor3f(0.9, 0, 0); } + // Horizontal wall hit if (disH < disV) { rx = hx; ry = hy; disT = disH; + // Horizontal walls are drawn a little darker than vertical walls + glColor3f(0.7, 0, 0); } - // * Draw the shortest line - glColor3f(1, 0, 0); + // * Draw the ray glLineWidth(3); glBegin(GL_LINES); glVertex2i(px, py); @@ -307,7 +313,6 @@ void drawRays3D() // * --- Draw 3D Walls --- // Correct the fish-eye effect - float ca = pa - ra; if (ra < 0) {