Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
xelatihy committed Jan 31, 2024
1 parent 6d7be3b commit 5a8899c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libs/yocto/yocto_scene.cpp
Expand Up @@ -573,7 +573,7 @@ vec3f eval_environment(const scene_data& scene,
const environment_data& environment, vec3f direction) {
auto wl = transform_direction(inverse(environment.frame), direction);
auto texcoord = vec2f{
atan2(wl.z, wl.x) / (2 * pif), 1 - acos(clamp(wl.y, -1.0f, 1.0f)) / pif};
atan2(wl.z, wl.x) / (2 * pif), acos(-clamp(wl.y, -1.0f, 1.0f)) / pif};
if (texcoord.x < 0) texcoord.x += 1;
return environment.emission *
xyz(eval_texture(scene, environment.emission_tex, texcoord));
Expand Down
6 changes: 3 additions & 3 deletions libs/yocto/yocto_trace.cpp
Expand Up @@ -362,8 +362,8 @@ static vec3f sample_lights(const scene_data& scene, const trace_lights& lights,
auto idx = sample_discrete(light.elements_cdf, rel);
auto size = max(texture.pixelsf.size(), texture.pixelsb.size());
// we avoid flipping twice the v in the uv and returned direction
auto uv = vec2f{
((idx % size.x) + 0.5f) / size.x, ((idx / size.x) + 0.5f) / size.y};
auto uv = vec2f{((idx % size.x) + 0.5f) / size.x,
1 - ((idx / size.x) + 0.5f) / size.y};
return transform_direction(environment.frame,
{cos(uv.x * 2 * pif) * sin(uv.y * pif), cos(uv.y * pif),
sin(uv.x * 2 * pif) * sin(uv.y * pif)});
Expand Down Expand Up @@ -409,7 +409,7 @@ static float sample_lights_pdf(const scene_data& scene, const trace_bvh& bvh,
auto wl = transform_direction(inverse(environment.frame), direction);
// we avoid flipping twice the v in the texcoord and ij
auto texcoord = vec2f{atan2(wl.z, wl.x) / (2 * pif),
acos(clamp(wl.y, -1.0f, 1.0f)) / pif};
acos(-clamp(wl.y, -1.0f, 1.0f)) / pif};
if (texcoord.x < 0) texcoord.x += 1;
auto size = max(
emission_tex.pixelsf.size(), emission_tex.pixelsb.size());
Expand Down

0 comments on commit 5a8899c

Please sign in to comment.