@luma.gl/engine 10.0.0-beta.2 → 10.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/arrow/index.cjs.map +1 -1
- package/dist/arrow/renderers/path/transforms/gpu-path-float64-deltas.cjs +1 -0
- package/dist/arrow/renderers/path/transforms/gpu-path-float64-deltas.d.ts.map +1 -1
- package/dist/arrow/renderers/path/transforms/gpu-path-float64-deltas.js +1 -0
- package/dist/arrow/renderers/path/transforms/gpu-path-float64-deltas.js.map +1 -1
- package/dist/dist.dev.js +54 -1
- package/dist/dist.min.js +64 -50
- package/dist/gltf/gltf/create-composed-scenegraphs-from-gltf.cjs +80 -0
- package/dist/gltf/gltf/create-composed-scenegraphs-from-gltf.d.ts +28 -0
- package/dist/gltf/gltf/create-composed-scenegraphs-from-gltf.d.ts.map +1 -0
- package/dist/gltf/gltf/create-composed-scenegraphs-from-gltf.js +74 -0
- package/dist/gltf/gltf/create-composed-scenegraphs-from-gltf.js.map +1 -0
- package/dist/gltf/gltf/create-scenegraph-from-gltf.cjs +13 -4
- package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts.map +1 -1
- package/dist/gltf/gltf/create-scenegraph-from-gltf.js +11 -0
- package/dist/gltf/gltf/create-scenegraph-from-gltf.js.map +1 -1
- package/dist/gltf/gltf/gltf-skin.cjs +1 -1
- package/dist/gltf/gltf/gltf-skin.js +2 -2
- package/dist/gltf/gltf/gltf-skin.js.map +1 -1
- package/dist/gltf/index.cjs +3 -0
- package/dist/gltf/index.cjs.map +3 -3
- package/dist/gltf/index.d.ts +1 -0
- package/dist/gltf/index.d.ts.map +1 -1
- package/dist/gltf/index.js +1 -0
- package/dist/gltf/index.js.map +1 -1
- package/dist/gltf/parsers/parse-gltf-physics-pointer.cjs +1 -1
- package/dist/gltf/parsers/parse-gltf-physics-pointer.js +1 -1
- package/dist/gltf/parsers/parse-gltf-physics-pointer.js.map +1 -1
- package/dist/gltf/parsers/parse-gltf.cjs +2 -1
- package/dist/gltf/parsers/parse-gltf.d.ts +2 -0
- package/dist/gltf/parsers/parse-gltf.d.ts.map +1 -1
- package/dist/gltf/parsers/parse-gltf.js +3 -1
- package/dist/gltf/parsers/parse-gltf.js.map +1 -1
- package/dist/gltf/physics/export-state.cjs +115 -14
- package/dist/gltf/physics/export-state.d.ts +9 -2
- package/dist/gltf/physics/export-state.d.ts.map +1 -1
- package/dist/gltf/physics/export-state.js +171 -18
- package/dist/gltf/physics/export-state.js.map +1 -1
- package/dist/gltf/physics/index.cjs.map +1 -1
- package/dist/gltf/physics/index.d.ts +1 -1
- package/dist/gltf/physics/index.d.ts.map +1 -1
- package/dist/gltf/physics/index.js.map +1 -1
- package/dist/gltf/physics/parse-gltf-physics.cjs +11 -8
- package/dist/gltf/physics/parse-gltf-physics.d.ts.map +1 -1
- package/dist/gltf/physics/parse-gltf-physics.js +6 -2
- package/dist/gltf/physics/parse-gltf-physics.js.map +1 -1
- package/dist/gltf/physics/physics-types.d.ts +4 -0
- package/dist/gltf/physics/physics-types.d.ts.map +1 -1
- package/dist/gltf/physics/property-bindings.cjs +5 -2
- package/dist/gltf/physics/property-bindings.d.ts.map +1 -1
- package/dist/gltf/physics/property-bindings.js +11 -2
- package/dist/gltf/physics/property-bindings.js.map +1 -1
- package/dist/gltf/types/gltf-postprocessed-schema.d.ts +4 -0
- package/dist/gltf/types/gltf-postprocessed-schema.d.ts.map +1 -1
- package/dist/gltf/types/gltf-types.d.ts +2 -0
- package/dist/gltf/types/gltf-types.d.ts.map +1 -1
- package/dist/graph/physics/index.cjs +3 -0
- package/dist/graph/physics/index.cjs.map +3 -3
- package/dist/graph/physics/index.d.ts +1 -0
- package/dist/graph/physics/index.d.ts.map +1 -1
- package/dist/graph/physics/index.js +1 -0
- package/dist/graph/physics/index.js.map +1 -1
- package/dist/graph/physics/scenegraph-ragdoll.cjs +132 -0
- package/dist/graph/physics/scenegraph-ragdoll.d.ts +32 -0
- package/dist/graph/physics/scenegraph-ragdoll.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-ragdoll.js +117 -0
- package/dist/graph/physics/scenegraph-ragdoll.js.map +1 -0
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/scenegraph/controllers/skin-controller.cjs +20 -1
- package/dist/scenegraph/controllers/skin-controller.d.ts +4 -0
- package/dist/scenegraph/controllers/skin-controller.d.ts.map +1 -1
- package/dist/scenegraph/controllers/skin-controller.js +21 -1
- package/dist/scenegraph/controllers/skin-controller.js.map +1 -1
- package/dist/shader-plugins/depth-interval.cjs +60 -0
- package/dist/shader-plugins/depth-interval.d.ts +10 -0
- package/dist/shader-plugins/depth-interval.d.ts.map +1 -0
- package/dist/shader-plugins/depth-interval.js +42 -0
- package/dist/shader-plugins/depth-interval.js.map +1 -0
- package/dist/splats/index.cjs.map +2 -2
- package/dist/splats/index.d.ts +1 -1
- package/dist/splats/index.d.ts.map +1 -1
- package/dist/splats/index.js.map +1 -1
- package/dist/splats/splat-picking.d.ts +2 -2
- package/dist/splats/splat-picking.d.ts.map +1 -1
- package/dist/splats/splat-renderer.cjs +51 -2
- package/dist/splats/splat-renderer.d.ts +15 -1
- package/dist/splats/splat-renderer.d.ts.map +1 -1
- package/dist/splats/splat-renderer.js +61 -2
- package/dist/splats/splat-renderer.js.map +1 -1
- package/dist/splats/splat-shaders.cjs +46 -3
- package/dist/splats/splat-shaders.d.ts +5 -3
- package/dist/splats/splat-shaders.d.ts.map +1 -1
- package/dist/splats/splat-shaders.js +42 -3
- package/dist/splats/splat-shaders.js.map +1 -1
- package/package.json +6 -6
- package/src/arrow/renderers/path/transforms/gpu-path-float64-deltas.ts +1 -0
- package/src/gltf/gltf/create-composed-scenegraphs-from-gltf.ts +100 -0
- package/src/gltf/gltf/create-scenegraph-from-gltf.ts +12 -0
- package/src/gltf/gltf/gltf-skin.ts +2 -2
- package/src/gltf/index.ts +5 -0
- package/src/gltf/parsers/parse-gltf-physics-pointer.ts +1 -1
- package/src/gltf/parsers/parse-gltf.ts +6 -4
- package/src/gltf/physics/README.md +16 -0
- package/src/gltf/physics/export-state.ts +215 -18
- package/src/gltf/physics/index.ts +1 -1
- package/src/gltf/physics/parse-gltf-physics.ts +5 -2
- package/src/gltf/physics/physics-types.ts +4 -0
- package/src/gltf/physics/property-bindings.ts +10 -2
- package/src/gltf/types/gltf-postprocessed-schema.ts +4 -0
- package/src/gltf/types/gltf-types.ts +2 -0
- package/src/graph/physics/index.ts +1 -0
- package/src/graph/physics/scenegraph-ragdoll.ts +133 -0
- package/src/index.ts +2 -0
- package/src/scenegraph/controllers/skin-controller.ts +20 -1
- package/src/shader-plugins/depth-interval.ts +45 -0
- package/src/splats/README.md +10 -0
- package/src/splats/index.ts +1 -0
- package/src/splats/splat-renderer.ts +82 -2
- package/src/splats/splat-shaders.ts +48 -3
package/src/index.ts
CHANGED
|
@@ -373,3 +373,5 @@ export {deformPositions} from './animation/deform-positions';
|
|
|
373
373
|
export {createAreaLightLTCTextures} from './lighting/ltc-textures';
|
|
374
374
|
|
|
375
375
|
export {makeGPUVectorGeometry} from './geometry/gpu-vector-geometry-adapter';
|
|
376
|
+
|
|
377
|
+
export {makeDepthIntervalPlugin} from './shader-plugins/depth-interval';
|
|
@@ -33,6 +33,9 @@ export type SkinControllerProps = {
|
|
|
33
33
|
export class SkinController {
|
|
34
34
|
readonly bindings: readonly SkinBinding[];
|
|
35
35
|
|
|
36
|
+
/** Palettes owned by a GPU producer for the duration of their binding. */
|
|
37
|
+
private readonly gpuDriven = new Set<SkinBinding>();
|
|
38
|
+
|
|
36
39
|
private readonly scenes: readonly GroupNode[];
|
|
37
40
|
|
|
38
41
|
constructor(props: SkinControllerProps) {
|
|
@@ -43,7 +46,7 @@ export class SkinController {
|
|
|
43
46
|
|
|
44
47
|
/** Re-evaluates every source skin after its animated node transforms have changed. */
|
|
45
48
|
update(): void {
|
|
46
|
-
if (this.
|
|
49
|
+
if (this.gpuDriven.size === this.bindings.length) {
|
|
47
50
|
return;
|
|
48
51
|
}
|
|
49
52
|
|
|
@@ -57,6 +60,7 @@ export class SkinController {
|
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
for (const binding of this.bindings) {
|
|
63
|
+
if (this.gpuDriven.has(binding)) continue;
|
|
60
64
|
updateSkinJointMatrices({
|
|
61
65
|
joints: binding.joints,
|
|
62
66
|
meshNode: binding.node,
|
|
@@ -84,6 +88,21 @@ export class SkinController {
|
|
|
84
88
|
}
|
|
85
89
|
}
|
|
86
90
|
|
|
91
|
+
/** Borrow a WebGPU storage palette and suspend CPU writes until the lease is released. */
|
|
92
|
+
claimGPUPalette(binding: SkinBinding): () => void {
|
|
93
|
+
if (!this.bindings.includes(binding) || !(binding.skinJointMatrices instanceof Buffer))
|
|
94
|
+
throw new Error('GPU skinning requires an owned storage palette');
|
|
95
|
+
if (this.gpuDriven.has(binding)) throw new Error('Skin palette already has a GPU producer');
|
|
96
|
+
this.gpuDriven.add(binding);
|
|
97
|
+
/** Only this lease can remove its claim, even if its disposer is called twice. */
|
|
98
|
+
let released = false;
|
|
99
|
+
return () => {
|
|
100
|
+
if (released) return;
|
|
101
|
+
released = true;
|
|
102
|
+
this.gpuDriven.delete(binding);
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
87
106
|
/** Finds the palette driven by a scenegraph node. */
|
|
88
107
|
getBinding(node: GroupNode | undefined): SkinBinding | undefined {
|
|
89
108
|
return this.bindings.find(binding => binding.node === node);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {ShaderPlugin} from '@luma.gl/shaders';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* WebGPU depth-bound filtering for a caller-owned texture matching the render target.
|
|
9
|
+
* Bind `depthIntervalBound` and a `vec4<u32>` uniform named `depthIntervalCompare`.
|
|
10
|
+
* A nonzero first component selects greater; zero selects less-equal.
|
|
11
|
+
* Pass framebuffer pixel coordinates, stored depth, and the host coverage mask.
|
|
12
|
+
* For MSAA, write the result to the fragment's `sample_mask` output.
|
|
13
|
+
*/
|
|
14
|
+
export function makeDepthIntervalPlugin(sampleCount: number, bindGroup = 1): ShaderPlugin {
|
|
15
|
+
const multisampled = sampleCount > 1;
|
|
16
|
+
const textureType = multisampled ? 'texture_depth_multisampled_2d' : 'texture_depth_2d';
|
|
17
|
+
const sampleLimit = multisampled ? 'textureNumSamples(depthIntervalBound)' : '1u';
|
|
18
|
+
const loadIndex = multisampled ? 'sampleIndex' : '0';
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
name: 'depthInterval',
|
|
22
|
+
module: {
|
|
23
|
+
name: 'depthInterval',
|
|
24
|
+
bindingLayout: [
|
|
25
|
+
{name: 'depthIntervalBound', group: bindGroup, visibility: 2},
|
|
26
|
+
{name: 'depthIntervalCompare', group: bindGroup, visibility: 2}
|
|
27
|
+
],
|
|
28
|
+
source: /* wgsl */ `
|
|
29
|
+
@group(${bindGroup}) @binding(auto) var depthIntervalBound: ${textureType};
|
|
30
|
+
@group(${bindGroup}) @binding(auto) var<uniform> depthIntervalCompare: vec4<u32>;
|
|
31
|
+
|
|
32
|
+
fn filterDepthInterval(pixel: vec2<i32>, depth: f32, coverage: u32) -> u32 {
|
|
33
|
+
let keepGreater = depthIntervalCompare.x != 0u;
|
|
34
|
+
var mask = 0u;
|
|
35
|
+
for (var sampleIndex = 0u; sampleIndex < ${sampleLimit}; sampleIndex++) {
|
|
36
|
+
if ((depth > textureLoad(depthIntervalBound, pixel, ${loadIndex})) == keepGreater) {
|
|
37
|
+
mask |= 1u << sampleIndex;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return coverage & mask;
|
|
41
|
+
}
|
|
42
|
+
`
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
package/src/splats/README.md
CHANGED
|
@@ -18,6 +18,16 @@ and in-place row updates. Both rendering paths evaluate view-dependent radiance
|
|
|
18
18
|
classes. `SplatPicker` and `GPUSplatGraphPicker` resolve original source rows; their corresponding
|
|
19
19
|
mixed-scene helpers compose splats with caller-owned depth-tested meshes.
|
|
20
20
|
|
|
21
|
+
For WebGPU scenes with transparent meshes, construct `SplatRenderer` with
|
|
22
|
+
`depthIntervalSamples` equal to the render target's sample count. Before each
|
|
23
|
+
draw, call `setDepthInterval({bound, compare})`, where `bound` is a caller-owned
|
|
24
|
+
depth texture or view with the same sample count and dimensions. `greater` keeps
|
|
25
|
+
samples whose splat depth is strictly greater than the bound; `less-equal` keeps
|
|
26
|
+
the complement, including equality. Draw the two sides in the order needed for
|
|
27
|
+
the scene's `depthConvention` (`standard` or `reverse`). The renderer never owns
|
|
28
|
+
or clears the bound. Without `depthIntervalSamples`, it uses the existing shader
|
|
29
|
+
and bindings, with no depth-texture lookup.
|
|
30
|
+
|
|
21
31
|
`SplatHierarchyManager` traverses frustum-culled, foveated source hierarchies while preserving
|
|
22
32
|
coarse parent fallback and bounded asynchronous loading. `SplatRADHierarchyManager` follows
|
|
23
33
|
Spark's authored per-row global child links, retaining mixed source-page leaves and parent
|
package/src/splats/index.ts
CHANGED
|
@@ -8,12 +8,15 @@ import {
|
|
|
8
8
|
type CompareFunction,
|
|
9
9
|
type CommandEncoder,
|
|
10
10
|
type Device,
|
|
11
|
-
type RenderPass
|
|
11
|
+
type RenderPass,
|
|
12
|
+
type Texture,
|
|
13
|
+
type TextureView
|
|
12
14
|
} from '@luma.gl/core';
|
|
13
15
|
import {ShaderInputs} from '@luma.gl/engine';
|
|
14
16
|
import {GPUData} from '@luma.gl/graph/gpu-data';
|
|
15
17
|
import {GPURecordBatch, GPUTable, type GPUInputSchema} from '@luma.gl/graph/gpu-tables';
|
|
16
18
|
import {GPUTableModel} from '@luma.gl/engine/tables';
|
|
19
|
+
import {makeDepthIntervalPlugin} from '../shader-plugins/depth-interval';
|
|
17
20
|
import {GPUSplatData} from './splat-data';
|
|
18
21
|
import {projectSplatCovarianceToScreen} from './splat-covariance';
|
|
19
22
|
import {acceptsSplatSemantic, type SplatSemanticFilter} from './splat-filter';
|
|
@@ -34,6 +37,7 @@ import {
|
|
|
34
37
|
SPLAT_STORAGE_SHADER_LAYOUT,
|
|
35
38
|
SPLAT_STORAGE_WGSL_SHADER,
|
|
36
39
|
SPLAT_VS_GLSL,
|
|
40
|
+
getSplatDepthIntervalWGSLShader,
|
|
37
41
|
splatUniforms,
|
|
38
42
|
type SplatUniforms
|
|
39
43
|
} from './splat-shaders';
|
|
@@ -56,6 +60,10 @@ export type SplatRendererProps = {
|
|
|
56
60
|
sortMode?: SplatSortMode;
|
|
57
61
|
/** Projected-depth convention for alpha ordering, independent of depthCompare. Defaults to standard. */
|
|
58
62
|
depthConvention?: 'standard' | 'reverse';
|
|
63
|
+
/** WebGPU only. Fixed render-target sample count for opt-in depth-interval filtering. */
|
|
64
|
+
depthIntervalSamples?: number;
|
|
65
|
+
/** Bound depth and side for a depth-interval draw; the texture remains caller-owned. */
|
|
66
|
+
depthInterval?: SplatDepthInterval;
|
|
59
67
|
/** Minimum fragment opacity retained after Gaussian attenuation. */
|
|
60
68
|
alphaCutoff?: number;
|
|
61
69
|
/** Alias for {@link alphaCutoff} when integrating opacity-threshold controls. */
|
|
@@ -84,6 +92,12 @@ export type SplatRendererProps = {
|
|
|
84
92
|
depthWriteEnabled?: boolean;
|
|
85
93
|
};
|
|
86
94
|
|
|
95
|
+
/** The two comparisons partition every sample, including samples exactly on the bound. */
|
|
96
|
+
export type SplatDepthInterval = {
|
|
97
|
+
bound: Texture | TextureView;
|
|
98
|
+
compare: 'greater' | 'less-equal';
|
|
99
|
+
};
|
|
100
|
+
|
|
87
101
|
/** Application-owned opaque or transparent mesh compatible with an existing render pass. */
|
|
88
102
|
export type SplatMeshRenderable = {
|
|
89
103
|
draw(renderPass: RenderPass): boolean | void;
|
|
@@ -127,6 +141,7 @@ type ResolvedSplatRendererProps = {
|
|
|
127
141
|
semanticFilter?: SplatSemanticFilter;
|
|
128
142
|
sortMode: SplatSortMode;
|
|
129
143
|
depthConvention: 'standard' | 'reverse';
|
|
144
|
+
depthIntervalSamples?: number;
|
|
130
145
|
alphaCutoff: number;
|
|
131
146
|
screenSizeCutoffPixels: number;
|
|
132
147
|
gaussianSupportRadius: number;
|
|
@@ -233,6 +248,11 @@ export class SplatRenderer {
|
|
|
233
248
|
private usesFloatWebGLColors = false;
|
|
234
249
|
private hasExplicitToneMapping = false;
|
|
235
250
|
private isDestroyed = false;
|
|
251
|
+
private depthIntervalBindings?: {
|
|
252
|
+
depthIntervalBound: Texture | TextureView;
|
|
253
|
+
depthIntervalCompare: Buffer;
|
|
254
|
+
};
|
|
255
|
+
private depthIntervalCompareBuffers?: Record<SplatDepthInterval['compare'], Buffer>;
|
|
236
256
|
|
|
237
257
|
/** Creates a renderer over optionally supplied caller-owned Gaussian source batches. */
|
|
238
258
|
constructor(device: Device, props: SplatRendererProps = {}) {
|
|
@@ -245,6 +265,7 @@ export class SplatRenderer {
|
|
|
245
265
|
semanticFilter: props.semanticFilter,
|
|
246
266
|
sortMode: props.sortMode ?? 'global',
|
|
247
267
|
depthConvention: props.depthConvention ?? 'standard',
|
|
268
|
+
depthIntervalSamples: props.depthIntervalSamples,
|
|
248
269
|
alphaCutoff: props.alphaCutoff ?? props.opacityThreshold ?? 1 / 255,
|
|
249
270
|
screenSizeCutoffPixels: props.screenSizeCutoffPixels ?? 0,
|
|
250
271
|
gaussianSupportRadius: props.gaussianSupportRadius ?? 3,
|
|
@@ -258,6 +279,9 @@ export class SplatRenderer {
|
|
|
258
279
|
depthWriteEnabled: props.depthWriteEnabled ?? false
|
|
259
280
|
};
|
|
260
281
|
this.hasExplicitToneMapping = props.toneMapping !== undefined;
|
|
282
|
+
if (props.depthInterval) {
|
|
283
|
+
this.setDepthInterval(props.depthInterval);
|
|
284
|
+
}
|
|
261
285
|
this.updateShaderInputs();
|
|
262
286
|
for (const batch of normalizeSplatBatches(props.data)) {
|
|
263
287
|
this.appendData(batch);
|
|
@@ -265,6 +289,32 @@ export class SplatRenderer {
|
|
|
265
289
|
this.update();
|
|
266
290
|
}
|
|
267
291
|
|
|
292
|
+
/** Selects the caller-owned bound and side for subsequent depth-interval draws. */
|
|
293
|
+
setDepthInterval(interval: SplatDepthInterval): void {
|
|
294
|
+
// A depth interval requires the WebGPU shader variant selected at construction.
|
|
295
|
+
if (this.device.type !== 'webgpu' || this.props.depthIntervalSamples === undefined) {
|
|
296
|
+
throw new Error('Depth interval requires a WebGPU renderer with depthIntervalSamples');
|
|
297
|
+
}
|
|
298
|
+
if (!this.depthIntervalCompareBuffers) {
|
|
299
|
+
this.depthIntervalCompareBuffers = {
|
|
300
|
+
greater: this.device.createBuffer({
|
|
301
|
+
id: 'splat-depth-interval-greater',
|
|
302
|
+
data: new Uint32Array([1, 0, 0, 0]),
|
|
303
|
+
usage: Buffer.UNIFORM
|
|
304
|
+
}),
|
|
305
|
+
'less-equal': this.device.createBuffer({
|
|
306
|
+
id: 'splat-depth-interval-less-equal',
|
|
307
|
+
data: new Uint32Array(4),
|
|
308
|
+
usage: Buffer.UNIFORM
|
|
309
|
+
})
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
this.depthIntervalBindings = {
|
|
313
|
+
depthIntervalBound: interval.bound,
|
|
314
|
+
depthIntervalCompare: this.depthIntervalCompareBuffers[interval.compare]
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
|
|
268
318
|
/** Current source rows, visibility, batch identity, and GPU allocation diagnostics. */
|
|
269
319
|
get stats(): SplatRendererStats {
|
|
270
320
|
return this.getStats();
|
|
@@ -312,6 +362,15 @@ export class SplatRenderer {
|
|
|
312
362
|
|
|
313
363
|
/** Updates camera, sorting, visibility, and styling controls in place. */
|
|
314
364
|
setProps(props: Partial<SplatRendererProps>): void {
|
|
365
|
+
if (
|
|
366
|
+
props.depthIntervalSamples !== undefined &&
|
|
367
|
+
props.depthIntervalSamples !== this.props.depthIntervalSamples
|
|
368
|
+
) {
|
|
369
|
+
throw new Error('depthIntervalSamples is fixed at construction');
|
|
370
|
+
}
|
|
371
|
+
if (props.depthInterval) {
|
|
372
|
+
this.setDepthInterval(props.depthInterval);
|
|
373
|
+
}
|
|
315
374
|
if (props.data !== undefined) {
|
|
316
375
|
const replacementBatches = normalizeSplatBatches(props.data);
|
|
317
376
|
const matchesRetainedBatches =
|
|
@@ -550,6 +609,10 @@ export class SplatRenderer {
|
|
|
550
609
|
this.placeholderSphericalHarmonicsBuffer?.destroy();
|
|
551
610
|
this.placeholderSphericalHarmonicsBuffer = undefined;
|
|
552
611
|
this.shaderInputs.destroy();
|
|
612
|
+
this.depthIntervalCompareBuffers?.greater.destroy();
|
|
613
|
+
this.depthIntervalCompareBuffers?.['less-equal'].destroy();
|
|
614
|
+
this.depthIntervalCompareBuffers = undefined;
|
|
615
|
+
this.depthIntervalBindings = undefined;
|
|
553
616
|
this.isDestroyed = true;
|
|
554
617
|
}
|
|
555
618
|
|
|
@@ -571,10 +634,18 @@ export class SplatRenderer {
|
|
|
571
634
|
}
|
|
572
635
|
return new GPUTableModel(this.device, {
|
|
573
636
|
id: 'gaussian-splat-renderer',
|
|
574
|
-
source: isWebGPU
|
|
637
|
+
source: isWebGPU
|
|
638
|
+
? this.props.depthIntervalSamples === undefined
|
|
639
|
+
? SPLAT_STORAGE_WGSL_SHADER
|
|
640
|
+
: getSplatDepthIntervalWGSLShader(this.props.depthIntervalSamples)
|
|
641
|
+
: SPLAT_ATTRIBUTE_WGSL_SHADER,
|
|
575
642
|
vs: SPLAT_VS_GLSL,
|
|
576
643
|
fs: SPLAT_FS_GLSL,
|
|
577
644
|
shaderLayout: isWebGPU ? SPLAT_STORAGE_SHADER_LAYOUT : SPLAT_ATTRIBUTE_SHADER_LAYOUT,
|
|
645
|
+
plugins:
|
|
646
|
+
isWebGPU && this.props.depthIntervalSamples !== undefined
|
|
647
|
+
? [makeDepthIntervalPlugin(this.props.depthIntervalSamples)]
|
|
648
|
+
: [],
|
|
578
649
|
modules: [splatUniforms],
|
|
579
650
|
shaderInputs: this.shaderInputs,
|
|
580
651
|
table,
|
|
@@ -600,6 +671,9 @@ export class SplatRenderer {
|
|
|
600
671
|
vertexCount: 4,
|
|
601
672
|
topology: 'triangle-strip',
|
|
602
673
|
parameters: {
|
|
674
|
+
...(!isWebGPU || this.props.depthIntervalSamples === undefined
|
|
675
|
+
? {}
|
|
676
|
+
: {sampleCount: this.props.depthIntervalSamples}),
|
|
603
677
|
depthWriteEnabled: this.props.depthWriteEnabled,
|
|
604
678
|
depthCompare: this.props.depthCompare,
|
|
605
679
|
blend: true,
|
|
@@ -913,6 +987,9 @@ export class SplatRenderer {
|
|
|
913
987
|
if (!this.model || !this.table) {
|
|
914
988
|
return false;
|
|
915
989
|
}
|
|
990
|
+
if (this.props.depthIntervalSamples !== undefined && !this.depthIntervalBindings) {
|
|
991
|
+
return false;
|
|
992
|
+
}
|
|
916
993
|
let drawSuccess = true;
|
|
917
994
|
for (const run of this.drawRuns) {
|
|
918
995
|
const batch = this.table.batches[run.batchIndex];
|
|
@@ -931,6 +1008,9 @@ export class SplatRenderer {
|
|
|
931
1008
|
this.batches[run.batchIndex].sphericalHarmonics?.data[0]?.buffer ??
|
|
932
1009
|
this.placeholderSphericalHarmonicsBuffer!
|
|
933
1010
|
});
|
|
1011
|
+
if (this.depthIntervalBindings) {
|
|
1012
|
+
this.model.setBindings(this.depthIntervalBindings);
|
|
1013
|
+
}
|
|
934
1014
|
this.model.setInstanceCount(run.rowIndices.length);
|
|
935
1015
|
drawSuccess = this.model.draw(renderPass) && drawSuccess;
|
|
936
1016
|
}
|
|
@@ -194,8 +194,7 @@ fn projectSplatVertex(
|
|
|
194
194
|
return output;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
|
|
198
|
-
fn fragmentMain(input : SplatFragmentInputs) -> @location(0) vec4<f32> {
|
|
197
|
+
fn evaluateSplatFragment(input : SplatFragmentInputs) -> vec4<f32> {
|
|
199
198
|
let gaussianWeight = exp(-0.5 * dot(input.gaussianCoordinate, input.gaussianCoordinate));
|
|
200
199
|
let alpha = input.color.a * gaussianWeight;
|
|
201
200
|
if (alpha <= 0.0 || alpha < splat.alphaCutoff) {
|
|
@@ -211,8 +210,41 @@ fn fragmentMain(input : SplatFragmentInputs) -> @location(0) vec4<f32> {
|
|
|
211
210
|
}
|
|
212
211
|
`;
|
|
213
212
|
|
|
213
|
+
const SPLAT_WGSL_DEFAULT_FRAGMENT = /* wgsl */ `\
|
|
214
|
+
@fragment
|
|
215
|
+
fn fragmentMain(input : SplatFragmentInputs) -> @location(0) vec4<f32> {
|
|
216
|
+
return evaluateSplatFragment(input);
|
|
217
|
+
}
|
|
218
|
+
`;
|
|
219
|
+
|
|
220
|
+
const SPLAT_DEPTH_INTERVAL_FRAGMENT_MULTISAMPLED = /* wgsl */ `\
|
|
221
|
+
struct SplatDepthIntervalOutput {
|
|
222
|
+
@location(0) color : vec4<f32>,
|
|
223
|
+
@builtin(sample_mask) sampleMask : u32,
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
@fragment
|
|
227
|
+
fn fragmentMain(input : SplatFragmentInputs) -> SplatDepthIntervalOutput {
|
|
228
|
+
let sampleMask = filterDepthInterval(vec2<i32>(input.position.xy), input.position.z, 0xffffffffu);
|
|
229
|
+
if (sampleMask == 0u) {
|
|
230
|
+
discard;
|
|
231
|
+
}
|
|
232
|
+
return SplatDepthIntervalOutput(evaluateSplatFragment(input), sampleMask);
|
|
233
|
+
}
|
|
234
|
+
`;
|
|
235
|
+
|
|
236
|
+
const SPLAT_DEPTH_INTERVAL_FRAGMENT_SINGLE_SAMPLE = /* wgsl */ `\
|
|
237
|
+
@fragment
|
|
238
|
+
fn fragmentMain(input : SplatFragmentInputs) -> @location(0) vec4<f32> {
|
|
239
|
+
if (filterDepthInterval(vec2<i32>(input.position.xy), input.position.z, 1u) == 0u) {
|
|
240
|
+
discard;
|
|
241
|
+
}
|
|
242
|
+
return evaluateSplatFragment(input);
|
|
243
|
+
}
|
|
244
|
+
`;
|
|
245
|
+
|
|
214
246
|
/** WebGPU vertex shader that consumes source vectors directly through storage buffers. */
|
|
215
|
-
|
|
247
|
+
const SPLAT_STORAGE_WGSL_BASE = /* wgsl */ `\
|
|
216
248
|
${SPLAT_WGSL_SHARED}
|
|
217
249
|
|
|
218
250
|
@group(0) @binding(auto) var<storage, read> splatPositions : array<f32>;
|
|
@@ -312,9 +344,22 @@ fn vertexMain(
|
|
|
312
344
|
}
|
|
313
345
|
`;
|
|
314
346
|
|
|
347
|
+
/** Default storage shader retains the original fragment output and bindings. */
|
|
348
|
+
export const SPLAT_STORAGE_WGSL_SHADER = SPLAT_STORAGE_WGSL_BASE + SPLAT_WGSL_DEFAULT_FRAGMENT;
|
|
349
|
+
|
|
350
|
+
/** Storage shader that writes only the samples on the selected side of a depth bound. */
|
|
351
|
+
export function getSplatDepthIntervalWGSLShader(samples: number): string {
|
|
352
|
+
const fragment =
|
|
353
|
+
samples > 1
|
|
354
|
+
? SPLAT_DEPTH_INTERVAL_FRAGMENT_MULTISAMPLED
|
|
355
|
+
: SPLAT_DEPTH_INTERVAL_FRAGMENT_SINGLE_SAMPLE;
|
|
356
|
+
return SPLAT_STORAGE_WGSL_BASE + fragment;
|
|
357
|
+
}
|
|
358
|
+
|
|
315
359
|
/** WebGPU attribute-backed shader retained for shader inspection and device-independent smoke tests. */
|
|
316
360
|
export const SPLAT_ATTRIBUTE_WGSL_SHADER = /* wgsl */ `\
|
|
317
361
|
${SPLAT_WGSL_SHARED}
|
|
362
|
+
${SPLAT_WGSL_DEFAULT_FRAGMENT}
|
|
318
363
|
|
|
319
364
|
struct SplatVertexInputs {
|
|
320
365
|
@builtin(vertex_index) vertexIndex : u32,
|