Appearance
Splat
The GPU buffers behind a Gaussian splat, for handing to a compute kernel.
Reached via entity.representation.splat on a splat representation; null for any other kind. Each attribute vends .read and .write tokens that go into a kernel's inputBuffers / outputBuffers maps, exactly as texture.read / texture.write do.
Important: pass
threadsPerThreadgroupwhenever the group count was divided by a number of your own. Left out, it defaults to the GPU's thread execution width (32 on Apple silicon), so dividing by 64 covers half the capture and leaves the rest of a.writebuffer undefined.Warning: a
.writetoken hands the kernel an uninitialised buffer, not last frame's contents. Whatever the kernel does not write is undefined. To change part of an attribute, bind.readas an input in the same dispatch and copy the rest across.
Example:
javascript
const splat = entity.representation.splat;
const THREADS = 64;
kernel.run({
uniforms: new Float32Array([scene.time, splat.count]),
inputBuffers: { src: splat.position.read },
outputBuffers: { dst: splat.position.write },
threadGroups: [Math.ceil(splat.count / THREADS), 1, 1],
threadsPerThreadgroup: [THREADS, 1, 1]
});Properties
boundingBox
- Type: BoundingBox
- The box around the capture, in the same space as the values in
position.
count
- Type: number
- How many splats the capture holds. Size a dispatch from this, and guard on it in the kernel: a thread that runs past the end writes into memory the renderer is using.
opacity
- Type: SplatAttribute
- Opacity of each splat, 1 float per splat, stored pre-sigmoid so 0 is half opaque rather than invisible. Fade the alpha and convert back rather than interpolating the stored value.
position
- Type: SplatAttribute
- Centre of each splat, 3 floats per splat, read in a kernel as
packed_float3.
rotation
- Type: SplatAttribute
- Orientation of each splat as a quaternion, 4 floats per splat, stored w first as
(w, x, y, z). Identity is(1, 0, 0, 0); anxyzwidentity is a half turn.
scale
- Type: SplatAttribute
- Per-axis size of each splat, 3 floats per splat, in log space and read in a kernel as
packed_float3. Halving a splat means subtractinglog(2), not multiplying by 0.5.
sphericalHarmonicDegree
- Type: number
- Spherical harmonic degree of the capture, 0 through 3.
sphericalHarmonics
- Type: SplatAttribute
- View-dependent colour: the DC triplet first, then one triplet per higher-order coefficient, so
itemSizeis3 * (bands + 1)and a splat's base colour is the first three floats of its block. Read in a kernel asfloat, indexed by that stride.