From 0dafba17af044532fa2f14c61176e7994336f56c Mon Sep 17 00:00:00 2001 From: ladevieq Date: Sun, 1 Aug 2021 16:48:27 +0200 Subject: Use SAH to generate BVH & fix ray triangle intersection --- src/vec3.cpp | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'src/vec3.cpp') diff --git a/src/vec3.cpp b/src/vec3.cpp index 8f7a720..166f681 100644 --- a/src/vec3.cpp +++ b/src/vec3.cpp @@ -139,32 +139,3 @@ vec3 refract(const vec3& uv, const vec3& n, float etai_over_etat) { std::ostream& operator<<(std::ostream& out, vec3 vec) { return out << vec.x << ' ' << vec.y << ' ' << vec.z << std::endl; } - -// TODO: Use something else to find random point onto a sphere -vec3 random_in_unit_sphere() { - while (true) { - auto p = vec3::random(-1,1); - if (p.length_sq() >= 1) continue; - return p; - } -} - -vec3 random_unit_vector() { - return random_in_unit_sphere().unit(); -} - -vec3 random_in_hemisphere(const vec3& normal) { - vec3 in_unit_sphere = random_in_unit_sphere(); - if (in_unit_sphere.dot(normal) > 0.0) // In the same hemisphere as the normal - return in_unit_sphere; - else - return -in_unit_sphere; -} - -vec3 random_in_unit_disk() { - while (true) { - auto p = vec3(randd(-1, 1), randd(-1, 1), 0); - if (p.length_sq() >= 1) continue; - return p; - } -} -- cgit v1.3