lightmap-studio 0.0.0-bootstrap.0 → 0.1.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 +24 -0
- package/README.md +226 -0
- package/dist/bake/environment.d.ts +17 -0
- package/dist/bake/environment.d.ts.map +1 -0
- package/dist/bake/environment.js +64 -0
- package/dist/bake/environment.js.map +1 -0
- package/dist/bake/gl.d.ts +16 -0
- package/dist/bake/gl.d.ts.map +1 -0
- package/dist/bake/gl.js +108 -0
- package/dist/bake/gl.js.map +1 -0
- package/dist/bake/harness.d.ts +11 -0
- package/dist/bake/harness.d.ts.map +1 -0
- package/dist/bake/harness.js +434 -0
- package/dist/bake/harness.js.map +1 -0
- package/dist/bake/shaders.d.ts +5 -0
- package/dist/bake/shaders.d.ts.map +1 -0
- package/dist/bake/shaders.js +73 -0
- package/dist/bake/shaders.js.map +1 -0
- package/dist/bake/stats.d.ts +3 -0
- package/dist/bake/stats.d.ts.map +1 -0
- package/dist/bake/stats.js +36 -0
- package/dist/bake/stats.js.map +1 -0
- package/dist/bake/types.d.ts +98 -0
- package/dist/bake/types.d.ts.map +1 -0
- package/dist/bake/types.js +16 -0
- package/dist/bake/types.js.map +1 -0
- package/dist/environment/index.d.ts +24 -0
- package/dist/environment/index.d.ts.map +1 -0
- package/dist/environment/index.js +332 -0
- package/dist/environment/index.js.map +1 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +18 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/lighting.d.ts +14 -0
- package/dist/lighting.d.ts.map +1 -0
- package/dist/lighting.js +152 -0
- package/dist/lighting.js.map +1 -0
- package/dist/loader.d.ts +12 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +84 -0
- package/dist/loader.js.map +1 -0
- package/dist/presets.d.ts +34 -0
- package/dist/presets.d.ts.map +1 -0
- package/dist/presets.js +106 -0
- package/dist/presets.js.map +1 -0
- package/dist/studio.d.ts +3 -0
- package/dist/studio.d.ts.map +1 -0
- package/dist/studio.js +268 -0
- package/dist/studio.js.map +1 -0
- package/dist/types.d.ts +220 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/unwrap/index.d.ts +17 -0
- package/dist/unwrap/index.d.ts.map +1 -0
- package/dist/unwrap/index.js +179 -0
- package/dist/unwrap/index.js.map +1 -0
- package/dist/unwrap/stats.d.ts +10 -0
- package/dist/unwrap/stats.d.ts.map +1 -0
- package/dist/unwrap/stats.js +16 -0
- package/dist/unwrap/stats.js.map +1 -0
- package/package.json +56 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to <https://unlicense.org/>
|
package/README.md
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# lightmap-studio
|
|
2
|
+
|
|
3
|
+
Engine-agnostic unwrapping and lightmap baking for the web, built on
|
|
4
|
+
[`xatlas-wasm`](https://github.com/mode777/xatlas-wasm) and
|
|
5
|
+
[`lightmapper-wasm`](https://github.com/mode777/lightmapper-wasm).
|
|
6
|
+
|
|
7
|
+
The studio owns the mesh-to-lightmap path: one shared xatlas atlas, a WebGL2
|
|
8
|
+
lightmapper bake, optional environment prefiltering, quality presets and a
|
|
9
|
+
plain-data result. It does not bundle three.js and does not export renderer
|
|
10
|
+
objects.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm install lightmap-studio
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`lightmapper-wasm` (minimum `0.2.0`) and `xatlas-wasm` are installed as direct
|
|
19
|
+
runtime dependencies. A bundler emits both wasm assets, and the loader resolves
|
|
20
|
+
them beside each dependency's published entry. Consumers do not need
|
|
21
|
+
Emscripten, CMake or a local `lightmapper-wasm` checkout.
|
|
22
|
+
|
|
23
|
+
The package is pre-1.0: the `0.1.x` line may change its API before `1.0`.
|
|
24
|
+
Changes follow the project's OpenSpec specifications.
|
|
25
|
+
|
|
26
|
+
## Quick start
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
import { createStudio } from "lightmap-studio";
|
|
30
|
+
|
|
31
|
+
const studio = await createStudio();
|
|
32
|
+
|
|
33
|
+
// Unwrap only (works without WebGL, including in Node).
|
|
34
|
+
const scene = await studio.unwrap(
|
|
35
|
+
[{ name: "floor", positions, normals, indices, albedo: [0.8, 0.8, 0.8] }],
|
|
36
|
+
{ size: 1024 }
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// Unwrap and bake.
|
|
40
|
+
const result = await studio.bake({
|
|
41
|
+
meshes: [
|
|
42
|
+
{ name: "floor", positions, normals, indices, albedo: [0.8, 0.8, 0.8] }
|
|
43
|
+
],
|
|
44
|
+
lighting: {
|
|
45
|
+
environment: { data, width, height, intensity: 1 },
|
|
46
|
+
ambient: [0, 0, 0],
|
|
47
|
+
emitters: [
|
|
48
|
+
{ name: "ceiling", positions, normals, indices, emissive: [6, 5, 4] }
|
|
49
|
+
],
|
|
50
|
+
points: [
|
|
51
|
+
{ position: [0, 2, 0], color: [1, 0.8, 0.6], power: 40, radius: 0.08 }
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
atlas: { size: 1024 },
|
|
55
|
+
quality: "preview"
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// result.scene.litObjects[i].uvs / positions / normals / indices / charts
|
|
59
|
+
// result.lightmap Float32Array, RGBA
|
|
60
|
+
// result.scene.atlas width, height, chartCount, utilization
|
|
61
|
+
// result.stats mean, min, max, nonBlackRatio, litPixels
|
|
62
|
+
// result.scene.emissiveObjects emitters and generated point proxies
|
|
63
|
+
studio.dispose();
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`bake` unwraps raw meshes and bakes them in one call. `unwrap` is the same
|
|
67
|
+
atlas step without a WebGL context. Inputs and outputs are typed arrays and
|
|
68
|
+
plain values; no three.js type crosses the boundary.
|
|
69
|
+
|
|
70
|
+
## Lighting model
|
|
71
|
+
|
|
72
|
+
The lightmapper integrates radiance from the geometry and sky drawn during each
|
|
73
|
+
hemisphere pass. The studio input reflects that:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
interface LightingInput {
|
|
77
|
+
environment?: EnvironmentInput; // the only sky source
|
|
78
|
+
ambient?: Vec3; // constant term, default black
|
|
79
|
+
emitters?: EmissiveMeshInput[]; // area lights, drawn during the bake
|
|
80
|
+
points?: PointLightInput[]; // expanded to emissive sphere proxies
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
There is **no directional-light input**. Sky lighting is supplied as linear
|
|
85
|
+
equirectangular data; a procedural sky is simply a generator that produces
|
|
86
|
+
that data.
|
|
87
|
+
|
|
88
|
+
A point light is:
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
interface PointLightInput {
|
|
92
|
+
position: Vec3;
|
|
93
|
+
color: Vec3;
|
|
94
|
+
power: number; // total radiant power in scene units
|
|
95
|
+
radius?: number; // proxy sphere radius, default 0.05
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The proxy sphere uses uniform radiance `power / (4 * pi^2 * radius^2)`. A small
|
|
100
|
+
radius gives sharper shadows and more sampling noise; a larger radius gives
|
|
101
|
+
softer area-light shadows. The generated proxy is returned in
|
|
102
|
+
`result.scene.emissiveObjects` with `source: "point"` so the caller can render
|
|
103
|
+
the same bulb.
|
|
104
|
+
|
|
105
|
+
`EnvironmentInput` is linear RGBA radiance in bottom-up row order: row 0 is the
|
|
106
|
+
south pole (`v = 0`), the last row is the north pole (`v = 1`). The studio
|
|
107
|
+
prefilters the environment to a 128x64 irradiance copy by default. Pass
|
|
108
|
+
`options.environmentPrefilter: false` to draw the full-resolution environment,
|
|
109
|
+
or `{ width, height, radius }` to control the copy.
|
|
110
|
+
|
|
111
|
+
## Wasm assets
|
|
112
|
+
|
|
113
|
+
Both modules load lazily: `createStudio()` fetches nothing, `unwrap()` loads
|
|
114
|
+
`xatlas.wasm`, and `bake()` probes WebGL2 and `EXT_color_buffer_float` before
|
|
115
|
+
loading `lightmapper.wasm`. A bundler that follows the packages' default
|
|
116
|
+
`new URL(...)` resolution emits both `.wasm` files as build assets. Override a
|
|
117
|
+
module with `wasm.xatlas` / `wasm.lightmapper` when the application serves the
|
|
118
|
+
assets from a custom location.
|
|
119
|
+
|
|
120
|
+
## Quality presets
|
|
121
|
+
|
|
122
|
+
| Preset | Atlas | Hemisphere | Bounces | Dilation | Smooth passes | Interpolation |
|
|
123
|
+
|---|---|---|---|---|---|---|
|
|
124
|
+
| `draft` | 512 | 32 | 1 | 4 | 1 | 1 |
|
|
125
|
+
| `preview` | 1024 | 64 | 2 | 8 | 1 | 2 |
|
|
126
|
+
| `final` | 1024 | 128 | 3 | 8 | 2 | 2 |
|
|
127
|
+
|
|
128
|
+
Explicit fields in `options` override the preset. Consumers can pass
|
|
129
|
+
per-scene values as overrides without changing the preset table.
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
studio.bake({
|
|
133
|
+
...scene,
|
|
134
|
+
quality: "final",
|
|
135
|
+
options: { bounces: 4, hemisphereWeight: "cosine", smoothPasses: 2 }
|
|
136
|
+
});
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`hemisphereWeight` defaults to the library's `uniform`; use `"cosine"` for
|
|
140
|
+
physically weighted diffuse sampling. The studio seeds the lightmapper's
|
|
141
|
+
rotation jitter before each bake, so repeated bakes of the same scene and
|
|
142
|
+
options are reproducible.
|
|
143
|
+
|
|
144
|
+
## Loader options
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
const studio = await createStudio({
|
|
148
|
+
gl, // optional existing context
|
|
149
|
+
canvas, // optional canvas to create the context from
|
|
150
|
+
wasm: {
|
|
151
|
+
lightmapper: { url: "/wasm/lightmapper.wasm" },
|
|
152
|
+
xatlas: { binary: preloadedBytes }
|
|
153
|
+
},
|
|
154
|
+
modules: {
|
|
155
|
+
// Optional: reuse modules you already initialized.
|
|
156
|
+
xatlas: existingXAtlasModule
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Resolution order per module: injected module, then `binary`, then `url`, then
|
|
162
|
+
the dependency's own default `new URL(...)` asset. Omit `wasm` to use the
|
|
163
|
+
package defaults.
|
|
164
|
+
|
|
165
|
+
Errors are `StudioError` instances with a `code` of `webgl2`, `float`,
|
|
166
|
+
`assets`, `validation`, `atlas`, `aborted`, `disposed`, `busy` or `bake`. The
|
|
167
|
+
original error is preserved as `cause`. Injected modules remain caller-owned
|
|
168
|
+
and are not disposed by the studio.
|
|
169
|
+
|
|
170
|
+
## Three-free display recipe
|
|
171
|
+
|
|
172
|
+
The result is a float RGBA lightmap and plain geometry. Any renderer can use
|
|
173
|
+
it. A three.js consumer can create a texture like this without the studio
|
|
174
|
+
depending on three:
|
|
175
|
+
|
|
176
|
+
```js
|
|
177
|
+
import * as THREE from "three";
|
|
178
|
+
|
|
179
|
+
const texture = new THREE.DataTexture(
|
|
180
|
+
result.lightmap,
|
|
181
|
+
result.width,
|
|
182
|
+
result.height,
|
|
183
|
+
THREE.RGBAFormat,
|
|
184
|
+
THREE.FloatType
|
|
185
|
+
);
|
|
186
|
+
texture.colorSpace = THREE.LinearSRGBColorSpace;
|
|
187
|
+
texture.minFilter = texture.magFilter = THREE.LinearFilter;
|
|
188
|
+
texture.wrapS = texture.wrapT = THREE.ClampToEdgeWrapping;
|
|
189
|
+
texture.generateMipmaps = false;
|
|
190
|
+
texture.needsUpdate = true;
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Use `result.scene.litObjects[i].uvs` as the lightmap UV attribute and multiply
|
|
194
|
+
the material albedo by the texture. Use `result.scene.emissiveObjects` for
|
|
195
|
+
emissive geometry and point proxies.
|
|
196
|
+
|
|
197
|
+
## Build and test
|
|
198
|
+
|
|
199
|
+
```sh
|
|
200
|
+
npm ci
|
|
201
|
+
npm run build
|
|
202
|
+
npm run typecheck
|
|
203
|
+
npm test # unit, unwrap, loader and import boundary
|
|
204
|
+
npm run test:consumer # pack → scratch Vite app → headless load
|
|
205
|
+
npm run test:pack # published tarball layout
|
|
206
|
+
CHROME_SHELL_PATH=... npm run test:headless
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
`test:consumer` installs the packed tarball, builds an application that
|
|
210
|
+
imports `lightmap-studio`, asserts that both wasm assets are emitted and
|
|
211
|
+
unwraps in headless Chrome. The headless suite covers the bake result,
|
|
212
|
+
point-light falloff, deterministic repeat bakes, abort, busy rejection, float
|
|
213
|
+
preflight and disposal. CI runs the same gates on Node 24 with pinned
|
|
214
|
+
`chrome-headless-shell` 131 and ANGLE SwiftShader.
|
|
215
|
+
|
|
216
|
+
## Releases
|
|
217
|
+
|
|
218
|
+
A `v<version>` tag runs the release workflow. The tag must equal the
|
|
219
|
+
`package.json` version; the workflow runs the build, unit, packed-consumer,
|
|
220
|
+
tarball and headless gates before publishing with provenance. If npm trusted
|
|
221
|
+
publishing is unavailable, configure an `NPM_TOKEN` repository secret; the
|
|
222
|
+
workflow then uses the token with the same gates.
|
|
223
|
+
|
|
224
|
+
## License
|
|
225
|
+
|
|
226
|
+
Unlicense. See [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Vec3 } from "../types.js";
|
|
2
|
+
import { type BakeEnvironment } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Validate an optional equirectangular environment before any GPU resource is
|
|
5
|
+
* created. The data is linear RGBA radiance in bottom-up row order.
|
|
6
|
+
*/
|
|
7
|
+
export declare function validateBakeEnvironment(environment: BakeEnvironment | undefined): void;
|
|
8
|
+
export declare function environmentIntensity(environment: BakeEnvironment): number;
|
|
9
|
+
/**
|
|
10
|
+
* Reconstruct a world-space direction for an NDC point from the lightmapper's
|
|
11
|
+
* view and projection matrices. The view matrix stores side/up/backward as its
|
|
12
|
+
* rows; zView = -1 gives the center ray along the hemisphere normal.
|
|
13
|
+
*/
|
|
14
|
+
export declare function rayDirectionForNdc(ndcX: number, ndcY: number, view: ArrayLike<number>, projection: ArrayLike<number>): Vec3;
|
|
15
|
+
/** Ray directions for the three vertices of the fullscreen skybox triangle. */
|
|
16
|
+
export declare function environmentRayDirections(view: ArrayLike<number>, projection: ArrayLike<number>): [Vec3, Vec3, Vec3];
|
|
17
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/bake/environment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7D;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI,CA+CtF;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,eAAe,GAAG,MAAM,CAEzE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,EACvB,UAAU,EAAE,SAAS,CAAC,MAAM,CAAC,GAC5B,IAAI,CAcN;AAED,+EAA+E;AAC/E,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,EACvB,UAAU,EAAE,SAAS,CAAC,MAAM,CAAC,GAC5B,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAMpB"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { BakeError } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Validate an optional equirectangular environment before any GPU resource is
|
|
4
|
+
* created. The data is linear RGBA radiance in bottom-up row order.
|
|
5
|
+
*/
|
|
6
|
+
export function validateBakeEnvironment(environment) {
|
|
7
|
+
if (!environment)
|
|
8
|
+
return;
|
|
9
|
+
const { width, height, data, intensity = 1 } = environment;
|
|
10
|
+
if (!Number.isInteger(width) || width <= 0) {
|
|
11
|
+
throw new BakeError(`environment width ${width} must be a positive integer`, "validation");
|
|
12
|
+
}
|
|
13
|
+
if (!Number.isInteger(height) || height <= 0) {
|
|
14
|
+
throw new BakeError(`environment height ${height} must be a positive integer`, "validation");
|
|
15
|
+
}
|
|
16
|
+
const expected = width * height * 4;
|
|
17
|
+
if (!data || data.length !== expected) {
|
|
18
|
+
throw new BakeError(`environment data length ${data?.length ?? "missing"} does not match ${width}x${height}x4 = ${expected}`, "validation");
|
|
19
|
+
}
|
|
20
|
+
for (let i = 0; i < data.length; i += 1) {
|
|
21
|
+
const value = data[i];
|
|
22
|
+
if (!Number.isFinite(value)) {
|
|
23
|
+
throw new BakeError(`environment data at index ${i} is not finite: ${value}`, "validation");
|
|
24
|
+
}
|
|
25
|
+
if (value < 0) {
|
|
26
|
+
throw new BakeError(`environment data at index ${i} is negative: ${value}`, "validation");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (!Number.isFinite(intensity) || intensity < 0) {
|
|
30
|
+
throw new BakeError(`environment intensity ${intensity} must be finite and non-negative`, "validation");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function environmentIntensity(environment) {
|
|
34
|
+
return environment.intensity ?? 1;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Reconstruct a world-space direction for an NDC point from the lightmapper's
|
|
38
|
+
* view and projection matrices. The view matrix stores side/up/backward as its
|
|
39
|
+
* rows; zView = -1 gives the center ray along the hemisphere normal.
|
|
40
|
+
*/
|
|
41
|
+
export function rayDirectionForNdc(ndcX, ndcY, view, projection) {
|
|
42
|
+
const xView = (ndcX + projection[8]) / projection[0];
|
|
43
|
+
const yView = (ndcY + projection[9]) / projection[5];
|
|
44
|
+
const zView = -1;
|
|
45
|
+
let x = view[0] * xView + view[1] * yView + view[2] * zView;
|
|
46
|
+
let y = view[4] * xView + view[5] * yView + view[6] * zView;
|
|
47
|
+
let z = view[8] * xView + view[9] * yView + view[10] * zView;
|
|
48
|
+
const length = Math.hypot(x, y, z);
|
|
49
|
+
if (length === 0)
|
|
50
|
+
return [0, 0, 0];
|
|
51
|
+
x /= length;
|
|
52
|
+
y /= length;
|
|
53
|
+
z /= length;
|
|
54
|
+
return [x, y, z];
|
|
55
|
+
}
|
|
56
|
+
/** Ray directions for the three vertices of the fullscreen skybox triangle. */
|
|
57
|
+
export function environmentRayDirections(view, projection) {
|
|
58
|
+
return [
|
|
59
|
+
rayDirectionForNdc(-1, -1, view, projection),
|
|
60
|
+
rayDirectionForNdc(3, -1, view, projection),
|
|
61
|
+
rayDirectionForNdc(-1, 3, view, projection)
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/bake/environment.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAwB,MAAM,YAAY,CAAC;AAE7D;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,WAAwC;IAC9E,IAAI,CAAC,WAAW;QAAE,OAAO;IAEzB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,CAAC,EAAE,GAAG,WAAW,CAAC;IAC3D,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,SAAS,CACjB,qBAAqB,KAAK,6BAA6B,EACvD,YAAY,CACb,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,SAAS,CACjB,sBAAsB,MAAM,6BAA6B,EACzD,YAAY,CACb,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC;IACpC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QACtC,MAAM,IAAI,SAAS,CACjB,2BAA2B,IAAI,EAAE,MAAM,IAAI,SAAS,mBAAmB,KAAK,IAAI,MAAM,QAAQ,QAAQ,EAA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AC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IAC5D,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IAC5D,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC;IAC7D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACnC,IAAI,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACnC,CAAC,IAAI,MAAM,CAAC;IACZ,CAAC,IAAI,MAAM,CAAC;IACZ,CAAC,IAAI,MAAM,CAAC;IACZ,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACnB,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,wBAAwB,CACtC,IAAuB,EACvB,UAA6B;IAE7B,OAAO;QACL,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC;QAC5C,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC;QAC3C,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC;KAC5C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare function compileShader(gl: WebGL2RenderingContext, type: number, source: string, label: string): WebGLShader;
|
|
2
|
+
export declare function createProgram(gl: WebGL2RenderingContext, vertexSource: string, fragmentSource: string): WebGLProgram;
|
|
3
|
+
export declare function requireUniform(gl: WebGL2RenderingContext, program: WebGLProgram, name: string): WebGLUniformLocation;
|
|
4
|
+
export interface BufferSet {
|
|
5
|
+
vao: WebGLVertexArrayObject;
|
|
6
|
+
positions: WebGLBuffer;
|
|
7
|
+
normals: WebGLBuffer;
|
|
8
|
+
uvs: WebGLBuffer;
|
|
9
|
+
indices: WebGLBuffer;
|
|
10
|
+
}
|
|
11
|
+
export declare function createBufferSet(gl: WebGL2RenderingContext, positions: Float32Array, normals: Float32Array, uvs: Float32Array, indices: Uint32Array): BufferSet;
|
|
12
|
+
export declare function deleteBufferSet(gl: WebGL2RenderingContext, buffers: BufferSet): void;
|
|
13
|
+
export declare function createFloatTexture(gl: WebGL2RenderingContext, width: number, height: number, data: Float32Array, filter: number): WebGLTexture;
|
|
14
|
+
export declare function uploadFloatTexture(gl: WebGL2RenderingContext, texture: WebGLTexture, width: number, height: number, data: Float32Array): void;
|
|
15
|
+
export declare function throwOnGlError(gl: WebGL2RenderingContext, label: string): void;
|
|
16
|
+
//# sourceMappingURL=gl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gl.d.ts","sourceRoot":"","sources":["../../src/bake/gl.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa,CAC3B,EAAE,EAAE,sBAAsB,EAC1B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,WAAW,CAWb;AAED,wBAAgB,aAAa,CAC3B,EAAE,EAAE,sBAAsB,EAC1B,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,GACrB,YAAY,CAsBd;AAED,wBAAgB,cAAc,CAC5B,EAAE,EAAE,sBAAsB,EAC1B,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,MAAM,GACX,oBAAoB,CAItB;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,sBAAsB,CAAC;IAC5B,SAAS,EAAE,WAAW,CAAC;IACvB,OAAO,EAAE,WAAW,CAAC;IACrB,GAAG,EAAE,WAAW,CAAC;IACjB,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,wBAAgB,eAAe,CAC7B,EAAE,EAAE,sBAAsB,EAC1B,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,YAAY,EACrB,GAAG,EAAE,YAAY,EACjB,OAAO,EAAE,WAAW,GACnB,SAAS,CAyCX;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,sBAAsB,EAAE,OAAO,EAAE,SAAS,GAAG,IAAI,CAMpF;AAED,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,sBAAsB,EAC1B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,MAAM,GACb,YAAY,CAWd;AAED,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,sBAAsB,EAC1B,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,YAAY,GACjB,IAAI,CAIN;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,sBAAsB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAK9E"}
|
package/dist/bake/gl.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { BakeError } from "./types.js";
|
|
2
|
+
export function compileShader(gl, type, source, label) {
|
|
3
|
+
const shader = gl.createShader(type);
|
|
4
|
+
if (!shader)
|
|
5
|
+
throw new BakeError(`could not create ${label} shader`, "gl");
|
|
6
|
+
gl.shaderSource(shader, source);
|
|
7
|
+
gl.compileShader(shader);
|
|
8
|
+
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
9
|
+
const log = gl.getShaderInfoLog(shader) ?? "(no compiler log)";
|
|
10
|
+
gl.deleteShader(shader);
|
|
11
|
+
throw new BakeError(`${label} shader compilation failed: ${log}`, "gl");
|
|
12
|
+
}
|
|
13
|
+
return shader;
|
|
14
|
+
}
|
|
15
|
+
export function createProgram(gl, vertexSource, fragmentSource) {
|
|
16
|
+
const vertex = compileShader(gl, gl.VERTEX_SHADER, vertexSource, "bake vertex");
|
|
17
|
+
const fragment = compileShader(gl, gl.FRAGMENT_SHADER, fragmentSource, "bake fragment");
|
|
18
|
+
const program = gl.createProgram();
|
|
19
|
+
if (!program) {
|
|
20
|
+
gl.deleteShader(vertex);
|
|
21
|
+
gl.deleteShader(fragment);
|
|
22
|
+
throw new BakeError("could not create bake shader program", "gl");
|
|
23
|
+
}
|
|
24
|
+
gl.attachShader(program, vertex);
|
|
25
|
+
gl.attachShader(program, fragment);
|
|
26
|
+
gl.linkProgram(program);
|
|
27
|
+
gl.deleteShader(vertex);
|
|
28
|
+
gl.deleteShader(fragment);
|
|
29
|
+
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
30
|
+
const log = gl.getProgramInfoLog(program) ?? "(no linker log)";
|
|
31
|
+
gl.deleteProgram(program);
|
|
32
|
+
throw new BakeError(`bake shader link failed: ${log}`, "gl");
|
|
33
|
+
}
|
|
34
|
+
return program;
|
|
35
|
+
}
|
|
36
|
+
export function requireUniform(gl, program, name) {
|
|
37
|
+
const location = gl.getUniformLocation(program, name);
|
|
38
|
+
if (!location)
|
|
39
|
+
throw new BakeError(`bake shader uniform ${name} is missing`, "gl");
|
|
40
|
+
return location;
|
|
41
|
+
}
|
|
42
|
+
export function createBufferSet(gl, positions, normals, uvs, indices) {
|
|
43
|
+
const vao = gl.createVertexArray();
|
|
44
|
+
const positionBuffer = gl.createBuffer();
|
|
45
|
+
const normalBuffer = gl.createBuffer();
|
|
46
|
+
const uvBuffer = gl.createBuffer();
|
|
47
|
+
const indexBuffer = gl.createBuffer();
|
|
48
|
+
if (!vao || !positionBuffer || !normalBuffer || !uvBuffer || !indexBuffer) {
|
|
49
|
+
throw new BakeError("could not allocate scene buffers", "gl");
|
|
50
|
+
}
|
|
51
|
+
gl.bindVertexArray(vao);
|
|
52
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
|
|
53
|
+
gl.bufferData(gl.ARRAY_BUFFER, positions, gl.STATIC_DRAW);
|
|
54
|
+
gl.enableVertexAttribArray(0);
|
|
55
|
+
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
|
|
56
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, normalBuffer);
|
|
57
|
+
gl.bufferData(gl.ARRAY_BUFFER, normals, gl.STATIC_DRAW);
|
|
58
|
+
gl.enableVertexAttribArray(1);
|
|
59
|
+
gl.vertexAttribPointer(1, 3, gl.FLOAT, false, 0, 0);
|
|
60
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, uvBuffer);
|
|
61
|
+
gl.bufferData(gl.ARRAY_BUFFER, uvs, gl.STATIC_DRAW);
|
|
62
|
+
gl.enableVertexAttribArray(2);
|
|
63
|
+
gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 0, 0);
|
|
64
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
|
|
65
|
+
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
|
|
66
|
+
gl.bindVertexArray(null);
|
|
67
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
68
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
|
|
69
|
+
return {
|
|
70
|
+
vao,
|
|
71
|
+
positions: positionBuffer,
|
|
72
|
+
normals: normalBuffer,
|
|
73
|
+
uvs: uvBuffer,
|
|
74
|
+
indices: indexBuffer
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export function deleteBufferSet(gl, buffers) {
|
|
78
|
+
gl.deleteVertexArray(buffers.vao);
|
|
79
|
+
gl.deleteBuffer(buffers.positions);
|
|
80
|
+
gl.deleteBuffer(buffers.normals);
|
|
81
|
+
gl.deleteBuffer(buffers.uvs);
|
|
82
|
+
gl.deleteBuffer(buffers.indices);
|
|
83
|
+
}
|
|
84
|
+
export function createFloatTexture(gl, width, height, data, filter) {
|
|
85
|
+
const texture = gl.createTexture();
|
|
86
|
+
if (!texture)
|
|
87
|
+
throw new BakeError("could not create lightmap texture", "gl");
|
|
88
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
89
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter);
|
|
90
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);
|
|
91
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
92
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
93
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, width, height, 0, gl.RGBA, gl.FLOAT, data);
|
|
94
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
95
|
+
return texture;
|
|
96
|
+
}
|
|
97
|
+
export function uploadFloatTexture(gl, texture, width, height, data) {
|
|
98
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
99
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, width, height, 0, gl.RGBA, gl.FLOAT, data);
|
|
100
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
101
|
+
}
|
|
102
|
+
export function throwOnGlError(gl, label) {
|
|
103
|
+
const error = gl.getError();
|
|
104
|
+
if (error !== gl.NO_ERROR) {
|
|
105
|
+
throw new BakeError(`${label}: GL error 0x${error.toString(16)}`, "gl");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=gl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gl.js","sourceRoot":"","sources":["../../src/bake/gl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,UAAU,aA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GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC5B,IAAI,KAAK,KAAK,EAAE,CAAC,QAAQ,EAAE,CAAC;QAC1B,MAAM,IAAI,SAAS,CAAC,GAAG,KAAK,gBAAgB,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type LightmapperModule } from "lightmapper-wasm";
|
|
2
|
+
import { type BakeHarnessOptions, type BakeOptions, type BakeSnapshot, type BakeScene } from "./types.js";
|
|
3
|
+
export interface BakeHarness {
|
|
4
|
+
bake(scene: BakeScene, options?: BakeOptions): Promise<BakeSnapshot>;
|
|
5
|
+
dispose(): void;
|
|
6
|
+
readonly gl: WebGL2RenderingContext;
|
|
7
|
+
readonly module: LightmapperModule;
|
|
8
|
+
readonly disposed: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function createBakeHarness(options?: BakeHarnessOptions): Promise<BakeHarness>;
|
|
11
|
+
//# sourceMappingURL=harness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harness.d.ts","sourceRoot":"","sources":["../../src/bake/harness.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAsBnF,OAAO,EAIL,KAAK,kBAAkB,EAGvB,KAAK,WAAW,EAEhB,KAAK,YAAY,EACjB,KAAK,SAAS,EAEf,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACrE,OAAO,IAAI,IAAI,CAAC;IAChB,QAAQ,CAAC,EAAE,EAAE,sBAAsB,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AA8BD,wBAAsB,iBAAiB,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,WAAW,CAAC,CA6W9F"}
|