From 3b567beadb6275adf4b60e1eca003e44014c3786 Mon Sep 17 00:00:00 2001 From: ladevieq Date: Tue, 22 Dec 2020 23:19:59 +0100 Subject: Defocus blur & randow scene generation --- src/vec3.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/vec3.cpp') diff --git a/src/vec3.cpp b/src/vec3.cpp index 3346973..94b3432 100644 --- a/src/vec3.cpp +++ b/src/vec3.cpp @@ -143,3 +143,11 @@ vec3 random_in_hemisphere(const vec3& normal) { 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