A Survey on 3DGS


Directions

1. Data-efficient 3D GS

  1. Regularization-based methods
    • Approach: introduce additional constraints to improve detail and overall consistency
      • DNGaussian [49]: improves geometric quality via depth regularization.
      • FSGS [46]: introduces Gaussian Unpooling and a depth regularization technique.
      • MVSplat [51]: provides geometric cues through a cost volume representation.
  2. Generalizability-based methods
    • Approach: aims for effective reconstruction even with little data through learned priors.
      • PixelSplat [47]: samples Gaussians from a dense probability distribution.
      • Splatter Image [48]: generates 3D Gaussians from a single image.

2. Memory-efficient 3D GS

  1. Reducing the number of 3D Gaussians
    • Approach: optimizes memory usage by removing unnecessary Gaussians.
      • Papantonakis et al. [63]: resolution-based Gaussian pruning technique.
      • Lee et al. [58]: reduces the number of Gaussians with a volume masking strategy.
  2. Compressing 3D Gaussian properties
    • Approach: minimizes storage by compressing the colors and parameters of Gaussians.
      • Niedermayr et al. [61]: compresses colors and Gaussian parameters into a codebook.
      • HAC [62]: develops a per-attribute adaptive quantization module.

3. Photorealistic 3D GS

Approach:

  1. Handling resolution changes
    • Strategy: address aliasing problems that arise at various resolutions.
    • Models:
      • Multi-scale 3D GS [67]: multi-scale representation using Gaussians of various sizes.
      • Analytic-Splatting [78]: uses an analytic approximation of the Gaussian integral within a pixel region.
  2. Using reflection and geometry information
    • Strategy: strengthen reflective-surface rendering and geometric accuracy.
    • Models:
      • GaussianShader [68]: adds a simplified shading function to 3D Gaussians.
      • GeoGaussian [77]: preserves the geometry of texture-less regions (e.g., walls, furniture).

4. Improved Optimization Algorithms

Approach:

  1. Introducing additional regularization
    • Strategy: improve visual quality with geometry- and frequency-based regularization.
    • Models:
      • FreGS [84]: frequency-based Gaussian density control.
      • Scaffold-GS [22]: structures Gaussians through a grid of anchor points.
  2. Improving the optimization procedure
    • Strategy: improve optimization through density initialization and minimizing SfM dependence.
    • Models:
      • GaussianPro [44]: geometry-based Gaussian densification strategy.
      • COLMAP-Free 3D GS [81]: removes the SfM step and uses the point cloud directly.

5. 3D Gaussian with More Properties

Approach:

  1. Integrating language embeddings
    • Strategy: add language information to 3D Gaussians to enable semantic queries.
    • Models:
      • Shi et al. [87]: strengthens scene representation through lightweight language embeddings.
  2. Adding spatio-temporal and semantic information
    • Strategy: integrate spatio-temporal characteristics and semantic/instance information into Gaussians.
    • Models:
      • Feature 3DGS [90]: distills feature fields from 2D models.
      • Yang et al. [93]: models spatio-temporal dynamic scenes with 4D Gaussians.

6. 3D GS with Structured Information

Approach:

  1. Combining with structured information
    • Strategy: introduce structured information tailored to specific tasks such as facial expression and spatio-temporal modeling.
    • Models:
      • Gaussian Head Avatar [96]: 3D Gaussians combined with a deformation field for facial expression.
      • Yang et al. [94]: deformable 3D Gaussians for dynamic scene reconstruction.
  2. Style transfer and editing
    • Strategy: use structured representations for style transfer and editing functions.
    • Models:
      • GS in Style [153]: style transfer combined with a multi-resolution hash grid.
      • CoGS [119]: scene editing using a joint Gaussian structure.

In this way, for each direction two approaches and the strategies and models that follow from them were presented.

3DGS Code Review


train.py

It consists of the main function training and functions for output preparation, logging, and reporting.

