Skip to content

Rayrai Example: Gaussian Splat Scene ​

Overview ​

Shows a 3D Gaussian Splatting scene next to physics bodies, a red box and a blue sphere on the ground. By default the scene is the procedural cloud that rayrai's tests use: 200,000 splats on a checkered box and on a sphere with a color gradient, with view-dependent color. A camera arm orbits the scene with an RGB, a depth and a segmentation camera (320 x 240). The main view draws the scene, the bodies and the RGB camera's frustum; the Robot cameras panel shows what the three cameras measure. Splats and meshes hide each other where they overlap in depth. The splats also collide: every 3 s a yellow ball is dropped onto the splat box and lands on it.

For a captured scene with a robot standing in it, see the Gaussian splat apartment example.

Target ​

CMake target: rayrai_gaussian_splat_scene.

Run ​

From the repository root, build the target and run it:

bash
source ./raisim_env.sh
cmake --build build-examples --target rayrai_gaussian_splat_scene --parallel 2
./build-examples/examples/rayrai_gaussian_splat_scene

See Build examples to configure a new build directory.

On Windows, run rayrai_gaussian_splat_scene.exe instead. This example renders in process with rayrai and does not need rayrai_tcp_viewer.

To show a captured scene instead, set kSplatFile at the top of the source to an Inria 3DGS .ply, a compressed .ply, an .spz or a .splat file and build again. The example turns the file's y-down, z-forward frame to RaiSim's z-up frame with gaussianSplatYDownToZUp(); most captures also need a position and a scale of their own (see Placing a scene).

Controls ​

  • Orbit: the speed of the camera arm, -1 to 1 rad/s. Drag in the main view to move the viewer's camera.
  • Depth: the depth the splats report to depth cameras. Median gives the first surface, the depth where the splats in front of a pixel become opaque, like a real sensor. Expected gives the opacity-weighted mean, smooth but with mixed depths at silhouettes.

The panel's first line names the pipeline that draws the splats: the compute pipeline on OpenGL 4.3 and in the browser, or the transform-feedback pipeline on OpenGL 3.3 and 4.1 (macOS), where depth cameras always get the expected depth.

Save the window ​

The capture that the rayrai examples share (see rayrai/example_common.hpp) saves the viewer image as a PNG and exits; add RAYRAI_EXAMPLE_CAPTURE_WINDOW=1 to save the window with its panel:

bash
RAYRAI_EXAMPLE_CAPTURE=gaussian_splat.png ./build-examples/examples/rayrai_gaussian_splat_scene

Details ​

  • Makes the procedural cloud with raisin::makeProceduralGaussianSplatCloud(count, shDegree, seed), or reads a file with raisin::readGaussianSplatFile().
  • Adds it with RayraiWindow::addGaussianSplatScene(cloud, pose, options). The options give the scene the segmentation ids (100, 0, label of the class splat scene), which the segmentation camera reports where the splats win a pixel. The scene is detectable, so the robot's cameras see it.
  • Renders the cameras with the sensor overloads renderWithExternalCamera(), renderDepthPlaneDistance() and renderSegmentation() and reads depth and ids with Camera::getRawImage().
  • Chooses the depth with RayraiWindow::setGaussianSplatRenderSettings() (GaussianSplatRenderSettings::depthMode) and reports the pipeline with gaussianSplatBackend().
  • Turns the splats into collision with raisin::addGaussianSplatCollision(*world, cloud, pose, raisim::VOXELMAP): a static voxel map of 2 cm voxels, hidden from rendering, that the ball lands on (see Collision).

See Gaussian splat scenes for the file formats, placement, what each camera type sees and the limits.

RaiSim — physics for robotics and AI.