mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-23 16:15:36 +08:00
feat(fields): create common get_normalized_directions fn (#1599)
* feat(fields): create common get_normalized_directions fn * style: run black * refactor: rename func and update docstring
This commit is contained in:
1 parent
630babacd6
commit
de6af6c4e5
5 files changed
+17
-36
No files matched your search
@@ -46,7 +46,7 @@ from nerfstudio.field_components.spatial_distortions import (
|
||||
SceneContraction,
|
||||
SpatialDistortion,
|
||||
)
|
||||
from nerfstudio.fields.base_field import Field
|
||||
from nerfstudio.fields.base_field import Field, shift_directions_for_tcnn
|
||||
|
||||
try:
|
||||
import tinycudann as tcnn
|
||||
@@ -55,15 +55,6 @@ except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
def get_normalized_directions(directions: TensorType["bs":..., 3]) -> TensorType["bs":..., 3]:
|
||||
"""SH encoding must be in the range [0, 1]
|
||||
|
||||
Args:
|
||||
directions: batch of directions
|
||||
"""
|
||||
return (directions + 1.0) / 2.0
|
||||
|
||||
|
||||
class TCNNNerfactoField(Field):
|
||||
"""Compound Field that uses TCNN
|
||||
|
||||
@@ -267,7 +258,7 @@ class TCNNNerfactoField(Field):
|
||||
if ray_samples.camera_indices is None:
|
||||
raise AttributeError("Camera indices are not provided.")
|
||||
camera_indices = ray_samples.camera_indices.squeeze()
|
||||
directions = get_normalized_directions(ray_samples.frustums.directions)
|
||||
directions = shift_directions_for_tcnn(ray_samples.frustums.directions)
|
||||
directions_flat = directions.view(-1, 3)
|
||||
d = self.direction_encoding(directions_flat)
|
||||
|
||||
|
||||
Reference in new issue
Block a user