From 0f122e2062309867dbca08ac28033838db707b0e Mon Sep 17 00:00:00 2001 From: jbb01 <32650546+jbb01@users.noreply.github.com> Date: Sat, 3 Aug 2024 02:56:24 +0200 Subject: [PATCH] use Lambertian reflection --- src/main/java/eu/jonahbauer/raytracing/render/Camera.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/eu/jonahbauer/raytracing/render/Camera.java b/src/main/java/eu/jonahbauer/raytracing/render/Camera.java index f8a997d..27d4653 100644 --- a/src/main/java/eu/jonahbauer/raytracing/render/Camera.java +++ b/src/main/java/eu/jonahbauer/raytracing/render/Camera.java @@ -134,10 +134,7 @@ public final class Camera { if (optional.isPresent()) { var result = optional.get(); - var newDirection = Vec3.random(true); - if (result.normal().times(newDirection) < 0) { - newDirection = newDirection.times(-1); - } + var newDirection = result.normal().plus(Vec3.random(true)); var scattered = new Ray(result.position(), newDirection); return Color.lerp(Color.BLACK, getColor(scene, scattered, depth - 1), 0.5);