Skip to content

Commit

Permalink
Correct environment lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
al-ro committed Dec 29, 2023
1 parent 8ce318e commit e3c94d0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down

0 comments on commit e3c94d0

Please sign in to comment.