Gaussian splat scenes
3D Gaussian Splatting (3DGS) reconstructs a real place from photographs as millions of small, semi-transparent, coloured Gaussian blobs, the splats. A splat scene reproduces the look of the place, its baked lighting included, from any viewpoint. rayrai draws such scenes together with the meshes of a RaiSim world, in the viewer and in sensor images, so a simulated robot can look at a captured room, street or lab.
Physics does not see a splat scene by itself. addGaussianSplatCollision() turns its splats into a voxel map or a triangle mesh that bodies stand on and bump into and LiDARs hit (see Collision); otherwise give the world collision geometry of your own, such as a ground plane at the scene's floor, boxes for tables and walls, or a mesh reconstructed from the same capture. LiDARs cast against collision geometry, so they see that geometry and not the splats.
The Gaussian splat scene example shows robot cameras seeing a procedural splat scene, or a file of your own, and the Gaussian splat apartment example a robot standing in a captured patio that it collides with.
Loading a scene
raisin::readGaussianSplatFile() (rayrai/GaussianSplatCloud.hpp) reads a file into a raisin::GaussianSplatCloud:
raisin::GaussianSplatCloud cloud;
std::string error;
raisin::GaussianSplatReadOptions read;
read.maxShDegree = 3; // drop higher view-dependent bands, 0 to 3
if (!raisin::readGaussianSplatFile("garden.ply", cloud, &error, read))
throw std::runtime_error("cannot read garden.ply: " + error);| Format | Extension | Notes |
|---|---|---|
| Inria 3D Gaussian Splatting PLY | .ply | The format of the original 3DGS code and most training tools: binary little-endian or ASCII, view-dependent colour of degree 0 to 3. A Mip-Splatting filter_3D property is folded into the scales and opacities, and the comment SplatRenderMode: mip marks an antialiased scene. ASCII numbers are read in the C locale (a . decimal point) whatever the process locale. |
| PlayCanvas / SuperSplat compressed PLY | .ply | Chunked and quantized; recognized by its header. |
| Niantic SPZ, versions 2 and 3 | .spz | gzip-compressed. Version 4 needs zstd, which rayrai does not include, and is rejected with an error. |
antimatter15 .splat | .splat | 32-byte records without view-dependent colour. |
The format is chosen from the file's contents (GaussianSplatFileFormat::AUTO). A .splat file has no header, so its extension decides unless the file has a complete header of another format: it is read as PLY only if it starts with a PLY header that the PLY readers accept (the properties of a splat PLY or a compressed PLY, and element counts the file can hold), and as SPZ only if it is a gzip stream that decompresses to the SPZ signature or starts with an SPZ version 4 header whose stream table lies inside the file, since the first bytes of a raw .splat record can look like any of these. A file chosen as PLY this way whose records the PLY reader then rejects fails with that error. Set read.format to force a format. Invalid splats, such as non-finite values or zero rotations, fail the read with a message instead of being dropped; in an ASCII PLY, a value of an integer property must be an integer that fits its type. SPZ data that continues after the splats without the extension flag is rejected, and so is a file that continues after its gzip stream, such as one with a second gzip member. A file whose header claims more splats than it can hold fails before its splats are read: an SPZ file claiming more than writeGaussianSplatPly() writes a cloud as an Inria PLY, which every splat tool reads.
A cloud holds, per splat, its centre, its rotation (unit quaternion, w x y z), the standard deviations of the Gaussian along its rotated axes (linear, not log), its opacity (0 to 1, after the sigmoid) and its colour: a constant term (colour .splat files are kept in the frame they are stored in, which for scenes trained from COLMAP has x right, y down and z forward. SPZ files store x right, y up, z back and are mirrored into the PLY frame on load, so a scene reads the same from its .ply and .spz versions.
makeProceduralGaussianSplatCloud(count, shDegree, seed) builds a test scene of a box and a sphere covered with flat splats, which needs no captured file.
Placing a scene
RayraiWindow::addGaussianSplatScene() adds a cloud and returns its id. A GaussianSplatPose places the file frame in the world:
with the position w x y z) and a uniform scale KHR_gaussian_splatting allows none either. gaussianSplatYDownToZUp() is the rotation that turns a y-down capture into RaiSim's z-up frame,
raisin::GaussianSplatPose pose;
pose.rotation = raisin::gaussianSplatYDownToZUp();
pose.position = {0.f, 0.f, 1.1f};
pose.scale = 0.8f;
raisin::GaussianSplatSceneOptions options;
options.segmentationIds = {1000, 0, world->addSegmentationClass("captured scene")};
const raisin::GaussianSplatSceneId id = viewer.addGaussianSplatScene(std::move(cloud), pose, options);
viewer.setGaussianSplatScenePose(id, pose); // move it later
viewer.removeGaussianSplatScene(id); // or clearGaussianSplatScenes()Scene ids are never reused during a viewer's lifetime, also after clearGaussianSplatScenes(), so an id held elsewhere (for example by a loaded .rscene) never names a later scene.
| Option | Default | Meaning |
|---|---|---|
detectable | true | Sensor renders draw the scene: RaiSim cameras, external cameras, renderDepthPlaneDistance(), renderSegmentation() and SensorBatchRenderer. The viewer always draws it. |
segmentationIds | {-2, -2, 0} | Object, body and label ids written where the scene wins a pixel. The default marks it as a visual that is not a RaiSim object (SegmentationCamera::kNotWorldObject). |
maxShDegree | 3 | View-dependent bands above this degree are dropped on upload. |
shQuality | STANDARD | Storage of the view-dependent terms: STANDARD (8 bits each, about 48 bytes per splat at degree 3) or HIGH (16-bit floats, about 92 bytes). |
sensorMaterial | defaults of raisim::SensorMaterialProperties | How active stereo depth cameras see the splats; invalid values are a fatal error. |
The view-dependent colour is evaluated with the view direction in the file frame, so it follows the scene's rotation.
Collision
raisin::addGaussianSplatCollision() (rayrai/GaussianSplatCollision.hpp) turns a scene's splats into solid voxels and adds them to a world as a static body: robots stand on a captured floor and bump into its walls and furniture, dropped objects land on its tables, and LiDARs hit it. Its shape argument chooses the body: raisim::VOXELMAP adds the voxels as a voxel map, and raisim::MESH adds their boundary as a triangle mesh (see Collision mesh); any other type is a fatal error. It returns the body as a raisim::SingleBodyObject*, whose getObjectType() is the shape.
raisin::GaussianSplatCollisionOptions collision;
collision.regionMin = {-5.f, -5.f, -0.5f}; // the room, not the street outside its windows
collision.regionMax = {5.f, 5.f, 3.f};
auto* voxels = raisin::addGaussianSplatCollision(*world, cloud, pose, raisim::VOXELMAP, collision);
viewer.addGaussianSplatScene(std::move(cloud), pose);A voxel is solid where the splats that reach it are together at least opacityThreshold opaque, their opacities combined as along a camera ray,
| Option | Default | Meaning |
|---|---|---|
voxelSize | 0.02 m | Side of the voxels. The voxels of a flat splat have their centres within half a voxel of it, so those of a level captured floor reach at most one voxel above it and a body can rest up to this much above the floor; a thick splat fills the voxels its Gaussian makes opaque enough, a few standard deviations from its centre. |
opacityThreshold | 0.2 | Combined opacity that makes a voxel solid. It is below the 0.5 at which a depth camera sees a surface because a camera ray adds up the splats of several voxels and a voxel only its own; higher values leave more holes in captured floors. |
maxSplatSize | 0.3 m | Splats with a standard deviation above this (at the scene's scale) are left out: the sky, the distant background and the large faint blobs a capture fills empty space with. |
regionMin, regionMax | unbounded | World-frame box the voxels' centres must lie in. |
meshTolerance | 0.01 m | For the collision mesh only: about how far merging triangles may move its surface (the simplifier's error measure); 0 turns merging off. |
The voxels are aligned with the world's axes, key setPosition(), setOrientation()), or build it again. makeGaussianSplatCollision() returns the voxels as a raisim::VoxelMapResource that several worlds share, such as the worlds of a SensorBatchRenderer:
const raisim::VoxelMapResource voxels = raisin::makeGaussianSplatCollision(cloud, pose);
for (auto& world : worlds) world->addVoxelMap(voxels)->setAppearance("hidden");The body addGaussianSplatCollision() adds has the appearance "hidden": the viewer, sensor images and the TCP viewer draw the splats and not the voxels, and rayrai builds no mesh for them. Give it a colour with setAppearance() to see them. In Python, raisimpy.rayrai.addGaussianSplatCollision(world, cloud, pose, shape, options) takes the same arguments, with the shape raisimpy.ObjectType.VOXELMAP or raisimpy.ObjectType.MESH, and returns a raisimpy.VoxelMap or a raisimpy.Mesh; makeGaussianSplatCollision(cloud, pose, options) and makeGaussianSplatCollisionMesh() below take the same arguments as in C++.
On a captured apartment of 661k splats, making the 2 cm voxels (9.2M solid ones) takes about 0.8 s on up to eight threads, and they match what depth cameras see from 24 viewpoints inside it: 94% of the surface points the cameras see have a solid voxel within one voxel (97% within two), and 97% of the voxels they see lie within one voxel of such a point. What stays open is where the capture's own splats leave gaps: single voxels in about 3% of its floor, and more on surfaces the capture saw poorly, such as a floor seen only through a window, and in foliage. Floaters, the stray splats a capture leaves in the air, become solid where they are opaque enough; keep them out with the region, or clear them with VoxelMap::fillBox(). Voxels more than gaussian_splat record of a .rscene file adds no collision; see .rscene files for building it from the record.
Collision mesh
With the shape raisim::MESH, raisin::addGaussianSplatCollision() adds the same collision as a static triangle mesh (raisim::Mesh) instead of voxels, from the same options:
raisin::GaussianSplatCollisionOptions collision;
collision.regionMin = {-5.f, -5.f, -0.5f};
collision.regionMax = {5.f, 5.f, 3.f};
auto* surface = static_cast<raisim::Mesh*>(
raisin::addGaussianSplatCollision(*world, cloud, pose, raisim::MESH, collision));The mesh is the boundary of the solid voxels with their corners cut: a slope becomes a fine terraced surface rather than a staircase of cubes, which wheels and feet roll and slide over more smoothly. Its surface runs on the faces between solid and empty voxels, or up to half a voxel further out where the empty voxel is nearly opaque enough, so a captured floor's surface lies up to one voxel above its splats, as the voxels' does. A thin surface becomes a thin closed shell, and a feature one voxel wide, such as a thin chair leg, becomes about half as wide. Flat parts are merged into larger triangles until the simplifier's error measure, roughly how far the surface moves, reaches meshTolerance. Voxels that touch only along an edge share it, so the mesh is not always a manifold surface.
addGaussianSplatCollision() adds the mesh as a static mesh with the appearance "hidden"; makeGaussianSplatCollisionMesh() returns its triangles as a raisim::MeshResource to share between worlds. rayrai draws the triangles once the mesh has a colour; the TCP viewer does not draw them, and world XML export leaves the mesh out with a warning, since it stores meshes by their file.
The mesh takes longer to build than the voxels. On the captured apartment at 2 cm, the voxels of the whole scan take 0.7 s and 0.4 GB; the mesh of an 8 m by 8 m region becomes 0.93M triangles in 2.1 s and 0.5 GB, and the mesh of the whole scan 3.7M triangles in 9.2 s and 1 GB. With ANYmal, a box and a ball on it, a step takes 11 to 12 µs with the voxels or either mesh. Keep the mesh to the region a robot uses.
What cameras see
Splats are sorted by their distance from each camera, blended front to back, hidden behind meshes, point clouds and coordinate frames in front of them, and seen through translucent meshes and visuals, water and weather in front of them. Where they are at least half opaque, their median depth enters the scene's depth buffer whenever translucent geometry, water, weather or explosion effects are drawn after them or post-processing runs: translucent geometry behind them stays hidden, and depth of field, fog and ambient occlusion treat the scene as a surface (this costs a second splat pass, like a depth image). They are composited after tone mapping. Their colours are those of the capture, lighting included: rayrai's lights, exposure, tone mapping and colour grading do not change them, and they cast no shadows. They receive the sun's shadow from the meshes (a robot standing on a captured floor, say): where the sun's shadow map is occluded, a splat's colour is scaled down by shadowStrength (default 0.75) times the sun's own shadow strength (Light::setShadowParams(), 0.85 by default), standing for the sun's share of the captured light. The viewer and RASTER sensor colour images look the shadow up per pixel on each splat's plane; TILES images look it up once per splat, at its centre, so a large splat is shadowed as a whole. Only a directional sun with shadows enabled shadows splats; shadowStrength = 0 turns it off. Every splat is blurred by a small image-space filter (a variance of 0.3 square pixels), as in the original 3DGS renderer, so that splats smaller than a pixel do not flicker, and scenes trained with antialiasing (Mip-Splatting) get the matching opacity compensation.
Depth and segmentation cameras see a splat scene as a surface:
- Depth. With the default
GaussianSplatDepthMode::MEDIAN, a pixel reports the depth at which the opacity accumulated front to back first reaches 0.5: a sharp first surface and one return per pixel, as a real depth sensor gives.EXPECTEDreports the opacity-weighted mean depth of the splats, completed by the mesh behind them: smooth, with mixed depths at silhouettes. A pixel whose accumulated opacity stays below 0.5 and has no mesh behind has no return. A mesh in front of the splats keeps its own depth. - Segmentation. A pixel reports the scene's
segmentationIdswhere its splats win, that is where their accumulated opacity reaches 0.5 in front of every mesh, and the mesh's ids elsewhere.
RayraiWindow::setGaussianSplatRenderSettings() sets the depth mode, the highest spherical-harmonics degree evaluated per view (maxShDegree, lower is cheaper), the received shadow (shadowStrength) and how sensor colour images draw splats (sensorColorMethod): RASTER, blended quads as in the viewer, or TILES, the tile rasterizer that also produces depth and segmentation, with exact per-pixel ordering. Cameras with distorted lenses render the splats into their pinhole source image and remap them with the meshes, so splats and meshes stay aligned. The splats do not move during a rolling-shutter readout; each band sees them from the camera's pose at its time.
Active stereo depth cameras see a splat scene in both imagers, with the near-infrared material of the scene (GaussianSplatSceneOptions::sensorMaterial, by default that of an unregistered physics material: a diffuse reflectance of 0.5) and the rules of sensor materials. The incidence angle of a splat is taken at the normal of its ellipsoid where the camera ray through its centre enters it, which for a flat splat is its thin axis. The return strength follows the depth: that of the splat where the opacity reaches 0.5 with MEDIAN, the opacity-weighted mean with EXPECTED. A transmissive scene (transmission of 0.5 or more) is seen through outside the glint angle, and a mirror-like one gives no return there.
LiDARs cast against collision geometry and do not see the splats; they see a scene's collision voxels. Normal and optical-flow images and the loose and 3D bounding boxes leave them out too.
SensorBatchRenderer::addGaussianSplatScene() adds one scene that the cameras of every World see, placed in each World's frame. The cameras drawn into one render target (one kind, resolution and lens type) are drawn together: their splats are culled, sorted and rasterized for all of them at once, about four million splat views at a time, and every camera gets the image it would get alone. Randomized appearance does not change splat colours.
Backends
RayraiWindow::gaussianSplatBackend() reports the pipeline of the current OpenGL context:
| Backend | Contexts | Sorting | Depth | Segmentation |
|---|---|---|---|---|
COMPUTE | OpenGL 4.3 (Linux, Windows); the browser's WebGPU backend | On the GPU, the cameras of a batch together | MEDIAN or EXPECTED | The winning scene per pixel |
TRANSFORM_FEEDBACK | OpenGL 3.3 and 4.1 without compute shaders (macOS) | On the CPU, one thread, per view, exact | EXPECTED only | Per pixel, the nearest scene whose own accumulated opacity reaches 0.5 |
On macOS the colour images look the same, but depth cameras get the expected depth whatever the depth mode (and active stereo cameras the opacity-weighted return strength), and a pixel where two scenes overlap, each too thin to reach 0.5 on its own, reports neither. The CPU sort orders the splats exactly by their view depth, as the GPU sort does: a stable radix sort of the depth values, so splats are ordered however close their depths and however far the farthest splat lies, and splats at equal depths keep their order. Its cost is linear in the number of visible splats, which makes many cameras or large scenes slower there; SensorBatchRenderer sorts once per camera and is slow with large batches on these contexts.
Limits
- A scene holds at least one splat. All scenes of one renderer together hold at most 16,776,960 splats, and the GPU limits them further: its largest storage buffer (
COMPUTE) or buffer texture (TRANSFORM_FEEDBACK).addGaussianSplatScene()reports a scene beyond these limits, an empty scene, an invalid pose or an invalid sensor material as a fatal error with a message naming the limit; a .rscene record reports them as an error of the scene. - Sensor images larger than one GPU storage block can hold (16 bytes per pixel; 8.4 million pixels in the 128 MiB that OpenGL guarantees, which software renderers such as llvmpipe provide) are rasterized by the tile rasterizer in bands of rows, each within the limit. In the browser, the bands share one buffer, which WebGPU's default 256 MiB buffer limit bounds at about 16.7 million pixels of depth, segmentation or tiled colour image.
- One renderer (a
RayraiWindowor aSensorBatchRenderer) holds at most 65,535 scenes. - A scene is placed with a uniform scale; it cannot be deformed or animated apart from moving it as a whole.
- Splats have no physics apart from their collision voxels and cast no shadows; they receive the sun's shadow only, not that of other lights (see above), and not in browser builds (the WebGPU backend cannot read the sun's shadow maps there). The shadow is looked up on each splat's tangent plane at the pixel, a first-order fit: a large splat seen at a grazing angle is shadowed at a point slightly off its surface.
- With linear HDR output (
RayraiWindow::setLinearHdrRenderingEnabled(), reprojected temporal antialiasing, material screen-space reflections or HDR exposure metering), splats are composited after post-processing so that it does not tone-map them, and they then also cover translucent geometry in front of them and are not in the depth that post-processing reads. - Splats are not multisampled: with MSAA, the edges of meshes in front of a splat scene are resolved per pixel against it. Without compute shaders the depth that hides translucent geometry is the splats' expected depth, so a translucent object between two splat layers can be hidden.
- Ray-traced glass (
RenderQualitySettings::geometryRefraction) traces triangles only: seen through it, a background made of splats shows the environment instead. - Single-precision arithmetic limits extremely thin splats: one that projects to a sliver thousands of times longer than it is wide is drawn with its width rounded, and its faintest pixels can come and go with the image size or the rolling-shutter bands.
- The view-dependent colour is a fit to the captured views: far outside them (behind walls, under the floor) a scene shows the gaps and floaters of its reconstruction.
.rscene files
A gaussian_splat record places a scene in a world's .rscene file: a RayraiWindow on that world draws it with the rest of the scene, and RaisimServer shares the file with a remote TCP viewer like the scene's meshes. The record is new in v2.20.0, which is not released yet; its keys are listed under gaussian_splat record. rsc/gaussian_splats/apartment/apartment.rscene places the captured patio of the apartment example:
raisim_engine_scene 2
time_step 0.005
gravity 0 0 -9.81
solver 150 1e-08 1.5 accurate erp2=0.002 defaultRestitutionThreshold=0.01 defaultStaticFrictionVelocityThreshold=1 fixedContactSolverIterationOrder=true
rayrai_render automaticIrradiance=false
gaussian_splat /World/Patio file=apartment.compressed.ply position=4.33,4.85,0.12 quaternion=0.7071068,-0.7071068,0,0 segmentation=100,0,1The splat file is found next to the scene file (see Paths and assets), the quaternion turns the y-down capture z-up, and the time_step and solver records keep the values of a default raisim::World; without them the world gets .rscene solver defaults. Splats take no part in rayrai's automatic bake of bounce light between meshes, so rayrai_render automaticIrradiance=false turns it off. Loading the file is all a viewer needs (made, like any RayraiWindow, while an OpenGL context is current):
auto world = std::make_shared<raisim::World>("rsc/gaussian_splats/apartment/apartment.rscene");
raisin::RayraiWindow viewer(world, 1280, 720); // draws the patioThe record adds no collision. Build it from the scene's records, world->getRscene()->gaussianSplats (the enabled ones, in file order), with voxels or a mesh, as the apartment example does:
const raisim::rscene::Scene& scene = *world->getRscene();
for (const raisim::rscene::GaussianSplat& record : scene.gaussianSplats) {
raisin::GaussianSplatCloud cloud;
raisin::GaussianSplatReadOptions read;
read.maxShDegree = 0; // collision needs no view-dependent colour
std::string error;
if (!raisin::readGaussianSplatFile(raisim::pathUtf8(scene.resolve(record.file)), cloud, &error, read))
throw std::runtime_error(error);
raisin::GaussianSplatPose pose;
pose.position = {float(record.position.x), float(record.position.y), float(record.position.z)};
pose.rotation = glm::quat(float(record.rotation.w), float(record.rotation.x),
float(record.rotation.y), float(record.rotation.z));
pose.scale = float(record.scale);
raisin::addGaussianSplatCollision(*world, cloud, pose, raisim::VOXELMAP); // or raisim::MESH
}raisim/Rscene.hpp declares the records and raisim/PathUtils.hppraisim::pathUtf8(). raisimpy does not expose a world's scene records: in Python, read the record's file with raisimpy.rayrai.readGaussianSplatFile() and pass the cloud, with a GaussianSplatPose holding the record's position, quaternion and scale, to the collision functions.
A record whose file or pose the renderer cannot use is an error of the scene that names the record and the file: a missing or unreadable file, a file without splats, more splats than the limits allow, or a position or scale beyond the range of a 32-bit float. The scene loading throws it as std::runtime_error after removing what it added, like any other scene content rayrai cannot show: the RayraiWindow constructor reports it as a RaiSim fatal error naming the scene, and the TCP viewer shows the message and keeps running without the server's scene files. Records take the default sensorMaterial.
Licences
RaiSim ships one captured splat scene, the apartment patio of the Gaussian splat apartment example (rsc/gaussian_splats/apartment, CC BY 4.0, see Asset credits); the other examples and the documentation images use the procedural scene. A captured scene keeps the licence of its capture, and many public 3DGS scenes are licensed CC BY or CC BY-NC: images that show a CC BY scene must credit its author, and NC scenes may not be used commercially.
Benchmarks
rayrai_gaussian_splat_io_benchmark measures loading each format and the preparation on load, and rayrai_gaussian_splat_benchmark measures drawing viewer, sensor and batched views on both backends (--backends=compute,feedback), with procedural clouds or a captured scene (--ply=scene.ply); --shadow gives the colour views a sun shadow map. Receiving the shadow per pixel adds about 0.4 ms to a 1280x720 view of 1M splats on an RTX 2070 SUPER (raster 1.47 ms to 1.87 ms). See the rayrai benchmark.md for the commands.
On the same GPU, from the same cameras (the procedural box and sphere orbited by every view, spherical harmonics of degree 0), batches of small sensor views take:
| Views | Splats | rayrai depth | rayrai colour | gsplat 1.5.3, colour and expected depth |
|---|---|---|---|---|
| 64 of 128x128 | 100k | 14.2 ms | 15.5 ms | 25.0 ms |
| 256 of 64x64 | 100k | 62.2 ms | 70.3 ms | 104.7 ms |
| 256 of 64x64 | 1M | 888 ms | 720 ms | out of memory (8 GB) |
gsplat renders colour and expected depth in one pass; rayrai renders each image in a pass of its own (depth: the median depth, the default depthMode).