gaussian-splat-lite 1.2.1 → 1.2.2

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.
@@ -1,7 +1,7 @@
1
1
  import { DepthTexture, Matrix4, OrthographicCamera, PerspectiveCamera, Scene } from 'three';
2
- import { NodeBuilder, NodeFrame, TempNode, TextureNode } from 'three/webgpu';
2
+ import { Node, NodeBuilder, NodeFrame, TextureNode } from 'three/webgpu';
3
3
  /** Camera/depth TAA for WebGPURenderer, including its WebGL2 fallback. */
4
- export declare class TAANode extends TempNode<"vec4"> {
4
+ export declare class TAANode extends Node<"vec4"> {
5
5
  scene: Scene;
6
6
  camera: PerspectiveCamera | OrthographicCamera;
7
7
  static get type(): string;
@@ -11,6 +11,8 @@ export declare class TAANode extends TempNode<"vec4"> {
11
11
  useSubpixelCorrection: boolean;
12
12
  private readonly source;
13
13
  private readonly history;
14
+ private readonly historyColor;
15
+ private readonly historyDepth;
14
16
  private readonly textureNode;
15
17
  private readonly material;
16
18
  private readonly quad;
@@ -1,7 +1,7 @@
1
1
  import { DepthTexture, Matrix4, OrthographicCamera, PerspectiveCamera, Scene } from 'three';
2
- import { NodeBuilder, NodeFrame, TempNode, TextureNode } from 'three/webgpu';
2
+ import { Node, NodeBuilder, NodeFrame, TextureNode } from 'three/webgpu';
3
3
  /** Camera/depth TAA for WebGPURenderer, including its WebGL2 fallback. */
4
- export declare class TAANode extends TempNode<"vec4"> {
4
+ export declare class TAANode extends Node<"vec4"> {
5
5
  scene: Scene;
6
6
  camera: PerspectiveCamera | OrthographicCamera;
7
7
  static get type(): string;
@@ -11,6 +11,8 @@ export declare class TAANode extends TempNode<"vec4"> {
11
11
  useSubpixelCorrection: boolean;
12
12
  private readonly source;
13
13
  private readonly history;
14
+ private readonly historyColor;
15
+ private readonly historyDepth;
14
16
  private readonly textureNode;
15
17
  private readonly material;
16
18
  private readonly quad;
@@ -1,4 +1,4 @@
1
- import { Camera, Matrix4, OrthographicCamera, PerspectiveCamera, RenderTarget, Vector2, Vector3 } from 'three';
1
+ import { Camera, Matrix4, OrthographicCamera, PerspectiveCamera, RenderTarget, TextureDataType, Vector2, Vector3 } from 'three';
2
2
  type TAACamera = PerspectiveCamera | OrthographicCamera;
3
3
  type TAAParameters = {
4
4
  depthThreshold: number;
@@ -22,7 +22,7 @@ export declare function createTAAState<FloatUniform extends {
22
22
  (value: Vector2): Vec2Uniform;
23
23
  (value: Vector3): Vec3Uniform;
24
24
  (value: Matrix4): Mat4Uniform;
25
- }, targets: RenderTarget[]): {
25
+ }, targets: RenderTarget[], nodeLogDepth?: boolean): {
26
26
  uniforms: {
27
27
  renderSize: Vec2Uniform;
28
28
  projection: Mat4Uniform;
@@ -34,6 +34,7 @@ export declare function createTAAState<FloatUniform extends {
34
34
  reversed: BoolUniform;
35
35
  logarithmic: BoolUniform;
36
36
  logFar: Vec2Uniform;
37
+ logNear: Vec2Uniform;
37
38
  depthThreshold: FloatUniform;
38
39
  edgeDepthDiff: FloatUniform;
39
40
  maxMotionLength: FloatUniform;
@@ -44,6 +45,7 @@ export declare function createTAAState<FloatUniform extends {
44
45
  jitterIndex: number;
45
46
  reset(): void;
46
47
  setSize(width: number, height: number): void;
48
+ setStencil(stencil: boolean, depthType: TextureDataType): void;
47
49
  beginCapture(camera: TAACamera): void;
48
50
  endCapture(camera: TAACamera): void;
49
51
  prepareResolve(camera: TAACamera, parameters: TAAParameters): 0 | 1;
@@ -1,4 +1,4 @@
1
- import { Camera, Matrix4, OrthographicCamera, PerspectiveCamera, RenderTarget, Vector2, Vector3 } from 'three';
1
+ import { Camera, Matrix4, OrthographicCamera, PerspectiveCamera, RenderTarget, TextureDataType, Vector2, Vector3 } from 'three';
2
2
  type TAACamera = PerspectiveCamera | OrthographicCamera;
3
3
  type TAAParameters = {
4
4
  depthThreshold: number;
@@ -22,7 +22,7 @@ export declare function createTAAState<FloatUniform extends {
22
22
  (value: Vector2): Vec2Uniform;
23
23
  (value: Vector3): Vec3Uniform;
24
24
  (value: Matrix4): Mat4Uniform;
25
- }, targets: RenderTarget[]): {
25
+ }, targets: RenderTarget[], nodeLogDepth?: boolean): {
26
26
  uniforms: {
27
27
  renderSize: Vec2Uniform;
28
28
  projection: Mat4Uniform;
@@ -34,6 +34,7 @@ export declare function createTAAState<FloatUniform extends {
34
34
  reversed: BoolUniform;
35
35
  logarithmic: BoolUniform;
36
36
  logFar: Vec2Uniform;
37
+ logNear: Vec2Uniform;
37
38
  depthThreshold: FloatUniform;
38
39
  edgeDepthDiff: FloatUniform;
39
40
  maxMotionLength: FloatUniform;
@@ -44,6 +45,7 @@ export declare function createTAAState<FloatUniform extends {
44
45
  jitterIndex: number;
45
46
  reset(): void;
46
47
  setSize(width: number, height: number): void;
48
+ setStencil(stencil: boolean, depthType: TextureDataType): void;
47
49
  beginCapture(camera: TAACamera): void;
48
50
  endCapture(camera: TAACamera): void;
49
51
  prepareResolve(camera: TAACamera, parameters: TAAParameters): 0 | 1;
@@ -50,7 +50,8 @@ export interface GaussianSplatRendererOptions {
50
50
  /**
51
51
  * Maximum standard deviations from the center to render Gaussians. Values
52
52
  * Math.sqrt(4)..Math.sqrt(9) produce acceptable results and can be tweaked for
53
- * performance.
53
+ * performance. A Gaussian still above minAlpha at this distance fades to
54
+ * minAlpha there instead of ending in a step.
54
55
  * @default Math.sqrt(8)
55
56
  */
56
57
  maxStdDev?: number;
@@ -62,7 +63,7 @@ export interface GaussianSplatRendererOptions {
62
63
  minPixelRadius?: number;
63
64
  /**
64
65
  * Minimum alpha value for splat rendering.
65
- * @default 1 / 255
66
+ * @default 0.5 / 255
66
67
  */
67
68
  minAlpha?: number;
68
69
  /**
@@ -258,6 +259,9 @@ export declare class GaussianSplatRenderer extends THREE.Mesh<SplatGeometry, Spl
258
259
  minAlpha: {
259
260
  value: number;
260
261
  };
262
+ edgeFade: {
263
+ value: THREE.Vector2;
264
+ };
261
265
  preBlurAmount: {
262
266
  value: number;
263
267
  };
@@ -50,7 +50,8 @@ export interface GaussianSplatRendererOptions {
50
50
  /**
51
51
  * Maximum standard deviations from the center to render Gaussians. Values
52
52
  * Math.sqrt(4)..Math.sqrt(9) produce acceptable results and can be tweaked for
53
- * performance.
53
+ * performance. A Gaussian still above minAlpha at this distance fades to
54
+ * minAlpha there instead of ending in a step.
54
55
  * @default Math.sqrt(8)
55
56
  */
56
57
  maxStdDev?: number;
@@ -62,7 +63,7 @@ export interface GaussianSplatRendererOptions {
62
63
  minPixelRadius?: number;
63
64
  /**
64
65
  * Minimum alpha value for splat rendering.
65
- * @default 1 / 255
66
+ * @default 0.5 / 255
66
67
  */
67
68
  minAlpha?: number;
68
69
  /**
@@ -258,6 +259,9 @@ export declare class GaussianSplatRenderer extends THREE.Mesh<SplatGeometry, Spl
258
259
  minAlpha: {
259
260
  value: number;
260
261
  };
262
+ edgeFade: {
263
+ value: THREE.Vector2;
264
+ };
261
265
  preBlurAmount: {
262
266
  value: number;
263
267
  };
@@ -30,6 +30,8 @@ export type SplatProjection = {
30
30
  /** Source color space; the draw stage applies encodeLinear. */
31
31
  rgba: Node<"vec4">;
32
32
  supportRadius: Node<"float">;
33
+ /** A wide kernel's low 16 bits hold its edge fade as a half. */
34
+ supportRadiusSquared: Node<"float">;
33
35
  kernelPower: Node<"float">;
34
36
  };
35
37
  /** Shared projection for vertex and compute paths. Call inside a TSL Fn. */
@@ -30,6 +30,8 @@ export type SplatProjection = {
30
30
  /** Source color space; the draw stage applies encodeLinear. */
31
31
  rgba: Node<"vec4">;
32
32
  supportRadius: Node<"float">;
33
+ /** A wide kernel's low 16 bits hold its edge fade as a half. */
34
+ supportRadiusSquared: Node<"float">;
33
35
  kernelPower: Node<"float">;
34
36
  };
35
37
  /** Shared projection for vertex and compute paths. Call inside a TSL Fn. */
@@ -8,6 +8,7 @@ export type ProjectedVertexData = {
8
8
  splatUv: Node<"vec2">;
9
9
  /** Stochastic variant only. */
10
10
  stochasticSeed?: Node<"uint">;
11
+ /** A wide kernel's low 16 bits hold its edge fade as a half. */
11
12
  supportRadiusSquared: Node<"float">;
12
13
  kernelPower: Node<"float">;
13
14
  viewportOrigin: Node<"vec2">;
@@ -8,6 +8,7 @@ export type ProjectedVertexData = {
8
8
  splatUv: Node<"vec2">;
9
9
  /** Stochastic variant only. */
10
10
  stochasticSeed?: Node<"uint">;
11
+ /** A wide kernel's low 16 bits hold its edge fade as a half. */
11
12
  supportRadiusSquared: Node<"float">;
12
13
  kernelPower: Node<"float">;
13
14
  viewportOrigin: Node<"vec2">;
@@ -38,6 +38,9 @@ export declare function makeSplatUniforms(): {
38
38
  minAlpha: {
39
39
  value: number;
40
40
  };
41
+ edgeFade: {
42
+ value: THREE.Vector2;
43
+ };
41
44
  preBlurAmount: {
42
45
  value: number;
43
46
  };
@@ -38,6 +38,9 @@ export declare function makeSplatUniforms(): {
38
38
  minAlpha: {
39
39
  value: number;
40
40
  };
41
+ edgeFade: {
42
+ value: THREE.Vector2;
43
+ };
41
44
  preBlurAmount: {
42
45
  value: number;
43
46
  };
@@ -53,6 +53,11 @@ In `webgpu/`, `ProjectedSplats.ts` coordinates projection and sorting, `Projecti
53
53
 
54
54
  Projected Splat support is capped at the viewport's short side, in projection space scaled by `focalAdjustment`, in both the TSL projection program and the GLSL vertex shader. The quad and its UV extent shrink by the same ratio, preserving the Gaussian profile.
55
55
 
56
+ A kernel still above `minAlpha` where its support ends is faded there instead of cut off. The fragment stage rescales it about its peak, `(alpha + fade) * kernel - fade`, so it reaches `minAlpha` at the support edge. The quad is never enlarged.
57
+
58
+ - **Gaussians.** Only `maxStdDev` can end a Gaussian early, so its fade follows from its alpha and the per-draw `edgeFade` uniform, a scale and offset derived from `maxStdDev` and `minAlpha`. It needs no per-Splat data, and a Gaussian that `minAlpha` already ends is drawn exactly as before.
59
+ - **Wide kernels.** The edge value depends on the kernel power, so the projection computes the fade and stores it as a half in the low 16 bits of the squared support radius. That radius is first rounded down to its high 16 bits, at most 0.6% of the radius, which keeps the fragment stage's radius test exact. The squared radius therefore passes to the fragment stage bit for bit, and native WebGPU caches it in place of the radius.
60
+
56
61
  Errors from automatic updates are caught and logged once per message; a draw whose preparation fails is skipped. Explicit `update()` calls rethrow to the caller. `frameCallbacks` is an internal flag for a second renderer on the same scene, so each `SplatMesh.onFrame` runs once per frame.
57
62
 
58
63
  Resource rules:
@@ -88,6 +93,7 @@ Seeds exist only for stochastic draws: WebGL accumulators omit the seed layer in
88
93
 
89
94
  - `taaShared.ts` owns the state both share: a 32-entry Halton(2, 3) jitter sequence, jittered and unjittered projections, previous-frame matrices, the history index, sizing, and reset. It supports custom projections, scaled rigs, reversed depth, and logarithmic depth.
90
95
  - Each implementation captures the scene itself into a half-float target with a depth texture and resolves between two history targets, with no history copies. The resolve applies depth rejection away from edges, neighborhood clipping, and luminance-aware blending.
96
+ - The capture target takes a stencil buffer when the Three.js renderer has one; the history targets never do, since the resolve writes only color and depth. Depth stays 32-bit float, except in `TAANode` on the WebGL2 fallback or on a device without `depth32float-stencil8`, where it is 24-bit.
91
97
  - The camera's projection is jittered only during capture. Native Splat projection reads the unjittered matrix through `getTAAProjection()`, so projection and sorting results are reused while only the jitter changes.
92
98
  - `TAAPass` flags its capture target as an XR-style target, so Three.js converts materials to `renderer.outputColorSpace` before blending, matching canvas blending. Tone mapping is disabled during capture. The final copy decodes the sRGB transfer into the composer's working-space buffer, the inverse of `OutputPass`, so the two round-trip at any alpha; as the last pass it presents the output-space image unchanged. An output color space change resets history.
93
99
  - `TAANode` is a TSL node updated once per render. It captures and accumulates in `ColorManagement.workingColorSpace`, leaving tone mapping and output conversion to `RenderPipeline`. A working color space change resets history.
@@ -30,9 +30,9 @@ Every option except `renderer` and `timer` is also a property, so you can change
30
30
 
31
31
  | Option | Type | Default | Description |
32
32
  | --- | --- | --- | --- |
33
- | `maxStdDev` | `number` | `Math.sqrt(8)` | How far each Splat extends from its center. Lower values trim its soft outer edge and render faster; `Math.sqrt(4)` to `Math.sqrt(9)` looks acceptable |
33
+ | `maxStdDev` | `number` | `Math.sqrt(8)` | How far each Splat extends from its center. Lower values trim its soft outer edge and render faster; a trimmed Splat fades to `minAlpha` at its edge instead of ending in a step. `Math.sqrt(4)` to `Math.sqrt(9)` looks acceptable |
34
34
  | `minPixelRadius` | `number` | `1` | Skip Splats smaller than this radius in screen pixels |
35
- | `minAlpha` | `number` | `1 / 255` | Hide the parts of a Splat more transparent than this |
35
+ | `minAlpha` | `number` | `0.5 / 255` | Hide the parts of a Splat more transparent than this |
36
36
  | `preBlurAmount` | `number` | `0.3` | Enlarge and soften Splats. Use `0` for models trained with anti-aliasing |
37
37
  | `blurAmount` | `number` | `0` | Soften Splats while adjusting their opacity to compensate. For models trained with anti-aliasing, use `0.3` together with `preBlurAmount: 0` |
38
38
  | `clipXY` | `number` | `1.25` | How far outside the view a Splat's center may be before the Splat is skipped; `1` cuts exactly at the edge |
package/docs/TAAPass.md CHANGED
@@ -15,6 +15,7 @@ Both render the scene themselves and need no velocity buffer or other scene setu
15
15
 
16
16
  - **One camera.** A `PerspectiveCamera` or `OrthographicCamera`, including custom projections, scaled camera rigs, reversed depth, and logarithmic depth. WebXR is not supported.
17
17
  - **Camera movement only.** Moving objects and changes to individual Splats are not tracked, and may leave a faint trail.
18
+ - **Stencil follows your renderer.** Create the Three.js renderer with `stencil: true` and stencil masks work as they do without TAA, including the stencil settings on your Splat renderer's `material`.
18
19
  - **Reset after a jump.** Call `taa.reset()` after a camera cut or after replacing the scene. Resizing resets automatically.
19
20
  - **Keep rendering while the image settles.** With on-demand rendering, render several more frames after each change. The viewer renders 32.
20
21
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gaussian-splat-lite",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Three.js Gaussian Splatting renderer with WebGPU/WebGL2, GPU sorting, streaming LOD, and high-precision GIS/ECEF support. Supports PLY, SPZ, SOG and RAD.",
5
5
  "author": "William Liu <lyz15972107087@gmail.com>",
6
6
  "type": "module",