AI/ML 3D Vision Gaussian Splatting Differentiable Rendering GPU Systems

3D Gaussian Splatting from First Principles: EWA Projection, Differentiable Rasterization & Tile Sorting


For three years, Neural Radiance Fields (NeRFs) dominated novel-view synthesis – but paid a brutal price: marching hundreds of rays per pixel through an MLP kept frame rates stuck in seconds-per-frame. 3D Gaussian Splatting (3DGS) (Kerbl et al., SIGGRAPH 2023, arXiv:2308.04079) flipped the paradigm completely: represent the scene explicitly as millions of learnable anisotropic 3D Gaussians, project them analytically onto the image plane via EWA splatting, and rasterize them in sorted $16\times 16$ GPU tiles at $100+$ FPS – all while staying 100% end-to-end differentiable.


1. Parameterizing Positive-Semi-Definite 3D Covariances

An unnormalized 3D Gaussian centered at $\boldsymbol{\mu} \in \mathbb{R}^3$ with covariance $\Sigma \in \mathbb{R}^{3\times 3}$ has density $G(\mathbf{x}) = \exp\big(-\frac{1}{2}(\mathbf{x}-\boldsymbol{\mu})^\top \Sigma^{-1}(\mathbf{x}-\boldsymbol{\mu})\big)$. You cannot optimize the 9 entries of $\Sigma$ directly with gradient descent because arbitrary updates break positive-semi-definiteness ($\Sigma \succeq 0$). Instead, 3DGS factorizes $\Sigma$ into a unit quaternion $\mathbf{q} \in \mathbb{S}^3$ (converted to rotation matrix $R$) and a 3D log-scale vector $\mathbf{s} \in \mathbb{R}^3$:

3D Covariance Factorization & EWA Screen-Space Projection (Kerbl et al., 2023)
$$\Sigma = R\,S\,S^\top\,R^\top, \qquad S = \mathrm{diag}(e^{s_x}, e^{s_y}, e^{s_z})$$ $$\Sigma' = J\,W\,\Sigma\,W^\top\,J^\top \in \mathbb{R}^{2\times 2}, \qquad J = \begin{pmatrix} \frac{f_x}{t_z} & 0 & -\frac{f_x t_x}{t_z^2} \\ 0 & \frac{f_y}{t_z} & -\frac{f_y t_y}{t_z^2} \end{pmatrix}$$

Here $W$ is the world-to-camera rotation, $\mathbf{t} = (t_x, t_y, t_z)^\top$ is the Gaussian center in camera coordinates, and $J \in \mathbb{R}^{2\times 3}$ is the first-order affine Jacobian of the perspective projection (with the depth row already dropped), so $\Sigma'$ directly yields the exact 2D screen-space conic ellipse!

1. 3D Gaussians μ, q, s, α, SH (deg 3) Frustum cull + EWA Σ′ 2. Tile Duplication 16×16 screen tiles 64-bit key = (tile_id | depth) 3. GPU Radix Sort Single CUB DeviceRadixSort Front-to-back per tile 4. Tile Alpha Blend Shared SRAM batch loads Early exit when T < 10⁻⁴
The 3DGS differentiable rasterizer replaces per-pixel ray-marching with a single global GPU radix sort and shared-memory tile blending.

2. Front-to-Back Alpha Compositing & Exact Reverse-Order Gradients

Once sorted front-to-back within each $16\times 16$ tile, every pixel accumulates color $C$ and remaining transmittance $T_i = \prod_{j=1}^{i-1}(1 - \alpha_j)$ until $T_i \lt 10^{-4}$:

Differentiable Volume Compositing & Backward Recurrence
$$C = \sum_{i=1}^{N} c_i\,\alpha_i\,T_i, \qquad \alpha_i = \sigma(o_i)\exp\!\left(-\frac{1}{2}\Delta\mathbf{p}_i^\top (\Sigma'_i)^{-1}\Delta\mathbf{p}_i\right)$$ $$\frac{\partial C}{\partial \alpha_i} = T_i\,c_i - \frac{1}{1 - \alpha_i}\sum_{k=i+1}^{N} c_k\,\alpha_k\,T_k$$

Notice the beauty of the backward pass: because the forward pass only stores the final transmittance $T_{\text{final}}$ and last-contributed index per pixel, the backward kernel traverses the exact same tile list back-to-front, recovering $T_i = T_{i+1} / (1 - \alpha_i)$ on the fly in registers – zero per-splat activation storage in HBM!

💻 Python: Analytic EWA 3D-to-2D Gaussian ProjectionPyTorch
import torch

def project_gaussians_2d(means3d, quats, log_scales, W_cam, fx, fy):
    # Analytic EWA projection of 3D Gaussians to 2D screen-space conics
    q = quats / (quats.norm(dim=-1, keepdim=True) + 1e-8)
    w, x, y, z = q.unbind(-1)
    R = torch.stack([
        1 - 2*(y*y + z*z), 2*(x*y - z*w),     2*(x*z + y*w),
        2*(x*y + z*w),     1 - 2*(x*x + z*z), 2*(y*z - x*w),
        2*(x*z - y*w),     2*(y*z + x*w),     1 - 2*(x*x + y*y),
    ], dim=-1).view(-1, 3, 3)

    S = torch.diag_embed(torch.exp(log_scales))
    M = R @ S
    Sigma = M @ M.transpose(-1, -2)                 # [N, 3, 3] PSD covariance

    t = (means3d @ W_cam[:3, :3].T) + W_cam[:3, 3]  # camera-space centers
    tx, ty, tz = t.unbind(-1)
    tz_inv = 1.0 / tz.clamp(min=0.1)
    J = torch.zeros(means3d.shape[0], 2, 3, device=means3d.device, dtype=means3d.dtype)
    J[:, 0, 0] = fx * tz_inv
    J[:, 0, 2] = -fx * tx * tz_inv * tz_inv
    J[:, 1, 1] = fy * tz_inv
    J[:, 1, 2] = -fy * ty * tz_inv * tz_inv

    W = W_cam[:3, :3].unsqueeze(0)
    T = J @ W
    cov2d = T @ Sigma @ T.transpose(-1, -2)         # [N, 2, 2]
    # Low-pass anti-aliasing filter (out-of-place for autograd safety)
    return cov2d + 0.3 * torch.eye(2, device=means3d.device, dtype=means3d.dtype)
Adaptive Density Control Footguns: (1) View-space positional gradient threshold: Gaussians in under-reconstructed regions accumulate large average screen-space gradients $\|\nabla_{\text{ndc}} \mathcal{L}\| \gt \tau_{\text{pos}}$; small Gaussians get cloned while large over-reconstructed ones get split along their principal scale axis by $1.6\times$. (2) Periodic opacity reset: resetting all $\alpha_i \leftarrow 0.01$ every 3,000 steps flushes out "floater" clouds stuck right in front of training cameras.
DimensionNeRF / Instant-NGP3D Gaussian Splatting
Scene RepresentationImplicit MLP + hash gridExplicit 3D Gaussians + Spherical Harmonics
Rendering AlgorithmVolumetric ray-marching ($64$–$256$ MLP evals/px)Tile-based radix-sorted rasterization
Real-Time 1080p FPS5–15 FPS (even with hash grids)100–250+ FPS on consumer GPUs
Memory FootprintTiny (10–50 MB)Large (200 MB–1.2 GB for millions of splats)