vispy.visuals.gaussian_splat module#

A visual for rendering 3D Gaussian Splatting scenes.

class vispy.visuals.gaussian_splat.GaussianSplatVisual(positions, covariances, colors, opacities=None, *, antialias=False)#

Bases: Visual

Renderer for a 3D Gaussian Splatting scene.

Each Gaussian (“splat”) is defined by a center, a 3x3 covariance matrix, and an RGBA color. Each is drawn as an instanced screen-aligned (billboarded) quad - similar to the instanced Markers visual.

The 3D covariance is projected to a 2D screen-space covariance in the vertex shader using a finite-difference Jacobian of the visual->framebuffer projection (the vispy equivalent of the model-view-projection). Finite differences are used because that projection is nonlinear under a perspective camera. The fragment shader evaluates the resulting 2D Gaussian. Splats are sorted and rendered back-to-front and blended (no depth testing).

Parameters:
positions(N, 3) array

Gaussian centers, in visual coordinates.

covariances(N, 3, 3) array

Symmetric positive-definite 3D covariance matrix for each Gaussian.

colorsarray or Color

One of:

  • a single color for every splat – anything Color accepts, such as 'white', '#ff000080' or (1, 0, 0);

  • a per-splat color, as (N, 3) RGB or (N, 4) RGBA in [0, 1].

opacities(N,) array or float, optional

Per-Gaussian peak opacity in [0, 1]. Required unless colors is given as (N, 4) RGBA, which supplies it as the alpha channel. A single color also carries an alpha (opaque unless the color says otherwise), which opacities overrides. Named in the plural because the scene graph’s Node.opacity is a separate, whole-visual alpha.

antialiasbool

Compensate opacity for the screen-space low-pass dilation, as expected by scenes trained with anti-aliasing (e.g. Mip-Splatting or gsplat’s "antialiased" mode). Leave off (the default) for scenes trained like the original 3DGS, which would otherwise render too faint. See the antialias property.

Notes

Per-splat records are stored once in a data texture and fetched in the vertex shader by texture slot. The splats are depth-sorted on the CPU, but only the (N, 2) draw order is re-uploaded, and only when the view direction rotates (pan, zoom and static redraws reuse the existing order) – so the heavy per-splat data never moves after upload, which keeps interaction smooth for up to a few million splats.

Color is a fixed per-Gaussian RGBA value; view-dependent color is often included in splat data, but yet not supported here.

property antialias#

Whether opacity is compensated for the low-pass dilation.

Every splat’s screen-space covariance is dilated by a small fixed amount so that sub-pixel splats don’t alias. Scenes trained with anti-aliasing expect that dilation to leave each splat’s total weight unchanged, i.e. its peak opacity scaled down by sqrt(det(cov2d) / det(cov2d + dilation)); scenes trained like the original 3DGS expect the opacity as stored. The training mode is not part of the standard ply layout, though some tools record it (Postshot writes a postshot.anti_aliasing=1 header comment).

property colors#

The (N, 4) array of per-Gaussian RGBA colors.

property covariances#

The (N, 3, 3) array of per-Gaussian 3D covariance matrices.

property opacities#

The (N,) array of per-Gaussian peak opacities.

Not opacity: the scene graph’s Node.opacity is a separate, whole-visual alpha and would shadow this name on scene.visuals.GaussianSplat.

property positions#

The (N, 3) array of Gaussian centers.

set_data(positions=None, covariances=None, colors=None, opacities=None)#

Update any subset of the per-Gaussian data arrays.

Parameters not supplied are left unchanged. See the class docstring for the expected shapes. Everything is validated before any of it is committed, so a call that raises leaves the visual as it was.