From 0bf64bfad88d4b5795d8233fcd5f0f1a766ed971 Mon Sep 17 00:00:00 2001
From: Yoel <s73017@beuth-hochschule.de>
Date: Tue, 16 Mar 2021 14:39:31 +0100
Subject: [PATCH] Fixed cLE-method

---
 RayTracer/shape/CirclePlane.cpp    | 4 +++-
 RayTracer/shape/RectanglePlane.cpp | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/RayTracer/shape/CirclePlane.cpp b/RayTracer/shape/CirclePlane.cpp
index 991a426..76d6d81 100644
--- a/RayTracer/shape/CirclePlane.cpp
+++ b/RayTracer/shape/CirclePlane.cpp
@@ -61,10 +61,12 @@ util::Vec3 CirclePlane::calculateLightEmission(const util::SurfacePoint& p,
 	// the light in regard to the angle.
 	// Uniform pdf of shape is 1/area, converting to pdf over solid angle is
 	// pdf/(dot/length^2).
+	// This is wrong. We just need the normal pdf, per area, as we do not sample
+	// with regard to a direction.
 	auto emission = p.emission();
 	auto dot = std::max<float>(util::dot(p.normal(), d.normalize()), 0);
 	auto area = M_PI * std::pow(radius, 2);
-	auto pdf = std::pow(d.length(), 2) / (dot * area);
+	auto pdf = 1 / area;
 	return emission / pdf;
 }
 }  // namespace shapes
diff --git a/RayTracer/shape/RectanglePlane.cpp b/RayTracer/shape/RectanglePlane.cpp
index 21c62d2..ebc6e2c 100644
--- a/RayTracer/shape/RectanglePlane.cpp
+++ b/RayTracer/shape/RectanglePlane.cpp
@@ -62,10 +62,12 @@ util::Vec3 RectanglePlane::calculateLightEmission(const util::SurfacePoint& p,
 	// the light in regard to the angle.
 	// Uniform pdf of shape is 1/area, converting to pdf over solid angle is
 	// pdf/(dot/length^2).
+	// This is wrong. We just need the normal pdf, per area, as we do not sample
+	// with regard to a direction.
 	auto emission = p.emission();
 	auto dot = std::max<float>(util::dot(p.normal(), d.normalize()), 0);
 	auto area = width * depth;
-	auto pdf = std::pow(d.length(), 2) / (dot * area);
+	auto pdf = 1 / area;
 	return emission / pdf;
 }
 }  // namespace shapes
-- 
GitLab