Skip to content

Commit eff0aad

Browse files
davnov134facebook-github-bot
authored andcommitted
Bugfix - normalize emitted ray directions after substraction
Summary: The bug lead to non-coinciding origins of the rays emitted from perspective cameras when unit_directions=True Reviewed By: bottler Differential Revision: D40865610 fbshipit-source-id: 398598e9e919b53e6bea179f0400e735bbb5b625
1 parent bea84a6 commit eff0aad

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pytorch3d/renderer/implicit/raysampling.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -670,12 +670,13 @@ def _xy_to_ray_bundle(
670670

671671
# directions are the differences between the two planes of points
672672
rays_directions_world = rays_plane_2_world - rays_plane_1_world
673-
if unit_directions:
674-
rays_directions_world = F.normalize(rays_directions_world, dim=-1)
675673

676674
# origins are given by subtracting the ray directions from the first plane
677675
rays_origins_world = rays_plane_1_world - rays_directions_world
678676

677+
if unit_directions:
678+
rays_directions_world = F.normalize(rays_directions_world, dim=-1)
679+
679680
return RayBundle(
680681
rays_origins_world.view(batch_size, *spatial_size, 3),
681682
rays_directions_world.view(batch_size, *spatial_size, 3),

0 commit comments

Comments
 (0)