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$:
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!
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}$:
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)
| Dimension | NeRF / Instant-NGP | 3D Gaussian Splatting |
|---|---|---|
| Scene Representation | Implicit MLP + hash grid | Explicit 3D Gaussians + Spherical Harmonics |
| Rendering Algorithm | Volumetric ray-marching ($64$–$256$ MLP evals/px) | Tile-based radix-sorted rasterization |
| Real-Time 1080p FPS | 5–15 FPS (even with hash grids) | 100–250+ FPS on consumer GPUs |
| Memory Footprint | Tiny (10–50 MB) | Large (200 MB–1.2 GB for millions of splats) |