@@ -55,8 +55,11 @@ class AccumulativeRaymarcherBase(RaymarcherBase, torch.nn.Module):
55
55
surface_thickness: The thickness of the raymarched surface.
56
56
bg_color: The background color. A tuple of either 1 element or of D elements,
57
57
where D matches the feature dimensionality; it is broadcast when necessary.
58
- background_opacity: The raw opacity value (i.e. before exponentiation)
59
- of the background.
58
+ replicate_last_interval: If True, the ray length assigned to the last interval
59
+ for the opacity delta calculation is copied from the penultimate interval.
60
+ background_opacity: The length over which the last raw opacity value
61
+ (i.e. before exponentiation) is considered to apply, for the delta
62
+ calculation. Ignored if replicate_last_interval=True.
60
63
density_relu: If `True`, passes the input density through ReLU before
61
64
raymarching.
62
65
blend_output: If `True`, alpha-blends the output renders with the
@@ -76,6 +79,7 @@ class AccumulativeRaymarcherBase(RaymarcherBase, torch.nn.Module):
76
79
77
80
surface_thickness : int = 1
78
81
bg_color : Tuple [float , ...] = (0.0 ,)
82
+ replicate_last_interval : bool = False
79
83
background_opacity : float = 0.0
80
84
density_relu : bool = True
81
85
blend_output : bool = False
@@ -151,13 +155,14 @@ def forward(
151
155
density_1d = True ,
152
156
)
153
157
154
- deltas = torch .cat (
155
- (
156
- ray_lengths [..., 1 :] - ray_lengths [..., :- 1 ],
157
- self .background_opacity * torch .ones_like (ray_lengths [..., :1 ]),
158
- ),
159
- dim = - 1 ,
160
- )
158
+ ray_lengths_diffs = ray_lengths [..., 1 :] - ray_lengths [..., :- 1 ]
159
+ if self .replicate_last_interval :
160
+ last_interval = ray_lengths_diffs [..., - 1 :]
161
+ else :
162
+ last_interval = torch .full_like (
163
+ ray_lengths [..., :1 ], self .background_opacity
164
+ )
165
+ deltas = torch .cat ((ray_lengths_diffs , last_interval ), dim = - 1 )
161
166
162
167
rays_densities = rays_densities [..., 0 ]
163
168
0 commit comments