mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-03 06:18:44 +08:00
Implement new rasterization mode using opacity compensation factor (#2888)
Implement new rasterization mode for tiny gaussians
This commit is contained in:
2 files changed
+24
-3
No files matched your search
@@ -157,6 +157,16 @@ class SplatfactoModelConfig(ModelConfig):
|
|||||||
"""
|
"""
|
||||||
output_depth_during_training: bool = False
|
output_depth_during_training: bool = False
|
||||||
"""If True, output depth during training. Otherwise, only output depth during evaluation."""
|
"""If True, output depth during training. Otherwise, only output depth during evaluation."""
|
||||||
|
rasterize_mode: Literal["classic", "antialiased"] = "classic"
|
||||||
|
"""
|
||||||
|
Classic mode of rendering will use the EWA volume splatting with a [0.3, 0.3] screen space blurring kernel. This
|
||||||
|
approach is however not suitable to render tiny gaussians at higher or lower resolution than the captured, which
|
||||||
|
results "aliasing-like" artifacts. The antialiased mode overcomes this limitation by calculating compensation factors
|
||||||
|
and apply them to the opacities of gaussians to preserve the total integrated density of splats.
|
||||||
|
|
||||||
|
However, PLY exported with antialiased rasterize mode is not compatible with classic mode. Thus many web viewers that
|
||||||
|
were implemented for classic mode can not render antialiased mode PLY properly without modifications.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class SplatfactoModel(Model):
|
class SplatfactoModel(Model):
|
||||||
@@ -721,7 +731,7 @@ class SplatfactoModel(Model):
|
|||||||
|
|
||||||
colors_crop = torch.cat((features_dc_crop[:, None, :], features_rest_crop), dim=1)
|
colors_crop = torch.cat((features_dc_crop[:, None, :], features_rest_crop), dim=1)
|
||||||
|
|
||||||
self.xys, depths, self.radii, conics, num_tiles_hit, cov3d = project_gaussians( # type: ignore
|
self.xys, depths, self.radii, conics, comp, num_tiles_hit, cov3d = project_gaussians( # type: ignore
|
||||||
means_crop,
|
means_crop,
|
||||||
torch.exp(scales_crop),
|
torch.exp(scales_crop),
|
||||||
1,
|
1,
|
||||||
@@ -736,6 +746,7 @@ class SplatfactoModel(Model):
|
|||||||
W,
|
W,
|
||||||
tile_bounds,
|
tile_bounds,
|
||||||
) # type: ignore
|
) # type: ignore
|
||||||
|
|
||||||
if (self.radii).sum() == 0:
|
if (self.radii).sum() == 0:
|
||||||
rgb = background.repeat(int(camera.height.item()), int(camera.width.item()), 1)
|
rgb = background.repeat(int(camera.height.item()), int(camera.width.item()), 1)
|
||||||
depth = background.new_ones(*rgb.shape[:2], 1) * 10
|
depth = background.new_ones(*rgb.shape[:2], 1) * 10
|
||||||
@@ -758,6 +769,16 @@ class SplatfactoModel(Model):
|
|||||||
# rescale the camera back to original dimensions
|
# rescale the camera back to original dimensions
|
||||||
camera.rescale_output_resolution(camera_downscale)
|
camera.rescale_output_resolution(camera_downscale)
|
||||||
assert (num_tiles_hit > 0).any() # type: ignore
|
assert (num_tiles_hit > 0).any() # type: ignore
|
||||||
|
|
||||||
|
# apply the compensation of screen space blurring to gaussians
|
||||||
|
opacities = None
|
||||||
|
if self.config.rasterize_mode == "antialiased":
|
||||||
|
opacities = torch.sigmoid(opacities_crop) * comp[:, None]
|
||||||
|
elif self.config.rasterize_mode == "classic":
|
||||||
|
opacities = torch.sigmoid(opacities_crop)
|
||||||
|
else:
|
||||||
|
raise ValueError("Unknown rasterize_mode: %s", self.config.rasterize_mode)
|
||||||
|
|
||||||
rgb, alpha = rasterize_gaussians( # type: ignore
|
rgb, alpha = rasterize_gaussians( # type: ignore
|
||||||
self.xys,
|
self.xys,
|
||||||
depths,
|
depths,
|
||||||
@@ -765,7 +786,7 @@ class SplatfactoModel(Model):
|
|||||||
conics,
|
conics,
|
||||||
num_tiles_hit, # type: ignore
|
num_tiles_hit, # type: ignore
|
||||||
rgbs,
|
rgbs,
|
||||||
torch.sigmoid(opacities_crop),
|
opacities,
|
||||||
H,
|
H,
|
||||||
W,
|
W,
|
||||||
background=background,
|
background=background,
|
||||||
|
|||||||
+1
-1
@@ -63,7 +63,7 @@ dependencies = [
|
|||||||
"xatlas",
|
"xatlas",
|
||||||
"trimesh>=3.20.2",
|
"trimesh>=3.20.2",
|
||||||
"timm==0.6.7",
|
"timm==0.6.7",
|
||||||
"gsplat==0.1.3",
|
"gsplat>=0.1.5",
|
||||||
"pytorch-msssim",
|
"pytorch-msssim",
|
||||||
"pathos",
|
"pathos",
|
||||||
"packaging"
|
"packaging"
|
||||||
|
|||||||
Reference in new issue
Block a user