@driftengine/splats 3.61.0
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/LICENSE +202 -0
- package/NOTICE +9 -0
- package/README.md +56 -0
- package/dist/half.d.ts +32 -0
- package/dist/half.js +88 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +38 -0
- package/dist/shaders/generated/splat.wgsl.d.ts +89 -0
- package/dist/shaders/generated/splat.wgsl.js +95 -0
- package/dist/shaders/splat.d.ts +25 -0
- package/dist/shaders/splat.js +337 -0
- package/dist/splat.d.ts +26 -0
- package/dist/splat.js +63 -0
- package/dist/splatBudget.d.ts +40 -0
- package/dist/splatBudget.js +45 -0
- package/dist/splatCapture.d.ts +76 -0
- package/dist/splatCapture.js +108 -0
- package/dist/splatCull.d.ts +25 -0
- package/dist/splatCull.js +80 -0
- package/dist/splatData.d.ts +177 -0
- package/dist/splatData.js +223 -0
- package/dist/splatGl.d.ts +49 -0
- package/dist/splatGl.js +176 -0
- package/dist/splatGpu.d.ts +50 -0
- package/dist/splatGpu.js +180 -0
- package/dist/splatLayout.d.ts +52 -0
- package/dist/splatLayout.js +75 -0
- package/dist/splatMatrix.d.ts +29 -0
- package/dist/splatMatrix.js +68 -0
- package/dist/splatPass.d.ts +83 -0
- package/dist/splatPass.js +206 -0
- package/dist/splatPly.d.ts +14 -0
- package/dist/splatPly.js +242 -0
- package/dist/splatSog.d.ts +110 -0
- package/dist/splatSog.js +285 -0
- package/dist/splatSogDecoder.d.ts +26 -0
- package/dist/splatSogDecoder.js +29 -0
- package/dist/splatSort.d.ts +137 -0
- package/dist/splatSort.js +199 -0
- package/dist/splatSortWorker.d.ts +14 -0
- package/dist/splatSortWorker.js +137 -0
- package/dist/splatSorter.d.ts +112 -0
- package/dist/splatSorter.js +231 -0
- package/dist/splatView.d.ts +52 -0
- package/dist/splatView.js +115 -0
- package/package.json +56 -0
- package/src/fixtures/README.md +36 -0
- package/src/fixtures/cloud.sog +0 -0
- package/src/fixtures/cloud.texels.json +27 -0
- package/src/fixtures/cloud.truth.json +582 -0
- package/src/half.ts +92 -0
- package/src/index.ts +55 -0
- package/src/shaders/generated/splat.wgsl.ts +98 -0
- package/src/shaders/splat.ts +344 -0
- package/src/splat.ts +75 -0
- package/src/splatBudget.ts +48 -0
- package/src/splatCapture.ts +154 -0
- package/src/splatCull.ts +91 -0
- package/src/splatData.ts +398 -0
- package/src/splatGl.ts +262 -0
- package/src/splatGpu.ts +259 -0
- package/src/splatLayout.ts +86 -0
- package/src/splatMatrix.ts +81 -0
- package/src/splatPass.ts +324 -0
- package/src/splatPly.ts +283 -0
- package/src/splatSog.ts +375 -0
- package/src/splatSogDecoder.ts +33 -0
- package/src/splatSort.ts +296 -0
- package/src/splatSortWorker.ts +155 -0
- package/src/splatSorter.ts +285 -0
- package/src/splatView.ts +147 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Drift Technologies
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
DriftEngine
|
|
2
|
+
Copyright 2026 Drift Technologies
|
|
3
|
+
|
|
4
|
+
This product includes software developed at Drift Technologies
|
|
5
|
+
(https://github.com/drftrun/driftengine).
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0. Section 4(d) of that licence
|
|
8
|
+
requires this NOTICE to be reproduced in any derivative work you distribute,
|
|
9
|
+
in the source, the documentation, or a display generated by the work.
|
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# @driftengine/splats
|
|
2
|
+
|
|
3
|
+
Gaussian splat captures: the readers, view-dependent colour, an off-frame sort, and a pass that
|
|
4
|
+
composes into the scene.
|
|
5
|
+
|
|
6
|
+
**Cost: 16.5 KB gzipped on top of core.** Measured by `scripts/size-gate.test.mjs`, which fails if it
|
|
7
|
+
drifts more than 3% — the number is derived from the same floors that gate asserts, so a README
|
|
8
|
+
quoting a stale one is a red suite rather than a thing somebody notices.
|
|
9
|
+
|
|
10
|
+
## What it is
|
|
11
|
+
|
|
12
|
+
A photographed place, drawn as several hundred thousand oriented ellipsoids. `readSplatPly` takes the
|
|
13
|
+
format the capture tools emit; `packSplats` writes the packed record `.drft` carries as `SPLT`.
|
|
14
|
+
`createSplatPass` composes them into a scene that also contains ordinary meshes.
|
|
15
|
+
|
|
16
|
+
## The sort is the whole problem
|
|
17
|
+
|
|
18
|
+
Splats are transparent, so they draw back to front, and the order changes whenever the camera does.
|
|
19
|
+
Sorting hundreds of thousands of them inside a frame is what makes a naive implementation stutter.
|
|
20
|
+
|
|
21
|
+
So **the sort is off-frame and the pass draws whatever order it last received** — a frame is never
|
|
22
|
+
blocked on one. `SplatSortFn` is the seam: supply your own, on a worker or wherever you like, and it
|
|
23
|
+
is handed a `SplatSortScratch` it reuses rather than an array it allocates. The cost is that a fast
|
|
24
|
+
camera move draws a slightly stale order for a frame or two, which reads as a soft settle rather than
|
|
25
|
+
as a stall. What would make that wrong is a capture small enough to sort inline, where the seam is
|
|
26
|
+
overhead.
|
|
27
|
+
|
|
28
|
+
## Colour that changes with the view
|
|
29
|
+
|
|
30
|
+
A capture from a training run stores its colour as a spherical-harmonic expansion: the constant term
|
|
31
|
+
is the colour from every angle, and the bands above it are how that colour changes as you move past
|
|
32
|
+
the surface. **The l=1 band is read and the rest is not**, which is a decision with numbers behind
|
|
33
|
+
it rather than a partial implementation.
|
|
34
|
+
|
|
35
|
+
Nine coefficients, transposed out of the file's channel-major order and packed into **one extra
|
|
36
|
+
texel a splat** — nine 8-bit values and a per-splat scale in the fourth word. That is 48 bytes a
|
|
37
|
+
record against 32, and the vertex stage runs six times a splat, so it is 288 bytes a splat a frame
|
|
38
|
+
against 192. At the mobile budget of 400,000 splats: **115 MB a frame against 77**.
|
|
39
|
+
|
|
40
|
+
Degree 2 is three extra texels and degree 3 is six, which at the same budget is 192 MB and 307 MB a
|
|
41
|
+
frame — against a mid-range phone already moving 389 MB a frame of attachment traffic. So the sharp
|
|
42
|
+
specular bands are declined, and the broad directional lobe that makes glass and a wet floor read as
|
|
43
|
+
themselves is the one that ships.
|
|
44
|
+
|
|
45
|
+
**A capture without harmonics pays nothing**: it is eight words a splat and two texels exactly as
|
|
46
|
+
before, and the shader's gate is a uniform, so it performs no third fetch. The width travels in the
|
|
47
|
+
`SPLT` block's own header, which the format designed for this.
|
|
48
|
+
|
|
49
|
+
## Streaming
|
|
50
|
+
|
|
51
|
+
The `SPLT` record is blocked and coarse-ordered, so a reader can draw the first block before the rest
|
|
52
|
+
arrives. Measured on a 332 KB capture: the first of sixteen blocks is 662 splats in 24 KB, and it
|
|
53
|
+
draws the whole room rather than a corner of it.
|
|
54
|
+
|
|
55
|
+
Part of [DriftEngine](../../README.md). See [`docs/ARCHITECTURE.md`](../../docs/ARCHITECTURE.md)
|
|
56
|
+
for how the packages divide, and why some features are compiled into core on demand instead.
|
package/dist/half.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** IEEE 754 binary16 encoding, because a covariance term is stored as a half and JavaScript has no half. */
|
|
2
|
+
/**
|
|
3
|
+
* The 16-bit pattern of the nearest half to `value`, ties to even.
|
|
4
|
+
*
|
|
5
|
+
* **Round to nearest even rather than truncate**, which costs a handful of operations per call and
|
|
6
|
+
* buys a bounded error instead of a biased one: truncation always moves toward zero, so a sum of
|
|
7
|
+
* truncated covariance terms shrinks a splat systematically rather than jittering it. What would
|
|
8
|
+
* make it wrong is nothing about correctness — a truncating version is simpler and is what several
|
|
9
|
+
* published viewers ship; it is half an ulp worse per term and the bias accumulates over six.
|
|
10
|
+
*
|
|
11
|
+
* Overflow saturates to infinity and underflow to a signed zero, which is what the format says.
|
|
12
|
+
* **A covariance term small enough to underflow is a splat smaller than 8 micrometres** at a
|
|
13
|
+
* capture's usual scale, and the low-pass in the vertex stage would swallow it whole.
|
|
14
|
+
*/
|
|
15
|
+
export declare function floatToHalf(value: number): number;
|
|
16
|
+
/**
|
|
17
|
+
* The number a 16-bit pattern stands for. **Tests and tools only** — nothing in a frame decodes a
|
|
18
|
+
* half, because the GPU does it.
|
|
19
|
+
*
|
|
20
|
+
* It exists so a round-trip can be asserted against the value that went in rather than against a
|
|
21
|
+
* second implementation of the encoder, which would only prove the two agree.
|
|
22
|
+
*/
|
|
23
|
+
export declare function halfToFloat(bits: number): number;
|
|
24
|
+
/**
|
|
25
|
+
* Two halves in one `uint32`, laid out as GLSL's `packHalf2x16`.
|
|
26
|
+
*
|
|
27
|
+
* **`a` occupies the sixteen least significant bits**, which is the specification's wording and is
|
|
28
|
+
* the one detail here that a shader cannot report going wrong: swapping them produces a covariance
|
|
29
|
+
* whose terms are transposed into each other's places, which is a valid matrix and draws a
|
|
30
|
+
* plausible, wrong ellipse.
|
|
31
|
+
*/
|
|
32
|
+
export declare function packHalf2x16(a: number, b: number): number;
|
package/dist/half.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/** IEEE 754 binary16 encoding, because a covariance term is stored as a half and JavaScript has no half. */
|
|
2
|
+
/*
|
|
3
|
+
* One scratch pair at module scope, reinterpreting a float's bits without allocating. `packSplats`
|
|
4
|
+
* calls this six times per splat, so a capture of a million splats calls it six million times in
|
|
5
|
+
* one loop — an `ArrayBuffer` per call would be six million of them.
|
|
6
|
+
*
|
|
7
|
+
* Not a hot path in the per-frame sense: packing happens once, on load. It is a hot *loop* all the
|
|
8
|
+
* same, and the house rule's reason applies to both.
|
|
9
|
+
*/
|
|
10
|
+
const scratch = new ArrayBuffer(4);
|
|
11
|
+
const asFloat = new Float32Array(scratch);
|
|
12
|
+
const asBits = new Uint32Array(scratch);
|
|
13
|
+
/**
|
|
14
|
+
* The 16-bit pattern of the nearest half to `value`, ties to even.
|
|
15
|
+
*
|
|
16
|
+
* **Round to nearest even rather than truncate**, which costs a handful of operations per call and
|
|
17
|
+
* buys a bounded error instead of a biased one: truncation always moves toward zero, so a sum of
|
|
18
|
+
* truncated covariance terms shrinks a splat systematically rather than jittering it. What would
|
|
19
|
+
* make it wrong is nothing about correctness — a truncating version is simpler and is what several
|
|
20
|
+
* published viewers ship; it is half an ulp worse per term and the bias accumulates over six.
|
|
21
|
+
*
|
|
22
|
+
* Overflow saturates to infinity and underflow to a signed zero, which is what the format says.
|
|
23
|
+
* **A covariance term small enough to underflow is a splat smaller than 8 micrometres** at a
|
|
24
|
+
* capture's usual scale, and the low-pass in the vertex stage would swallow it whole.
|
|
25
|
+
*/
|
|
26
|
+
export function floatToHalf(value) {
|
|
27
|
+
asFloat[0] = value;
|
|
28
|
+
const bits = asBits[0] ?? 0;
|
|
29
|
+
const sign = (bits >>> 16) & 0x8000;
|
|
30
|
+
const exponent = (bits >>> 23) & 0xff;
|
|
31
|
+
const mantissa = bits & 0x007fffff;
|
|
32
|
+
/* NaN keeps a non-zero mantissa so it stays NaN; infinity keeps an empty one. */
|
|
33
|
+
if (exponent === 0xff)
|
|
34
|
+
return sign | 0x7c00 | (mantissa === 0 ? 0 : 0x0200);
|
|
35
|
+
/* Rebias: float32 excess-127 to float16 excess-15. */
|
|
36
|
+
const rebiased = exponent - 127 + 15;
|
|
37
|
+
if (rebiased >= 0x1f)
|
|
38
|
+
return sign | 0x7c00;
|
|
39
|
+
if (rebiased <= 0) {
|
|
40
|
+
/* Past the subnormal range entirely — 24 bits of shift would leave nothing. */
|
|
41
|
+
if (rebiased < -10)
|
|
42
|
+
return sign;
|
|
43
|
+
/* Subnormal: restore the implicit leading one, then shift it down into place. */
|
|
44
|
+
const full = mantissa | 0x00800000;
|
|
45
|
+
const shift = 14 - rebiased;
|
|
46
|
+
const truncated = full >>> shift;
|
|
47
|
+
const half = truncated & 0xffff;
|
|
48
|
+
const roundBit = (full >>> (shift - 1)) & 1;
|
|
49
|
+
const sticky = (full & ((1 << (shift - 1)) - 1)) === 0 ? 0 : 1;
|
|
50
|
+
const round = roundBit === 1 && (sticky === 1 || (half & 1) === 1) ? 1 : 0;
|
|
51
|
+
return sign | (half + round);
|
|
52
|
+
}
|
|
53
|
+
const truncated = (rebiased << 10) | (mantissa >>> 13);
|
|
54
|
+
const roundBit = (mantissa >>> 12) & 1;
|
|
55
|
+
const sticky = (mantissa & 0x0fff) === 0 ? 0 : 1;
|
|
56
|
+
const round = roundBit === 1 && (sticky === 1 || (truncated & 1) === 1) ? 1 : 0;
|
|
57
|
+
/* Carrying out of the mantissa lands in the exponent, which is exactly right: 65520 rounds up
|
|
58
|
+
to infinity and 2047.5 rounds up to 2048, both by the same addition. */
|
|
59
|
+
return (sign | (truncated + round)) & 0xffff;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The number a 16-bit pattern stands for. **Tests and tools only** — nothing in a frame decodes a
|
|
63
|
+
* half, because the GPU does it.
|
|
64
|
+
*
|
|
65
|
+
* It exists so a round-trip can be asserted against the value that went in rather than against a
|
|
66
|
+
* second implementation of the encoder, which would only prove the two agree.
|
|
67
|
+
*/
|
|
68
|
+
export function halfToFloat(bits) {
|
|
69
|
+
const sign = (bits & 0x8000) === 0 ? 1 : -1;
|
|
70
|
+
const exponent = (bits >>> 10) & 0x1f;
|
|
71
|
+
const mantissa = bits & 0x03ff;
|
|
72
|
+
if (exponent === 0)
|
|
73
|
+
return sign * mantissa * 2 ** -24;
|
|
74
|
+
if (exponent === 0x1f)
|
|
75
|
+
return mantissa === 0 ? sign * Infinity : NaN;
|
|
76
|
+
return sign * (1 + mantissa / 1024) * 2 ** (exponent - 15);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Two halves in one `uint32`, laid out as GLSL's `packHalf2x16`.
|
|
80
|
+
*
|
|
81
|
+
* **`a` occupies the sixteen least significant bits**, which is the specification's wording and is
|
|
82
|
+
* the one detail here that a shader cannot report going wrong: swapping them produces a covariance
|
|
83
|
+
* whose terms are transposed into each other's places, which is a valid matrix and draws a
|
|
84
|
+
* plausible, wrong ellipse.
|
|
85
|
+
*/
|
|
86
|
+
export function packHalf2x16(a, b) {
|
|
87
|
+
return ((floatToHalf(b) << 16) | floatToHalf(a)) >>> 0;
|
|
88
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*! DriftEngine | Copyright 2026 Drift Technologies | Apache-2.0 | https://github.com/drftrun/driftengine */
|
|
2
|
+
/**
|
|
3
|
+
* `@driftengine/splats` — Gaussian splat captures, read and drawn into the scene.
|
|
4
|
+
*
|
|
5
|
+
* **The barrel is the contract.** Anything not exported here is private to this package, whatever
|
|
6
|
+
* its file permissions suggest.
|
|
7
|
+
*
|
|
8
|
+
* This package owns its readers, its sort, its shaders and its GPU resources, and it reaches the
|
|
9
|
+
* frame through `registerPass` rather than through a verb on `RendererApi` — which is what makes
|
|
10
|
+
* it a package at all. A consumer that never imports it carries none of it, and
|
|
11
|
+
* `scripts/size-gate.test.mjs` asserts that rather than claiming it.
|
|
12
|
+
*/
|
|
13
|
+
export { packSplats, SPLAT_SH1_COEFFICIENTS, SPLAT_WORDS, SPLAT_WORDS_SH1 } from './splatData.ts';
|
|
14
|
+
export type { SplatData, SplatSource } from './splatData.ts';
|
|
15
|
+
export { readSplat, SPLAT_RECORD_BYTES } from './splat.ts';
|
|
16
|
+
export { readSplatPly } from './splatPly.ts';
|
|
17
|
+
export { browserWebpDecoder } from './splatSogDecoder.ts';
|
|
18
|
+
export { SOG_VERSION, readSogMeta, readSogSource, readSplatSog, unbundleSog } from './splatSog.ts';
|
|
19
|
+
export type { DecodedImage, SogFiles, SogMeta, WebpDecoder } from './splatSog.ts';
|
|
20
|
+
export { createSplatPass } from './splatPass.ts';
|
|
21
|
+
export type { SplatPass, SplatView } from './splatPass.ts';
|
|
22
|
+
export { SPLAT_STRIDE } from './splatLayout.ts';
|
|
23
|
+
export { createSplatSortScratch, sortSplatsByDepth, SPLAT_SIZE_BUCKETS, SPLAT_SORT_BUCKETS, } from './splatSort.ts';
|
|
24
|
+
export type { SplatSortFn, SplatSortRequest, SplatSortResult, SplatSortScratch, } from './splatSort.ts';
|
|
25
|
+
export { SplatSorter, createDefaultSplatSort, sortOnMainThread } from './splatSorter.ts';
|
|
26
|
+
export type { SplatSorterOptions } from './splatSorter.ts';
|
|
27
|
+
export { createSplatViewLocal, resolveSplatView } from './splatView.ts';
|
|
28
|
+
export type { SplatViewLocal } from './splatView.ts';
|
|
29
|
+
export { defaultSplatBudget, SPLAT_BUDGET_DEFAULT, SPLAT_BUDGET_WEAK } from './splatBudget.ts';
|
|
30
|
+
export { splatBoundsVisible } from './splatCull.ts';
|
|
31
|
+
export { SplatCapture, splatsFromRecords } from './splatCapture.ts';
|
|
32
|
+
export type { SplatAppend, SplatCaptureOptions } from './splatCapture.ts';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*! DriftEngine | Copyright 2026 Drift Technologies | Apache-2.0 | https://github.com/drftrun/driftengine */
|
|
2
|
+
/**
|
|
3
|
+
* `@driftengine/splats` — Gaussian splat captures, read and drawn into the scene.
|
|
4
|
+
*
|
|
5
|
+
* **The barrel is the contract.** Anything not exported here is private to this package, whatever
|
|
6
|
+
* its file permissions suggest.
|
|
7
|
+
*
|
|
8
|
+
* This package owns its readers, its sort, its shaders and its GPU resources, and it reaches the
|
|
9
|
+
* frame through `registerPass` rather than through a verb on `RendererApi` — which is what makes
|
|
10
|
+
* it a package at all. A consumer that never imports it carries none of it, and
|
|
11
|
+
* `scripts/size-gate.test.mjs` asserts that rather than claiming it.
|
|
12
|
+
*/
|
|
13
|
+
export { packSplats, SPLAT_SH1_COEFFICIENTS, SPLAT_WORDS, SPLAT_WORDS_SH1 } from './splatData.js';
|
|
14
|
+
export { readSplat, SPLAT_RECORD_BYTES } from './splat.js';
|
|
15
|
+
export { readSplatPly } from './splatPly.js';
|
|
16
|
+
/*
|
|
17
|
+
* The `.sog` container: a ZIP of lossless WebP images and a manifest, which is what newer capture
|
|
18
|
+
* tools emit.
|
|
19
|
+
*
|
|
20
|
+
* **Four exports rather than one, because the read has two halves a consumer may want separately.**
|
|
21
|
+
* A bundle unpacks to files and files decode to Gaussians, and an *unbundled* capture — a
|
|
22
|
+
* `meta.json` beside its images, which is what `splat-transform` writes to a directory — arrives at
|
|
23
|
+
* the second half without the first. `browserWebpDecoder` is the ordinary decoder and is separate
|
|
24
|
+
* from both, for the reason `splatSog.ts` opens with: Node has none, and vendoring one is a
|
|
25
|
+
* thousand lines of VP8L this package will not carry.
|
|
26
|
+
*/
|
|
27
|
+
export { browserWebpDecoder } from './splatSogDecoder.js';
|
|
28
|
+
export { SOG_VERSION, readSogMeta, readSogSource, readSplatSog, unbundleSog } from './splatSog.js';
|
|
29
|
+
export { createSplatPass } from './splatPass.js';
|
|
30
|
+
export { SPLAT_STRIDE } from './splatLayout.js';
|
|
31
|
+
export { createSplatSortScratch, sortSplatsByDepth, SPLAT_SIZE_BUCKETS, SPLAT_SORT_BUCKETS, } from './splatSort.js';
|
|
32
|
+
export { SplatSorter, createDefaultSplatSort, sortOnMainThread } from './splatSorter.js';
|
|
33
|
+
export { createSplatViewLocal, resolveSplatView } from './splatView.js';
|
|
34
|
+
export { defaultSplatBudget, SPLAT_BUDGET_DEFAULT, SPLAT_BUDGET_WEAK } from './splatBudget.js';
|
|
35
|
+
export { splatBoundsVisible } from './splatCull.js';
|
|
36
|
+
/* A capture that fills up as its container blocks arrive, and the one-shot form of the same
|
|
37
|
+
assembly for a caller that read the whole file. */
|
|
38
|
+
export { SplatCapture, splatsFromRecords } from './splatCapture.js';
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export declare const SPLAT_FRAG_WGSL = "struct Uniforms {\n uOutputTransform: i32,\n uOutputExposure: f32,\n}\n\n@group(0) @binding(1) \nvar<uniform> unnamed: Uniforms;\nvar<private> vCorner_1: vec2<f32>;\nvar<private> vColor_1: vec4<f32>;\nvar<private> fragColor: vec4<f32>;\n\nfn linearToSrgb_u0028_vf3_u003b(c: ptr<function, vec3<f32>>) -> vec3<f32> {\n var low: vec3<f32>;\n var high: vec3<f32>;\n\n let _e54 = (*c);\n low = (_e54 * 12.92f);\n let _e56 = (*c);\n high = ((pow(max(_e56, vec3<f32>(0f, 0f, 0f)), vec3<f32>(0.41666666f, 0.41666666f, 0.41666666f)) * 1.055f) - vec3(0.055f));\n let _e62 = high;\n let _e63 = low;\n let _e64 = (*c);\n return mix(_e62, _e63, step(_e64, vec3<f32>(0.0031308f, 0.0031308f, 0.0031308f)));\n}\n\nfn rrtAndOdtFit_u0028_vf3_u003b(v: ptr<function, vec3<f32>>) -> vec3<f32> {\n var a: vec3<f32>;\n var b: vec3<f32>;\n\n let _e54 = (*v);\n let _e55 = (*v);\n a = ((_e54 * (_e55 + vec3(0.0245786f))) - vec3(0.000090537f));\n let _e61 = (*v);\n let _e62 = (*v);\n b = ((_e61 * ((_e62 * 0.983729f) + vec3(0.432951f))) + vec3(0.238081f));\n let _e69 = a;\n let _e70 = b;\n return (_e69 / _e70);\n}\n\nfn acesFilmic_u0028_vf3_u003b(x: ptr<function, vec3<f32>>) -> vec3<f32> {\n var param: vec3<f32>;\n\n let _e54 = unnamed.uOutputExposure;\n let _e55 = (*x);\n (*x) = (_e55 * _e54);\n let _e57 = (*x);\n param = (mat3x3<f32>(vec3<f32>(0.59719f, 0.076f, 0.0284f), vec3<f32>(0.35458f, 0.90834f, 0.13383f), vec3<f32>(0.04823f, 0.01566f, 0.83777f)) * _e57);\n let _e59 = rrtAndOdtFit_u0028_vf3_u003b((¶m));\n return clamp((mat3x3<f32>(vec3<f32>(1.60475f, -0.10208f, -0.00327f), vec3<f32>(-0.53108f, 1.10813f, -0.07276f), vec3<f32>(-0.07367f, -0.00605f, 1.07602f)) * _e59), vec3(0f), vec3(1f));\n}\n\nfn applyOutputTransform_u0028_vf3_u003b(c_1: ptr<function, vec3<f32>>) -> vec3<f32> {\n var param_1: vec3<f32>;\n var param_2: vec3<f32>;\n\n let _e55 = unnamed.uOutputTransform;\n if (_e55 == 0i) {\n let _e57 = (*c_1);\n return _e57;\n }\n let _e59 = unnamed.uOutputTransform;\n if (_e59 == 2i) {\n let _e61 = (*c_1);\n param_1 = _e61;\n let _e62 = acesFilmic_u0028_vf3_u003b((¶m_1));\n (*c_1) = _e62;\n }\n let _e63 = (*c_1);\n param_2 = _e63;\n let _e64 = linearToSrgb_u0028_vf3_u003b((¶m_2));\n return _e64;\n}\n\nfn main_1() {\n var power: f32;\n var alpha: f32;\n var colour: vec3<f32>;\n var param_3: vec3<f32>;\n\n let _e55 = vCorner_1;\n let _e56 = vCorner_1;\n power = dot(_e55, _e56);\n let _e59 = vColor_1[3u];\n let _e60 = power;\n alpha = (_e59 * exp((-0.5f * _e60)));\n let _e64 = alpha;\n if (_e64 < 0.003921569f) {\n discard;\n }\n let _e66 = vColor_1;\n param_3 = _e66.xyz;\n let _e68 = applyOutputTransform_u0028_vf3_u003b((¶m_3));\n colour = _e68;\n let _e69 = colour;\n let _e70 = alpha;\n let _e71 = (_e69 * _e70);\n let _e72 = alpha;\n fragColor = vec4<f32>(_e71.x, _e71.y, _e71.z, _e72);\n return;\n}\n\n@fragment \nfn main(@location(0) vCorner: vec2<f32>, @location(1) vColor: vec4<f32>) -> @location(0) vec4<f32> {\n vCorner_1 = vCorner;\n vColor_1 = vColor;\n main_1();\n let _e5 = fragColor;\n return _e5;\n}\n";
|
|
2
|
+
export declare const SPLAT_VERT_WGSL = "struct Uniforms {\n uSplatCount: i32,\n uSplatStride: i32,\n uSplatTexels: i32,\n uView: mat4x4<f32>,\n uProjection: mat4x4<f32>,\n uViewport: vec2<f32>,\n uModel: mat4x4<f32>,\n uSplatCameraLocal: vec3<f32>,\n uSplatShDegree: i32,\n}\n\nstruct gl_PerVertex {\n @builtin(position) gl_Position: vec4<f32>,\n gl_PointSize: f32,\n}\n\nstruct VertexOutput {\n @builtin(position) gl_Position: vec4<f32>,\n @location(0) member: vec2<f32>,\n @location(1) member_1: vec4<f32>,\n}\n\n@group(0) @binding(0) \nvar<uniform> unnamed: Uniforms;\n@group(0) @binding(16) \nvar uSplatData_t: texture_2d<u32>;\nvar<private> gl_VertexIndex_1: i32;\nvar<private> unnamed_1: gl_PerVertex = gl_PerVertex(vec4<f32>(0f, 0f, 0f, 1f), 1f);\nvar<private> vCorner: vec2<f32>;\nvar<private> vColor: vec4<f32>;\n@group(0) @binding(18) \nvar uSplatOrder_t: texture_2d<u32>;\n@group(0) @binding(17) \nvar uSplatData_s: sampler;\n@group(0) @binding(19) \nvar uSplatOrder_s: sampler;\n\nfn unpackRgba8_u0028_u1_u003b(packed: ptr<function, u32>) -> vec4<f32> {\n let _e50 = (*packed);\n let _e53 = (*packed);\n let _e58 = (*packed);\n let _e63 = (*packed);\n return (vec4<f32>(f32((_e50 & 255u)), f32(((_e53 >> bitcast<u32>(8i)) & 255u)), f32(((_e58 >> bitcast<u32>(16i)) & 255u)), f32(((_e63 >> bitcast<u32>(24i)) & 255u))) / vec4(255f));\n}\n\nfn viewDependentColour_u0028_vu4_u003b_vf3_u003b(sh: ptr<function, vec4<u32>>, direction: ptr<function, vec3<f32>>) -> vec3<f32> {\n var scale: f32;\n var a: vec4<f32>;\n var param: u32;\n var b: vec4<f32>;\n var param_1: u32;\n var c: vec4<f32>;\n var param_2: u32;\n var c0_: vec3<f32>;\n var c1_: vec3<f32>;\n var c2_: vec3<f32>;\n\n let _e62 = (*sh)[3u];\n scale = bitcast<f32>(_e62);\n let _e64 = scale;\n if (_e64 == 0f) {\n return vec3<f32>(0f, 0f, 0f);\n }\n let _e67 = (*sh)[0u];\n param = _e67;\n let _e68 = unpackRgba8_u0028_u1_u003b((¶m));\n a = _e68;\n let _e70 = (*sh)[1u];\n param_1 = _e70;\n let _e71 = unpackRgba8_u0028_u1_u003b((¶m_1));\n b = _e71;\n let _e73 = (*sh)[2u];\n param_2 = _e73;\n let _e74 = unpackRgba8_u0028_u1_u003b((¶m_2));\n c = _e74;\n let _e76 = a[0u];\n let _e78 = a[1u];\n let _e80 = a[2u];\n let _e87 = scale;\n c0_ = ((((vec3<f32>(_e76, _e78, _e80) * 255f) - vec3(128f)) / vec3(127f)) * _e87);\n let _e90 = a[3u];\n let _e92 = b[0u];\n let _e94 = b[1u];\n let _e101 = scale;\n c1_ = ((((vec3<f32>(_e90, _e92, _e94) * 255f) - vec3(128f)) / vec3(127f)) * _e101);\n let _e104 = b[2u];\n let _e106 = b[3u];\n let _e108 = c[0u];\n let _e115 = scale;\n c2_ = ((((vec3<f32>(_e104, _e106, _e108) * 255f) - vec3(128f)) / vec3(127f)) * _e115);\n let _e118 = (*direction)[1u];\n let _e120 = c0_;\n let _e123 = (*direction)[2u];\n let _e124 = c1_;\n let _e128 = (*direction)[0u];\n let _e129 = c2_;\n return ((((_e120 * -(_e118)) + (_e124 * _e123)) - (_e129 * _e128)) * 0.48860252f);\n}\n\nfn fetchTexel_u0028_i1_u003b_i1_u003b(splat: ptr<function, i32>, which: ptr<function, i32>) -> vec4<u32> {\n var at: i32;\n var width: i32;\n\n let _e53 = (*splat);\n let _e55 = unnamed.uSplatTexels;\n let _e57 = (*which);\n at = ((_e53 * _e55) + _e57);\n let _e60 = unnamed.uSplatStride;\n let _e62 = unnamed.uSplatTexels;\n width = (_e60 * _e62);\n let _e64 = at;\n let _e65 = width;\n let _e73 = at;\n let _e74 = width;\n let _e77 = textureLoad(uSplatData_t, vec2<i32>((_e64 - (i32(floor((f32(_e64) / f32(_e65)))) * _e65)), (_e73 / _e74)), 0i);\n return _e77;\n}\n\nfn main_1() {\n var vertex: i32;\n var slot: i32;\n var corner: i32;\n var splat_1: i32;\n var texel0_: vec4<u32>;\n var param_3: i32;\n var param_4: i32;\n var texel1_: vec4<u32>;\n var param_5: i32;\n var param_6: i32;\n var centre: vec3<f32>;\n var param_7: u32;\n var direction_1: vec3<f32>;\n var param_8: i32;\n var param_9: i32;\n var param_10: vec4<u32>;\n var param_11: vec3<f32>;\n var c01_: vec2<f32>;\n var c23_: vec2<f32>;\n var c45_: vec2<f32>;\n var sigma: mat3x3<f32>;\n var world: vec4<f32>;\n var view: vec4<f32>;\n var clip: vec4<f32>;\n var focalX: f32;\n var focalY: f32;\n var invZ: f32;\n var invZ2_: f32;\n var jacobian: mat3x2<f32>;\n var rotation: mat3x3<f32>;\n var world3_: mat3x3<f32>;\n var screen: mat2x2<f32>;\n var a_1: f32;\n var b_1: f32;\n var d: f32;\n var mid: f32;\n var discriminant: f32;\n var lambda1_: f32;\n var lambda2_: f32;\n var major: vec2<f32>;\n var minor: vec2<f32>;\n var radius1_: f32;\n var radius2_: f32;\n var offsets: array<vec2<f32>, 6>;\n var unit: vec2<f32>;\n var offsetPx: vec2<f32>;\n var phi_358_: bool;\n var phi_369_: bool;\n\n let _e95 = gl_VertexIndex_1;\n vertex = _e95;\n let _e96 = vertex;\n slot = (_e96 / 6i);\n let _e98 = vertex;\n corner = (_e98 - (i32(floor((f32(_e98) / f32(6i)))) * 6i));\n let _e106 = slot;\n let _e108 = unnamed.uSplatCount;\n if (_e106 >= _e108) {\n unnamed_1.gl_Position = vec4<f32>(2f, 2f, 2f, 1f);\n vCorner = vec2<f32>(0f, 0f);\n vColor = vec4<f32>(0f, 0f, 0f, 0f);\n return;\n }\n let _e111 = slot;\n let _e113 = unnamed.uSplatStride;\n let _e121 = slot;\n let _e123 = unnamed.uSplatStride;\n let _e126 = textureLoad(uSplatOrder_t, vec2<i32>((_e111 - (i32(floor((f32(_e111) / f32(_e113)))) * _e113)), (_e121 / _e123)), 0i);\n splat_1 = bitcast<i32>(_e126.x);\n let _e129 = splat_1;\n param_3 = _e129;\n param_4 = 0i;\n let _e130 = fetchTexel_u0028_i1_u003b_i1_u003b((¶m_3), (¶m_4));\n texel0_ = _e130;\n let _e131 = splat_1;\n param_5 = _e131;\n param_6 = 1i;\n let _e132 = fetchTexel_u0028_i1_u003b_i1_u003b((¶m_5), (¶m_6));\n texel1_ = _e132;\n let _e133 = texel0_;\n centre = bitcast<vec3<f32>>(_e133.xyz);\n let _e137 = texel0_[3u];\n param_7 = _e137;\n let _e138 = unpackRgba8_u0028_u1_u003b((¶m_7));\n vColor = _e138;\n let _e140 = unnamed.uSplatShDegree;\n if (_e140 > 0i) {\n let _e142 = centre;\n let _e144 = unnamed.uSplatCameraLocal;\n direction_1 = normalize((_e142 - _e144));\n let _e147 = vColor;\n let _e149 = splat_1;\n param_8 = _e149;\n param_9 = 2i;\n let _e150 = fetchTexel_u0028_i1_u003b_i1_u003b((¶m_8), (¶m_9));\n param_10 = _e150;\n let _e151 = direction_1;\n param_11 = _e151;\n let _e152 = viewDependentColour_u0028_vu4_u003b_vf3_u003b((¶m_10), (¶m_11));\n let _e154 = max((_e147.xyz + _e152), vec3<f32>(0f, 0f, 0f));\n let _e155 = vColor;\n vColor = vec4<f32>(_e154.x, _e154.y, _e154.z, _e155.w);\n }\n let _e162 = texel1_[0u];\n c01_ = unpack2x16float(_e162);\n let _e165 = texel1_[1u];\n c23_ = unpack2x16float(_e165);\n let _e168 = texel1_[2u];\n c45_ = unpack2x16float(_e168);\n let _e171 = c01_[0u];\n let _e173 = c01_[1u];\n let _e175 = c23_[0u];\n let _e177 = c01_[1u];\n let _e179 = c23_[1u];\n let _e181 = c45_[0u];\n let _e183 = c23_[0u];\n let _e185 = c45_[0u];\n let _e187 = c45_[1u];\n sigma = mat3x3<f32>(vec3<f32>(_e171, _e173, _e175), vec3<f32>(_e177, _e179, _e181), vec3<f32>(_e183, _e185, _e187));\n let _e193 = unnamed.uModel;\n let _e194 = centre;\n world = (_e193 * vec4<f32>(_e194.x, _e194.y, _e194.z, 1f));\n let _e201 = unnamed.uView;\n let _e202 = world;\n view = (_e201 * _e202);\n let _e205 = unnamed.uProjection;\n let _e206 = view;\n clip = (_e205 * _e206);\n let _e209 = view[2u];\n let _e210 = (_e209 > -0.01f);\n phi_358_ = _e210;\n if !(_e210) {\n let _e213 = clip[0u];\n let _e216 = clip[3u];\n phi_358_ = (abs(_e213) > (_e216 * 1.3f));\n }\n let _e220 = phi_358_;\n phi_369_ = _e220;\n if !(_e220) {\n let _e223 = clip[1u];\n let _e226 = clip[3u];\n phi_369_ = (abs(_e223) > (_e226 * 1.3f));\n }\n let _e230 = phi_369_;\n if _e230 {\n unnamed_1.gl_Position = vec4<f32>(2f, 2f, 2f, 1f);\n vCorner = vec2<f32>(0f, 0f);\n return;\n }\n let _e235 = unnamed.uProjection[0][0u];\n let _e238 = unnamed.uViewport[0u];\n focalX = ((_e235 * _e238) * 0.5f);\n let _e244 = unnamed.uProjection[1][1u];\n let _e247 = unnamed.uViewport[1u];\n focalY = ((_e244 * _e247) * 0.5f);\n let _e251 = view[2u];\n invZ = (1f / _e251);\n let _e253 = invZ;\n let _e254 = invZ;\n invZ2_ = (_e253 * _e254);\n let _e256 = focalX;\n let _e257 = invZ;\n let _e259 = focalY;\n let _e260 = invZ;\n let _e262 = focalX;\n let _e265 = view[0u];\n let _e267 = invZ2_;\n let _e269 = focalY;\n let _e272 = view[1u];\n let _e274 = invZ2_;\n jacobian = mat3x2<f32>(vec2<f32>((_e256 * _e257), 0f), vec2<f32>(0f, (_e259 * _e260)), vec2<f32>(((-(_e262) * _e265) * _e267), ((-(_e269) * _e272) * _e274)));\n let _e281 = unnamed.uView;\n let _e283 = unnamed.uModel;\n let _e284 = (_e281 * _e283);\n rotation = mat3x3<f32>(_e284[0].xyz, _e284[1].xyz, _e284[2].xyz);\n let _e292 = rotation;\n let _e293 = sigma;\n let _e295 = rotation;\n world3_ = ((_e292 * _e293) * transpose(_e295));\n let _e298 = jacobian;\n let _e299 = world3_;\n let _e301 = jacobian;\n screen = ((_e298 * _e299) * transpose(_e301));\n let _e306 = screen[0][0u];\n screen[0][0u] = (_e306 + 0.3f);\n let _e312 = screen[1][1u];\n screen[1][1u] = (_e312 + 0.3f);\n let _e318 = screen[0][0u];\n a_1 = _e318;\n let _e321 = screen[0][1u];\n b_1 = _e321;\n let _e324 = screen[1][1u];\n d = _e324;\n let _e325 = a_1;\n let _e326 = d;\n mid = (0.5f * (_e325 + _e326));\n let _e329 = mid;\n let _e330 = mid;\n let _e332 = a_1;\n let _e333 = d;\n let _e335 = b_1;\n let _e336 = b_1;\n discriminant = sqrt(max(0.1f, ((_e329 * _e330) - ((_e332 * _e333) - (_e335 * _e336)))));\n let _e342 = mid;\n let _e343 = discriminant;\n lambda1_ = (_e342 + _e343);\n let _e345 = mid;\n let _e346 = discriminant;\n lambda2_ = (_e345 - _e346);\n let _e348 = lambda2_;\n if (_e348 <= 0f) {\n unnamed_1.gl_Position = vec4<f32>(2f, 2f, 2f, 1f);\n vCorner = vec2<f32>(0f, 0f);\n return;\n }\n let _e351 = b_1;\n let _e352 = lambda1_;\n let _e353 = a_1;\n major = normalize(vec2<f32>(_e351, (_e352 - _e353)));\n let _e358 = major[1u];\n let _e361 = major[0u];\n minor = vec2<f32>(-(_e358), _e361);\n let _e363 = lambda1_;\n radius1_ = min((2f * sqrt(_e363)), 512f);\n let _e367 = lambda2_;\n radius2_ = min((2f * sqrt(_e367)), 512f);\n offsets = array<vec2<f32>, 6>(vec2<f32>(-1f, -1f), vec2<f32>(1f, -1f), vec2<f32>(-1f, 1f), vec2<f32>(-1f, 1f), vec2<f32>(1f, -1f), vec2<f32>(1f, 1f));\n let _e371 = corner;\n let _e373 = offsets[_e371];\n unit = _e373;\n let _e374 = unit;\n vCorner = (_e374 * 2f);\n let _e377 = unit[0u];\n let _e378 = major;\n let _e380 = radius1_;\n let _e383 = unit[1u];\n let _e384 = minor;\n let _e386 = radius2_;\n offsetPx = (((_e378 * _e377) * _e380) + ((_e384 * _e383) * _e386));\n let _e389 = clip;\n let _e391 = offsetPx;\n let _e393 = unnamed.uViewport;\n let _e397 = clip[3u];\n let _e399 = (_e389.xy + (((_e391 / _e393) * 2f) * _e397));\n let _e401 = clip[2u];\n let _e403 = clip[3u];\n unnamed_1.gl_Position = vec4<f32>(_e399.x, _e399.y, _e401, _e403);\n return;\n}\n\n@vertex \nfn main(@builtin(vertex_index) gl_VertexIndex: u32) -> VertexOutput {\n gl_VertexIndex_1 = i32(gl_VertexIndex);\n main_1();\n let _e8 = unnamed_1.gl_Position.y;\n unnamed_1.gl_Position.y = -(_e8);\n let _e10 = unnamed_1.gl_Position;\n let _e11 = vCorner;\n let _e12 = vColor;\n return VertexOutput(_e10, _e11, _e12);\n}\n";
|
|
3
|
+
/**
|
|
4
|
+
* What the transform assigned, so the renderer binds the same numbers.
|
|
5
|
+
*
|
|
6
|
+
* A permuted shader has one entry per variant, keyed as `FLAT_FRAG_WGSL` is.
|
|
7
|
+
*/
|
|
8
|
+
export declare const SPLAT_BINDINGS: {
|
|
9
|
+
readonly SPLAT_FRAG: {
|
|
10
|
+
readonly uniforms: 1;
|
|
11
|
+
readonly uniformSize: 16;
|
|
12
|
+
readonly fields: {
|
|
13
|
+
readonly uOutputTransform: {
|
|
14
|
+
readonly offset: 0;
|
|
15
|
+
readonly size: 4;
|
|
16
|
+
readonly type: "int";
|
|
17
|
+
};
|
|
18
|
+
readonly uOutputExposure: {
|
|
19
|
+
readonly offset: 4;
|
|
20
|
+
readonly size: 4;
|
|
21
|
+
readonly type: "float";
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
readonly textures: {};
|
|
25
|
+
};
|
|
26
|
+
readonly SPLAT_VERT: {
|
|
27
|
+
readonly uniforms: 0;
|
|
28
|
+
readonly uniformSize: 240;
|
|
29
|
+
readonly fields: {
|
|
30
|
+
readonly uSplatCount: {
|
|
31
|
+
readonly offset: 0;
|
|
32
|
+
readonly size: 4;
|
|
33
|
+
readonly type: "int";
|
|
34
|
+
};
|
|
35
|
+
readonly uSplatStride: {
|
|
36
|
+
readonly offset: 4;
|
|
37
|
+
readonly size: 4;
|
|
38
|
+
readonly type: "int";
|
|
39
|
+
};
|
|
40
|
+
readonly uSplatTexels: {
|
|
41
|
+
readonly offset: 8;
|
|
42
|
+
readonly size: 4;
|
|
43
|
+
readonly type: "int";
|
|
44
|
+
};
|
|
45
|
+
readonly uView: {
|
|
46
|
+
readonly offset: 16;
|
|
47
|
+
readonly size: 64;
|
|
48
|
+
readonly type: "mat4";
|
|
49
|
+
};
|
|
50
|
+
readonly uProjection: {
|
|
51
|
+
readonly offset: 80;
|
|
52
|
+
readonly size: 64;
|
|
53
|
+
readonly type: "mat4";
|
|
54
|
+
};
|
|
55
|
+
readonly uViewport: {
|
|
56
|
+
readonly offset: 144;
|
|
57
|
+
readonly size: 8;
|
|
58
|
+
readonly type: "vec2";
|
|
59
|
+
};
|
|
60
|
+
readonly uModel: {
|
|
61
|
+
readonly offset: 160;
|
|
62
|
+
readonly size: 64;
|
|
63
|
+
readonly type: "mat4";
|
|
64
|
+
};
|
|
65
|
+
readonly uSplatCameraLocal: {
|
|
66
|
+
readonly offset: 224;
|
|
67
|
+
readonly size: 12;
|
|
68
|
+
readonly type: "vec3";
|
|
69
|
+
};
|
|
70
|
+
readonly uSplatShDegree: {
|
|
71
|
+
readonly offset: 236;
|
|
72
|
+
readonly size: 4;
|
|
73
|
+
readonly type: "int";
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
readonly textures: {
|
|
77
|
+
readonly uSplatData: {
|
|
78
|
+
readonly texture: 16;
|
|
79
|
+
readonly sampler: 17;
|
|
80
|
+
readonly type: "usampler2D";
|
|
81
|
+
};
|
|
82
|
+
readonly uSplatOrder: {
|
|
83
|
+
readonly texture: 18;
|
|
84
|
+
readonly sampler: 19;
|
|
85
|
+
readonly type: "usampler2D";
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|