training
def training(dataset, opt, pipe, testing_iterations, saving_iterations, checkpoint_iterations, checkpoint, debug_from):

		... 

    first_iter = 0
    tb_writer = prepare_output_and_logger(dataset)
    gaussians = GaussianModel(dataset.sh_degree, opt.optimizer_type) # Gaussian Model객체 생성
    scene = Scene(dataset, gaussians) # Scene 생성
    gaussians.training_setup(opt) # Optim 기반 학습 준비(from gaussian_model.py)
		
		...

    iter_start = torch.cuda.Event(enable_timing = True)
    iter_end = torch.cuda.Event(enable_timing = True)

    use_sparse_adam = opt.optimizer_type == "sparse_adam" and SPARSE_ADAM_AVAILABLE 
    depth_l1_weight = get_expon_lr_func(opt.depth_l1_weight_init, opt.depth_l1_weight_final, max_steps=opt.iterations) # general_utils 내에서 import해온 continuous lr decay 함수
    viewpoint_stack = scene.getTrainCameras().copy() # train할 viewpoint stack. Scene 객체의 self.train_cameras 딕셔너리의 viewpoint들을 가져옴
    viewpoint_indices = list(range(len(viewpoint_stack)))
    ema_loss_for_log = 0.0
    ema_Ll1depth_for_log = 0.0

    progress_bar = tqdm(range(first_iter, opt.iterations), desc="Training progress")
    first_iter += 1
    
    # 메인 루프
    for iteration in range(first_iter, opt.iterations + 1):
        if network_gui.conn == None: # 네트워크 GUI를 통해 원격으로 학습과정 시각화 or 조작 가능
            network_gui.try_connect()
        while network_gui.conn != None:
            try:
                net_image_bytes = None
                custom_cam, do_training, pipe.convert_SHs_python, pipe.compute_cov3D_python, keep_alive, scaling_modifer = network_gui.receive()
                if custom_cam != None:
                    net_image = render(custom_cam, gaussians, pipe, background, scaling_modifier=scaling_modifer, use_trained_exp=dataset.train_test_exp, separate_sh=SPARSE_ADAM_AVAILABLE)["render"]
                    net_image_bytes = memoryview((torch.clamp(net_image, min=0, max=1.0) * 255).byte().permute(1, 2, 0).contiguous().cpu().numpy())
                network_gui.send(net_image_bytes, dataset.source_path)
                if do_training and ((iteration < int(opt.iterations)) or not keep_alive):
                    break
            except Exception as e:
                network_gui.conn = None

        iter_start.record()

        gaussians.update_learning_rate(iteration) # pretrained 된 노출 값이 없다면 exposure lr + 좌표 xyz lr 함께 업데이트

        # Render
        if (iteration - 1) == debug_from: # 파라미터로 지정해준 debug용 렌더 카메라 뷰
            pipe.debug = True

        bg = torch.rand((3), device="cuda") if opt.random_background else background

        render_pkg = render(viewpoint_cam, gaussians, pipe, bg, use_trained_exp=dataset.train_test_exp, separate_sh=SPARSE_ADAM_AVAILABLE)
        image, viewspace_point_tensor, visibility_filter, radii = render_pkg["render"], render_pkg["viewspace_points"], render_pkg["visibility_filter"], render_pkg["radii"]

        if viewpoint_cam.alpha_mask is not None:
            alpha_mask = viewpoint_cam.alpha_mask.cuda()
            image *= alpha_mask

        # Loss
        gt_image = viewpoint_cam.original_image.cuda()
        Ll1 = l1_loss(image, gt_image)
        if FUSED_SSIM_AVAILABLE:
            ssim_value = fused_ssim(image.unsqueeze(0), gt_image.unsqueeze(0))
        else:
            ssim_value = ssim(image, gt_image)

        loss = (1.0 - opt.lambda_dssim) * Ll1 + opt.lambda_dssim * (1.0 - ssim_value)

        # Depth regularization: 렌더링된 depth(invDepth)과 실제 depth(mono_invdepth) 간의 오차를 추가 loss로 씀
               Ll1depth_pure = 0.0
        if depth_l1_weight(iteration) > 0 and viewpoint_cam.depth_reliable:
            invDepth = render_pkg["depth"]
            mono_invdepth = viewpoint_cam.invdepthmap.cuda()
            depth_mask = viewpoint_cam.depth_mask.cuda()

            Ll1depth_pure = torch.abs((invDepth  - mono_invdepth) * depth_mask).mean()
            Ll1depth = depth_l1_weight(iteration) * Ll1depth_pure 
            loss += Ll1depth
            Ll1depth = Ll1depth.item()
        else:
            Ll1depth = 0
				
				# 역전파
        loss.backward()

        iter_end.record()

        with torch.no_grad():
            # Progress bar
            ema_loss_for_log = 0.4 * loss.item() + 0.6 * ema_loss_for_log
            ema_Ll1depth_for_log = 0.4 * Ll1depth + 0.6 * ema_Ll1depth_for_log

            if iteration % 10 == 0:
                progress_bar.set_postfix({"Loss": f"{ema_loss_for_log:.{7}f}", "Depth Loss": f"{ema_Ll1depth_for_log:.{7}f}"})
                progress_bar.update(10)
            if iteration == opt.iterations:
                progress_bar.close()

            # Log and save
            training_report(tb_writer, iteration, Ll1, loss, l1_loss, iter_start.elapsed_time(iter_end), testing_iterations, scene, render, (pipe, background, 1., SPARSE_ADAM_AVAILABLE, None, dataset.train_test_exp), dataset.train_test_exp)
            if (iteration in saving_iterations):
                print("\n[ITER {}] Saving Gaussians".format(iteration))
                scene.save(iteration)

            # Densification
            if iteration < opt.densify_until_iter: # OptimizationParams 객체에 지정된 densification 수행 iter range 내에서 densification 진행
                # Keep track of max radii in image-space for pruning
                gaussians.max_radii2D[visibility_filter] = torch.max(gaussians.max_radii2D[visibility_filter], radii[visibility_filter])
                gaussians.add_densification_stats(viewspace_point_tensor, visibility_filter)

                if iteration > opt.densify_from_iter and iteration % opt.densification_interval == 0:
                    size_threshold = 20 if iteration > opt.opacity_reset_interval else None
                    gaussians.densify_and_prune(opt.densify_grad_threshold, 0.005, scene.cameras_extent, size_threshold, radii)
                
                if iteration % opt.opacity_reset_interval == 0 or (dataset.white_background and iteration == opt.densify_from_iter):
                    gaussians.reset_opacity() # opacity reset 반복

            # Optimizer step
            if iteration < opt.iterations:
                gaussians.exposure_optimizer.step()
                gaussians.exposure_optimizer.zero_grad(set_to_none = True)
                if use_sparse_adam:
                    visible = radii > 0
                    gaussians.optimizer.step(visible, radii.shape[0])
                    gaussians.optimizer.zero_grad(set_to_none = True)
                else:
                    gaussians.optimizer.step()
                    gaussians.optimizer.zero_grad(set_to_none = True)

            if (iteration in checkpoint_iterations):
                print("\n[ITER {}] Saving Checkpoint".format(iteration))
                torch.save((gaussians.capture(), iteration), scene.model_path + "/chkpnt" + str(iteration) + ".pth")

