From e3c94d01d663b2fd7a441cfe940fa470a1d2254e Mon Sep 17 00:00:00 2001 From: al-ro <> Date: Fri, 29 Dec 2023 15:07:18 +0200 Subject: [PATCH] Correct environment lookup --- main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index eb3fe78..3a8a86e 100644 --- a/main.cpp +++ b/main.cpp @@ -50,9 +50,9 @@ float dot_c(const vec3& a, const vec3& b) { } vec3 getEnvironment(const vec3& direction) { - uint u = environment.width * atan2f(direction.z, direction.x) * INV2PI - 0.5f; - uint v = environment.height * acosf(direction.y) * INVPI - 0.5f; - uint idx = min(u + v * environment.width, (uint)(environment.data.size()) - 1); + uint u = environment.width * (atan2f(direction.z, direction.x) * INV2PI + 0.5f); + uint v = environment.height * acosf(direction.y) * INVPI; + uint idx = min(environment.width * v + u, (uint)(environment.data.size()) - 1); return 0.5f * environment[idx]; }