Skip to content

Commit

Permalink
fix error of computing normals due to ray direction normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
lizhiqi49 committed Apr 8, 2024
1 parent d193769 commit cd3aa08
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
5 changes: 1 addition & 4 deletions custom/threestudio-3dgs/configs/mvcontrol-gaussian.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ data:
eval_fovy_deg: 49.1
eval_elevation_deg: 0
n_val_views: 8
# relative_radius: false
# n_predict_views: 800
# predict_azimuth_range: [-180, 180]
# predict_elevation_range: [-10, 80]
rays_d_normalize: false

system_type: "sugar-mvcontrol-system"
system:
Expand Down
1 change: 1 addition & 0 deletions custom/threestudio-3dgs/configs/mvcontrol-sugar-vsd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ data:
predict_azimuth_range: [-180, 180]
predict_elevation_range: [-10, 80]
predict_camera_distance_range: [1.3, 1.5]
rays_d_normalize: false

system_type: "sugar-mvcontrol-system"
system:
Expand Down
15 changes: 11 additions & 4 deletions custom/threestudio-3dgs/data/uncond.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class RandomCameraDataModuleConfig:
predict_azimuth_range: Tuple[float, float] = (-180, 180)
predict_elevation_range: Tuple[float, float] = (-10, 80)
predict_camera_distance_range: Tuple[float, float] = (1.5, 2.0)
# rays_d_normalize: bool = True

rays_d_normalize: bool = True


class RandomCameraIterableDataset(IterableDataset, Updateable):
Expand Down Expand Up @@ -323,7 +324,9 @@ def collate(self, batch) -> Dict[str, Any]:
)

# Importance note: the returned rays_d MUST be normalized!
rays_o, rays_d = get_rays(directions, c2w, keepdim=True)
rays_o, rays_d = get_rays(
directions, c2w, keepdim=True, normalize=self.cfg.rays_d_normalize
)

proj_mtx: Float[Tensor, "B 4 4"] = get_projection_matrix(
fovy, self.width / self.height, 0.1, 1000.0
Expand Down Expand Up @@ -427,7 +430,9 @@ def __init__(self, cfg: Any, split: str) -> None:
directions[:, :, :, :2] / focal_length[:, None, None, None]
)

rays_o, rays_d = get_rays(directions, c2w, keepdim=True)
rays_o, rays_d = get_rays(
directions, c2w, keepdim=True, normalize=self.cfg.rays_d_normalize
)
proj_mtx: Float[Tensor, "B 4 4"] = get_projection_matrix(
fovy, self.cfg.eval_width / self.cfg.eval_height, 0.1, 1000.0
) # FIXME: hard-coded near and far
Expand Down Expand Up @@ -596,7 +601,9 @@ def __init__(self, cfg: Any, split: str = "prediction") -> None:
directions[:, :, :, :2] / focal_length[:, None, None, None]
)

rays_o, rays_d = get_rays(directions, c2w, keepdim=True)
rays_o, rays_d = get_rays(
directions, c2w, keepdim=True, normalize=self.cfg.rays_d_normalize
)
proj_mtx: Float[Tensor, "B 4 4"] = get_projection_matrix(
fovy, self.cfg.predict_width / self.cfg.predict_height, 0.1, 1000.0
) # FIXME: hard-coded near and far
Expand Down

0 comments on commit cd3aa08

Please sign in to comment.