scene/gaussian_model.py

The GaussianModel class is defined here. It stores the parameter data of all Gaussians in the scene and defines the related functions.

Parameters

# xyz 위치좌표
self._xyz = torch.empty(0)  # 초기화 시 빈 텐서, 이후 (N, 3) 형태로 저장

# 크기
self._scaling = torch.empty(0)  # (N, 3) 형태로 저장

# 회전(쿼터니언)
self._rotation = torch.empty(0)  # (N, 4) 형태로 저장

# 색상(SH)
self._features_dc = torch.empty(0)  # DC 성분 (N, 3, 1)
self._features_rest = torch.empty(0)  # 나머지 SH 성분 (N, 3, (SH_degree + 1)^2 - 1)

# Opacity
self._opacity = torch.empty(0)  # (N, 1)

Densification & Pruning

def add_densification_stats(self, viewspace_point_tensor, update_filter):
        self.xyz_gradient_accum[update_filter] += torch.norm(viewspace_point_tensor.grad[update_filter,:2], dim=-1, keepdim=True)
        self.denom[update_filter] += 1
  • Accumulate gradient information for each Gaussian → build the data needed to decide which Gaussians require densification.
  • The larger the gradient, the more the Gaussian sits in a complex region of the scene → refine it.
  • parameters
    • viewspace_point_tensor: a tensor representing the position of each Gaussian in the camera coordinate system. Contains gradient information.
    • update_filter: a masking filter that selects points requiring updates based on index.
