Skip to content

10 — 2D Gaussian Splatting

Example file: examples/10_gaussian2d.py

3D Gaussian Splatting (3DGS) took neural rendering by storm. But the core idea is surprisingly simple: scatter a bunch of colored blobs, alpha-composite them together, compare to a target image, and backprop.

This example strips 3DGS down to its 2D essence. No camera projection, no spherical harmonics, no tile-based rasterizer. Just N learnable 2D Gaussians — each with position, scale, rotation, color, and opacity — rendered via differentiable alpha compositing and optimized with plain PyTorch autograd.

Watch the Gaussians wander across the canvas, scale up, rotate, change color, and gradually reassemble the target image. That's the algorithm that renders photorealistic scenes at 100+ fps.

New friends

New thing What it does Why it matters
nn.Parameter for Gaussians Position, log-scale, rotation, raw color, raw opacity Every Gaussian attribute is learnable — autograd handles the rest
Inverse covariance $\Sigma^{-1}$ from scale + rotation The math that gives each Gaussian its elliptical shape
Alpha compositing $C = \sum_i \alpha_i T_i c_i$ where $T_i = \prod_{j