Skip to content

Commit

Permalink
Bugfix - normalize emitted ray directions after substraction
Browse files Browse the repository at this point in the history
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
  • Loading branch information
davnov134 authored and facebook-github-bot committed Oct 31, 2022
1 parent bea84a6 commit eff0aad
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pytorch3d/renderer/implicit/raysampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,12 +670,13 @@ def _xy_to_ray_bundle(

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

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

if unit_directions:
rays_directions_world = F.normalize(rays_directions_world, dim=-1)

return RayBundle(
rays_origins_world.view(batch_size, *spatial_size, 3),
rays_directions_world.view(batch_size, *spatial_size, 3),
Expand Down

0 comments on commit eff0aad

Please sign in to comment.