SIGGRAPH 2023 had a paper "3D Gaussian Splatting for Real-Time Radiance Field Rendering" by Kerbl, Kopanas, Leimkühler, Drettakis that looks pretty cool! Check out their website, source code repository, data sets and so on.
I've decided to try to implement the realtime visualization part (i.e. the one that takes already-produced gaussian splat "model" file) in Unity.
The original paper code has a purely CUDA-based realtime renderer; other people have done their own implementations (e.g. WebGPU at cvlab-epfl, Taichi at wanmeihuali, etc.).
Code in here so far is randomly cribbled together from reading the paper (as well as earlier literature on EWA splatting), looking at the official CUDA implementation, and so on. Current state:
First download or clone this repository and open as a Unity (2022.3) project. Note that the project defaults to DX12 on Windows, since then it can use a faster sorting routine (DX11 should also work, but sorting will be slower).
Next up, create some GaussianSplat assets: open Tools -> Gaussian Splats -> Create GaussianSplatAsset
menu within Unity. In the dialog point it to
your gaussian splat "model" directory (it is expected to contain cameras.json
and point_cloud/iteration_7000/point_cloud.ply
inside of it,
and be an actual Gaussian Splat model, not something else).
Pick desired compression options and output folder, and press "Create Asset" button.
If everything was fine, there should be a GaussianSplat asset that has a bunch of data images next to it:
Since the gaussian splat models are quite large, I have not included any in this Github repo. The original paper github page has a a link to 14GB zip of their models.
In the game object that has a GaussianSplatRenderer
script, point the Asset field to one of your created assets.
There are various controls on the script to debug/visualize the data, as well as a slider to move game camera into one of asset's camera
locations.
The rendering takes game object transformation matrix into account; the official gaussian splat models seem to be all rotated by about -160 degrees around X axis, and mirrored around Z axis, so in the sample scene the object has such a transform set up, and the camera is setup as a child object.
That's it!
Wishlist that I may or might not do at some point:
My own blog posts about all this (so far... not that many!):
"bicycle" scene from the paper, with 6.1M splats and first camera in there, rendering at 1200x797 resolution, at "Medium" asset quality level (273MB asset file):
Besides the gaussian splat asset that is loaded into GPU memory, currently this also needs about 48 bytes of GPU memory per splat (for sorting, caching view dependent data etc.).