def densify_and_prune(self, max_grad, min_opacity, extent, max_screen_size, radii):
        grads = self.xyz_gradient_accum / self.denom
        grads[grads.isnan()] = 0.0

        self.tmp_radii = radii
        self.densify_and_clone(grads, max_grad, extent)
        self.densify_and_split(grads, max_grad, extent)

        prune_mask = (self.get_opacity < min_opacity).squeeze()
        if max_screen_size:
            big_points_vs = self.max_radii2D > max_screen_size
            big_points_ws = self.get_scaling.max(dim=1).values > 0.1 * extent
            prune_mask = torch.logical_or(torch.logical_or(prune_mask, big_points_vs), big_points_ws)
        self.prune_points(prune_mask)
        tmp_radii = self.tmp_radii
        self.tmp_radii = None

        torch.cuda.empty_cache()
  • Called directly in the densification process of train.py, leading to clone, split, and prune.
  • Computes the average gradient based on self.xyz_gradient_accum accumulated in add_densification_stats

    → calls densify_and_split and densify_and_clone

  • Afterwards, deletes Gaussians whose opacity is below the threshold or that are too large
def densify_and_split(self, grads, grad_threshold, scene_extent, N=2):
        n_init_points = self.get_xyz.shape[0]
        # Extract points that satisfy the gradient condition
        padded_grad = torch.zeros((n_init_points), device="cuda")
        padded_grad[:grads.shape[0]] = grads.squeeze()
        selected_pts_mask = torch.where(padded_grad >= grad_threshold, True, False)
        selected_pts_mask = torch.logical_and(selected_pts_mask,
                                              torch.max(self.get_scaling, dim=1).values > self.percent_dense*scene_extent)

        stds = self.get_scaling[selected_pts_mask].repeat(N,1)
        means =torch.zeros((stds.size(0), 3),device="cuda")
        samples = torch.normal(mean=means, std=stds)
        rots = build_rotation(self._rotation[selected_pts_mask]).repeat(N,1,1)
        new_xyz = torch.bmm(rots, samples.unsqueeze(-1)).squeeze(-1) + self.get_xyz[selected_pts_mask].repeat(N, 1)
        new_scaling = self.scaling_inverse_activation(self.get_scaling[selected_pts_mask].repeat(N,1) / (0.8*N))
        new_rotation = self._rotation[selected_pts_mask].repeat(N,1)
        new_features_dc = self._features_dc[selected_pts_mask].repeat(N,1,1)
        new_features_rest = self._features_rest[selected_pts_mask].repeat(N,1,1)
        new_opacity = self._opacity[selected_pts_mask].repeat(N,1)
        new_tmp_radii = self.tmp_radii[selected_pts_mask].repeat(N)

        self.densification_postfix(new_xyz, new_features_dc, new_features_rest, new_opacity, new_scaling, new_rotation, new_tmp_radii)

        prune_filter = torch.cat((selected_pts_mask, torch.zeros(N * selected_pts_mask.sum(), device="cuda", dtype=bool)))
        self.prune_points(prune_filter)
  • Select Gaussians based on gradient
  • Do not split those that are too small in size
  • Sample according to a normal distribution and create a new Gaussian at that position
  • Copy rotation, color, and opacity from the original Gaussian to set the new parameters
  • Remove duplicate points
def densify_and_clone(self, grads, grad_threshold, scene_extent):
        # Extract points that satisfy the gradient condition
        selected_pts_mask = torch.where(torch.norm(grads, dim=-1) >= grad_threshold, True, False)
        selected_pts_mask = torch.logical_and(selected_pts_mask,
                                              torch.max(self.get_scaling, dim=1).values <= self.percent_dense*scene_extent)
        
        new_xyz = self._xyz[selected_pts_mask]
        new_features_dc = self._features_dc[selected_pts_mask]
        new_features_rest = self._features_rest[selected_pts_mask]
        new_opacities = self._opacity[selected_pts_mask]
        new_scaling = self._scaling[selected_pts_mask]
        new_rotation = self._rotation[selected_pts_mask]

        new_tmp_radii = self.tmp_radii[selected_pts_mask]

        self.densification_postfix(new_xyz, new_features_dc, new_features_rest, new_opacities, new_scaling, new_rotation, new_tmp_radii)
  • Opposite of split: do not clone those that are too large in size
  • Instead of creating a new Gaussian at a sampled position, clone it in place