@naanouff/w3dts-lightmapper 0.0.0-stage → 0.0.1
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/README.md +12 -3
- package/dist/atlasPostprocess.d.ts +37 -0
- package/dist/atlasPostprocess.d.ts.map +1 -0
- package/dist/bakeGiBounceComputeWgsl.d.ts +7 -0
- package/dist/bakeGiBounceComputeWgsl.d.ts.map +1 -0
- package/dist/bakeLighting.d.ts +18 -0
- package/dist/bakeLighting.d.ts.map +1 -0
- package/dist/bakeLightmapComputeWgsl.d.ts +7 -0
- package/dist/bakeLightmapComputeWgsl.d.ts.map +1 -0
- package/dist/bakeSceneAccel.d.ts +143 -0
- package/dist/bakeSceneAccel.d.ts.map +1 -0
- package/dist/base64.d.ts +11 -0
- package/dist/base64.d.ts.map +1 -0
- package/dist/buildUvGBuffer.d.ts +25 -0
- package/dist/buildUvGBuffer.d.ts.map +1 -0
- package/dist/classifyStatic.d.ts +10 -0
- package/dist/classifyStatic.d.ts.map +1 -0
- package/dist/clearLightingBake.d.ts +22 -0
- package/dist/clearLightingBake.d.ts.map +1 -0
- package/dist/collectBakeLights.d.ts +73 -0
- package/dist/collectBakeLights.d.ts.map +1 -0
- package/dist/constants.d.ts +20 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/cpuIrradianceBake.d.ts +65 -0
- package/dist/cpuIrradianceBake.d.ts.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lightmapperSceneExtension.d.ts +37 -0
- package/dist/lightmapperSceneExtension.d.ts.map +1 -0
- package/dist/packAtlasUv1.d.ts +36 -0
- package/dist/packAtlasUv1.d.ts.map +1 -0
- package/dist/packBakeLightsGpu.d.ts +5 -0
- package/dist/packBakeLightsGpu.d.ts.map +1 -0
- package/dist/planarUv1.d.ts +53 -0
- package/dist/planarUv1.d.ts.map +1 -0
- package/dist/prepareAtlas.d.ts +9 -0
- package/dist/prepareAtlas.d.ts.map +1 -0
- package/dist/probeVolume.d.ts +68 -0
- package/dist/probeVolume.d.ts.map +1 -0
- package/dist/restoreLightmapAtlas.d.ts +12 -0
- package/dist/restoreLightmapAtlas.d.ts.map +1 -0
- package/dist/runGpuBakeDirect.d.ts +28 -0
- package/dist/runGpuBakeDirect.d.ts.map +1 -0
- package/dist/runGpuBakeGiBounces.d.ts +17 -0
- package/dist/runGpuBakeGiBounces.d.ts.map +1 -0
- package/dist/softVisibility.d.ts +16 -0
- package/dist/softVisibility.d.ts.map +1 -0
- package/dist/types.d.ts +109 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/w3dts-lightmapper.es.js +3465 -0
- package/dist/w3dts-lightmapper.umd.js +855 -0
- package/package.json +49 -3
- package/shaders/bake_gi_bounce.compute.wgsl +255 -0
- package/shaders/bake_lightmap.compute.wgsl +599 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file index.ts
|
|
3
|
+
* @project w3dts
|
|
4
|
+
* @author Cyril TARRIET
|
|
5
|
+
* @date 2026-11-29
|
|
6
|
+
* @description @naanouff/w3dts-lightmapper public API.
|
|
7
|
+
*/
|
|
8
|
+
export { LIGHTMAP_ATLAS_PADDING, LIGHTMAP_ATLAS_SIZE, LIGHTMAP_DEFAULT_BOUNCES, LIGHTMAP_DEFAULT_SAMPLES, LIGHTMAP_TILE_SIZE, LIGHTMAPPER_EXTENSION_ID, LIGHTMAPPER_EXT_VERSION, } from './constants';
|
|
9
|
+
export type { BakeLightingOptions, BakeProgress, LightmapDenoiseGuides, LightmapperBakedEntity, LightmapperBakedReflectionProbe, LightmapperScenePayload, LightmapperSettings, LightmapperShVolume, PrepareAtlasChart, PrepareAtlasOptions, PrepareAtlasResult, } from './types';
|
|
10
|
+
export { collectBakeCandidateEntities, ensureStaticTags } from './classifyStatic';
|
|
11
|
+
export { packMeshesIntoAtlas } from './packAtlasUv1';
|
|
12
|
+
export type { ChartPack } from './packAtlasUv1';
|
|
13
|
+
export { prepareAtlas } from './prepareAtlas';
|
|
14
|
+
export { bakeLighting } from './bakeLighting';
|
|
15
|
+
export type { BakeLightingResult } from './bakeLighting';
|
|
16
|
+
export { clearLightingBake } from './clearLightingBake';
|
|
17
|
+
export type { ClearLightingBakeOptions, ClearLightingBakeResult } from './clearLightingBake';
|
|
18
|
+
export { bakeReflectionProbesPt, bakeShVolumeCpu, decodeShVolumeCoefficients, evalShL2Basis, evalShL2ProbeIrradiance, evalShVolumeIrradiance, packShVolumeUniformF32, placeAutoProbeVolume, SH_PROBE_VOLUME_MAX_PROBES, SH_PROBE_VOLUME_UNIFORM_FLOATS, } from './probeVolume';
|
|
19
|
+
export type { BakeReflectionProbesOptions, BakeShVolumeOptions, ProbeVolumeDesc, } from './probeVolume';
|
|
20
|
+
export { createLightmapperRuntimeState, createLightmapperSceneExtensionHandler, parseLightmapperScenePayload, } from './lightmapperSceneExtension';
|
|
21
|
+
export type { LightmapperRuntimeState } from './lightmapperSceneExtension';
|
|
22
|
+
export { restoreLightmapAtlasFromPayload } from './restoreLightmapAtlas';
|
|
23
|
+
export type { RestoreLightmapAtlasResult } from './restoreLightmapAtlas';
|
|
24
|
+
export { base64ToUint32, uint32ToBase64 } from './base64';
|
|
25
|
+
export { collectBakeLights, evalBakeIrradiance, makeCanonicalTangent } from './collectBakeLights';
|
|
26
|
+
export type { BakeLight, BakeOcclusionFn, EvalBakeIrradianceOptions } from './collectBakeLights';
|
|
27
|
+
export { bakeCpuIrradianceAtlas } from './cpuIrradianceBake';
|
|
28
|
+
export type { CpuIrradianceBakeOptions, CpuIrradianceBakeResult, IrradianceChart, } from './cpuIrradianceBake';
|
|
29
|
+
export { bakeRayClosestHit, bakeRayOccluded, buildBakeSceneAccel, computeVertexDiffuseAlbedos, hashSeedToUnitPair, hashTexel2d, packBakeSceneAccelGpu, sampleContactAo, sampleEmissiveCatalogDirect, sampleIndirectBounce, sampleSrgbImageLinear, updateBounceSrcFromAtlas, writeChartBounceSrc, } from './bakeSceneAccel';
|
|
30
|
+
export type { BakeRayHit, BakeSceneAccel, BuildBakeSceneAccelOptions, CpuSrgbImageLike, PackedGpuBakeBvh, SampleIndirectBounceOptions, } from './bakeSceneAccel';
|
|
31
|
+
export { softLightVisibility } from './softVisibility';
|
|
32
|
+
export type { SoftVisibilityOptions } from './softVisibility';
|
|
33
|
+
export { dilateAtlas, denoiseAtlas } from './atlasPostprocess';
|
|
34
|
+
export { ensurePlanarUv1 } from './planarUv1';
|
|
35
|
+
export { packBakeLightsGpu, BAKE_LIGHT_FLOATS } from './packBakeLightsGpu';
|
|
36
|
+
export { buildUvGBuffer } from './buildUvGBuffer';
|
|
37
|
+
export type { UvGBuffer, UvGBufferChart } from './buildUvGBuffer';
|
|
38
|
+
export { runGpuBakeDirect } from './runGpuBakeDirect';
|
|
39
|
+
export type { RunGpuBakeDirectOptions } from './runGpuBakeDirect';
|
|
40
|
+
export { runGpuBakeGiBounces } from './runGpuBakeGiBounces';
|
|
41
|
+
export type { RunGpuBakeGiBouncesOptions } from './runGpuBakeGiBounces';
|
|
42
|
+
export { BAKE_LIGHTMAP_COMPUTE_WGSL } from './bakeLightmapComputeWgsl';
|
|
43
|
+
export { BAKE_GI_BOUNCE_COMPUTE_WGSL } from './bakeGiBounceComputeWgsl';
|
|
44
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,mBAAmB,EACnB,YAAY,EACZ,qBAAqB,EACrB,sBAAsB,EACtB,+BAA+B,EAC/B,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,EACnB,iBAA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} from '@naanouff/w3dts-core';
|
|
2
|
+
import { LightmapperScenePayload } from './types';
|
|
3
|
+
export type LightmapperRuntimeState = {
|
|
4
|
+
lastPayload: LightmapperScenePayload | null;
|
|
5
|
+
};
|
|
6
|
+
export declare function createLightmapperRuntimeState(): LightmapperRuntimeState;
|
|
7
|
+
/**
|
|
8
|
+
* SceneDD handler. Serialize reads {@link LightmapperRuntimeState}; deserialize
|
|
9
|
+
* re-attaches {@link LightmapInstanceComponent} via entityMap when available,
|
|
10
|
+
* uploads atlas pages & SH L2 probe volume, and switches to the baked-interior graph preset.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createLightmapperSceneExtensionHandler(state: LightmapperRuntimeState): {
|
|
13
|
+
id: string;
|
|
14
|
+
serialize: (ctx: {
|
|
15
|
+
world: World;
|
|
16
|
+
entityToId?: ReadonlyMap<Entity, string>;
|
|
17
|
+
}) => LightmapperScenePayload | undefined;
|
|
18
|
+
deserialize: (payload: unknown, ctx: {
|
|
19
|
+
params: {
|
|
20
|
+
world: World;
|
|
21
|
+
resourceManager: import('@naanouff/w3dts-core').ResourceManager;
|
|
22
|
+
engine: {
|
|
23
|
+
webGPUContext: {
|
|
24
|
+
device: GPUDevice;
|
|
25
|
+
};
|
|
26
|
+
renderer: {
|
|
27
|
+
setLightmapAtlas: (tex: GPUTexture | null, strength?: number) => void;
|
|
28
|
+
setLightmapShVolume?: (uniformData: Float32Array | null) => void;
|
|
29
|
+
};
|
|
30
|
+
reloadGameRenderGraph?: () => Promise<void>;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
entityMap?: ReadonlyMap<string, Entity>;
|
|
34
|
+
}) => void | Promise<void>;
|
|
35
|
+
};
|
|
36
|
+
export declare function parseLightmapperScenePayload(raw: unknown): LightmapperScenePayload | undefined;
|
|
37
|
+
//# sourceMappingURL=lightmapperSceneExtension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lightmapperSceneExtension.d.ts","sourceRoot":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AC,IAAI,CAAC,CAAC;CAC3B,CAiFA;AAED,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,OAAO,GAAG,uBAAuB,GAAG,SAAS,CAE9F"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Mesh } from '@naanouff/w3dts-core';
|
|
2
|
+
export type ChartPack = {
|
|
3
|
+
mesh: Mesh;
|
|
4
|
+
entity: number;
|
|
5
|
+
surfaceArea: number;
|
|
6
|
+
/** Atlas UV bounds after packing. */
|
|
7
|
+
u0: number;
|
|
8
|
+
v0: number;
|
|
9
|
+
u1: number;
|
|
10
|
+
v1: number;
|
|
11
|
+
/** Bounding atlas pixel rect across all islands of this entity. */
|
|
12
|
+
px: number;
|
|
13
|
+
py: number;
|
|
14
|
+
pw: number;
|
|
15
|
+
ph: number;
|
|
16
|
+
uvScaleOffset: [number, number, number, number];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Unwraps (when needed) and packs all mesh UV islands across all candidate entities
|
|
20
|
+
* into a single lightmap atlas with uniform world-space texel density.
|
|
21
|
+
* Sets `mesh.bakedGeometryDirty = true` when UV1 is written.
|
|
22
|
+
*/
|
|
23
|
+
export declare function packMeshesIntoAtlas(entries: readonly {
|
|
24
|
+
entity: number;
|
|
25
|
+
mesh: Mesh;
|
|
26
|
+
worldScale?: readonly [number, number, number];
|
|
27
|
+
}[], options?: {
|
|
28
|
+
atlasSize?: number;
|
|
29
|
+
padding?: number;
|
|
30
|
+
texelsPerUnit?: number;
|
|
31
|
+
}): {
|
|
32
|
+
charts: ChartPack[];
|
|
33
|
+
texelsPerUnit: number;
|
|
34
|
+
atlasSize: number;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=packAtlasUv1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packAtlasUv1.d.ts","sourceRoot":"","sources":["../src/packAtlasUv1.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAmD,KAAK,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAIlG,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,mEAAmE;IACnE,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CACjD,CAAC;AAkCF;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,SAAS;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAChD,EAAE,EACH,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GACzE;IAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAgMnE"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BakeLight } from './collectBakeLights';
|
|
2
|
+
/** Serializes bake lights for `@binding(4) var<storage, read> lights`. */
|
|
3
|
+
export declare function packBakeLightsGpu(lights: readonly BakeLight[]): Float32Array;
|
|
4
|
+
export declare const BAKE_LIGHT_FLOATS = 16;
|
|
5
|
+
//# sourceMappingURL=packBakeLightsGpu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packBakeLightsGpu.d.ts","sourceRoot":"","sources":["../src/packBakeLightsGpu.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAI3E,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,GAAG,YAAY,CAyE5E;AAED,eAAO,MAAM,iBAAiB,KAAmB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Mesh } from '@naanouff/w3dts-core';
|
|
2
|
+
export interface PreBakeMeshSnapshot {
|
|
3
|
+
vertices: Float32Array;
|
|
4
|
+
indices: Uint16Array | Uint32Array;
|
|
5
|
+
hasAuthoredUv1: boolean;
|
|
6
|
+
morphPositionDeltaData?: Float32Array;
|
|
7
|
+
}
|
|
8
|
+
/** Per-mesh island generated in world-scaled metric space (meters). */
|
|
9
|
+
export interface UnwrappedUvIsland {
|
|
10
|
+
/** Indices into `mesh.vertices` belonging exclusively to this island. */
|
|
11
|
+
vertexIndices: Uint32Array;
|
|
12
|
+
/** Unpacked metric UV coordinates (2 floats per entry in `vertexIndices`). */
|
|
13
|
+
metricUvs: Float32Array;
|
|
14
|
+
u0: number;
|
|
15
|
+
v0: number;
|
|
16
|
+
u1: number;
|
|
17
|
+
v1: number;
|
|
18
|
+
/** World-space 3D surface area of all triangles in this island. */
|
|
19
|
+
worldArea: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Copies the pre-bake geometry snapshot from `source` to `clone` when isolating shared meshes.
|
|
23
|
+
*/
|
|
24
|
+
export declare function copyMeshLightmapSnapshot(source: Mesh, clone: Mesh): void;
|
|
25
|
+
/**
|
|
26
|
+
* Snapshots original mesh geometry + UV1 once, or restores them prior to re-baking
|
|
27
|
+
* so re-baking is 100% idempotent across resolution, scale, or texelsPerUnit changes.
|
|
28
|
+
*/
|
|
29
|
+
export declare function snapshotOrRestoreMeshOriginalUv1(mesh: Mesh): void;
|
|
30
|
+
/**
|
|
31
|
+
* Restores a mesh to its pre-bake geometry & UV1 state and clears snapshot metadata.
|
|
32
|
+
* Used by {@link clearLightingBake}.
|
|
33
|
+
*/
|
|
34
|
+
export declare function restoreMeshFromLightmapSnapshot(mesh: Mesh): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Unwraps a mesh into non-overlapping metric UV islands (splitting shared seam vertices
|
|
37
|
+
* across normal-chart boundaries when needed).
|
|
38
|
+
*
|
|
39
|
+
* When `mesh.hasAuthoredUv1` is already true prior to unwrapping, preserves authored `UV1`
|
|
40
|
+
* and returns a single island spanning the authored UV bounds.
|
|
41
|
+
*/
|
|
42
|
+
export declare function unwrapMeshLightmapIslands(mesh: Mesh, worldScale?: readonly [number, number, number]): {
|
|
43
|
+
generated: boolean;
|
|
44
|
+
islands: UnwrappedUvIsland[];
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Standalone helper: unwraps `mesh` into non-overlapping normalized `[0, 1]²` UV1 islands
|
|
48
|
+
* when `mesh.hasAuthoredUv1` is false. Returns true when UV1 was generated.
|
|
49
|
+
*/
|
|
50
|
+
export declare function ensurePlanarUv1(mesh: Mesh, options?: {
|
|
51
|
+
worldScale?: readonly [number, number, number];
|
|
52
|
+
}): boolean;
|
|
53
|
+
//# sourceMappingURL=planarUv1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planarUv1.d.ts","sourceRoot":"","sources":["../src/planarUv1.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAmD,KAAK,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAElG,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,EAAE,WAAW,GAAG,WAAW,CAAC;IACnC,cAAc,EAAE,OAAO,CAAC;IACxB,sBAAsB,CAAC,EAAE,YAAY,CAAC;CACvC;AAED,uEAAuE;AACvE,MAAM,WAAW,iBAAiB;IAChC,yEAAyE;IACzE,aAAa,EAAE,WAAW,CAAC;IAC3B,8EAA8E;IAC9E,SAAS,EAAE,YAAY,CAAC;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;CACnB;AAgBD;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAcxE;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CA+CjE;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CA0CnE;AA4CD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,IAAI,EACV,UAAU,GAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAa,GACxD;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,iBAAiB,EAAE,CAAA;CAAE,CAmVtD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,IAAI,EACV,OAAO,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAC3D,OAAO,CAgET"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { World, ResourceManager } from '@naanouff/w3dts-core';
|
|
2
|
+
import { PrepareAtlasOptions, PrepareAtlasResult } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Auto-classifies static meshes, clones shared Mesh instances so every baked entity
|
|
5
|
+
* receives non-overlapping world-scaled atlas UV1s, packs UV1 into one atlas,
|
|
6
|
+
* and attaches lightmap components.
|
|
7
|
+
*/
|
|
8
|
+
export declare function prepareAtlas(world: World, resourceManager?: ResourceManager, options?: PrepareAtlasOptions): PrepareAtlasResult;
|
|
9
|
+
//# sourceMappingURL=prepareAtlas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareAtlas.d.ts","sourceRoot":"","sources":["../src/prepareAtlas.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAOL,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AA6DvE;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,KAAK,EACZ,eAAe,CAAC,EAAE,eAAe,EACjC,OAAO,CAAC,EAAE,mBAAmB,GAC5B,kBAAkB,CA6FpB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ResourceManager, World } from '@naanouff/w3dts-core';
|
|
2
|
+
import { BakeSceneAccel } from './bakeSceneAccel';
|
|
3
|
+
import { BakeLight, BakeOcclusionFn } from './collectBakeLights';
|
|
4
|
+
import { LightmapperBakedReflectionProbe, LightmapperShVolume } from './types';
|
|
5
|
+
export type ProbeVolumeDesc = {
|
|
6
|
+
boundsMin: [number, number, number];
|
|
7
|
+
boundsMax: [number, number, number];
|
|
8
|
+
resolution: [number, number, number];
|
|
9
|
+
};
|
|
10
|
+
/** Max probes supported in `@group(3) @binding(20)` uniform buffer (`8 * 6 * 8 = 384`, 55,344 B < 64 KB). */
|
|
11
|
+
export declare const SH_PROBE_VOLUME_MAX_PROBES = 384;
|
|
12
|
+
export declare const SH_PROBE_VOLUME_UNIFORM_FLOATS: number;
|
|
13
|
+
/** Evaluates the 9 real orthonormal SH L2 basis functions at unit direction `d`. */
|
|
14
|
+
export declare function evalShL2Basis(d: readonly [number, number, number]): [number, number, number, number, number, number, number, number, number];
|
|
15
|
+
/**
|
|
16
|
+
* Evaluates clamped Ramamoorthi-Hanrahan SH L2 Lambertian irradiance `E(n) >= 0`
|
|
17
|
+
* from 27 packed float32 coefficients (`9 bands × RGB`) starting at `offset`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function evalShL2ProbeIrradiance(coeffs: Float32Array, offset: number, normal: readonly [number, number, number]): [number, number, number];
|
|
20
|
+
/** Decodes `coefficientsBase64` back into a `Float32Array` (`probeCount * 27`). */
|
|
21
|
+
export declare function decodeShVolumeCoefficients(shVolume: LightmapperShVolume): Float32Array;
|
|
22
|
+
/** Trilinearly interpolates SH L2 irradiance at `worldPos` for surface `normal`. */
|
|
23
|
+
export declare function evalShVolumeIrradiance(shVolume: LightmapperShVolume, coeffs: Float32Array, worldPos: readonly [number, number, number], normal: readonly [number, number, number]): [number, number, number];
|
|
24
|
+
/**
|
|
25
|
+
* Packs a {@link LightmapperShVolume} into the `@group(3) @binding(20)` uniform buffer layout:
|
|
26
|
+
* - `[0..3]`: `boundsMin.xyz`, `.w = enabled (1|0)`
|
|
27
|
+
* - `[4..7]`: `boundsMax.xyz`, `.w = strength`
|
|
28
|
+
* - `[8..11]`: `u32` `(rx, ry, rz, probeCount)` via `Uint32Array` view
|
|
29
|
+
* - `[12..]`: `probeCount * 9` `vec4<f32>` (`rgb = c_k, w = 0`)
|
|
30
|
+
*/
|
|
31
|
+
export declare function packShVolumeUniformF32(shVolume: LightmapperShVolume | null | undefined, strength?: number): Float32Array;
|
|
32
|
+
/**
|
|
33
|
+
* Builds a world-space AABB from static renderables and a ~1 m probe grid (clamped).
|
|
34
|
+
*/
|
|
35
|
+
export declare function placeAutoProbeVolume(world: World): ProbeVolumeDesc;
|
|
36
|
+
export type BakeShVolumeOptions = {
|
|
37
|
+
occluded?: BakeOcclusionFn;
|
|
38
|
+
/** World-space SAH BVH for indirect bounce & emissive ray gather. */
|
|
39
|
+
accel?: BakeSceneAccel | null;
|
|
40
|
+
/** Baked HDR RGBA lightmap atlas (`atlasSize * atlasSize * 4`) for hit radiosity lookup. */
|
|
41
|
+
atlasRgba?: Float32Array;
|
|
42
|
+
atlasSize?: number;
|
|
43
|
+
/** Sky / HDRI radiance when a probe ray escapes the scene (`!hit`). */
|
|
44
|
+
skyRadiance?: readonly [number, number, number];
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Full 9-band SH L2 projection across the 3D probe grid using 64 Fibonacci directions:
|
|
48
|
+
* - Projects direct punctual/directional/area lighting analytically onto `SH L2` (with shadow rays),
|
|
49
|
+
* - Projects scene indirect GI (`atlasRgba` + `accel` + emissive surfaces + `skyRadiance`) via
|
|
50
|
+
* 64-ray spherical quadrature so `L0`, `L1`, AND `L2` bands capture true directional & Color-Bleed GI!
|
|
51
|
+
*/
|
|
52
|
+
export declare function bakeShVolumeCpu(volume: ProbeVolumeDesc, ambient: readonly [number, number, number], lights?: readonly BakeLight[], occludedOrOptions?: BakeOcclusionFn | BakeShVolumeOptions): LightmapperShVolume;
|
|
53
|
+
export type BakeReflectionProbesOptions = {
|
|
54
|
+
accel?: BakeSceneAccel | null;
|
|
55
|
+
atlasRgba?: Float32Array;
|
|
56
|
+
atlasSize?: number;
|
|
57
|
+
ambient?: readonly [number, number, number];
|
|
58
|
+
skyRadiance?: readonly [number, number, number];
|
|
59
|
+
faceSize?: number;
|
|
60
|
+
device?: GPUDevice;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Ray-traces static 6-face HDR `rgb9e5ufloat` cubemaps for every visible `ReflectionProbeComponent`
|
|
64
|
+
* entity using the baked GI scene acceleration & atlas, registering textures in `ResourceManager`
|
|
65
|
+
* when a `GPUDevice` is available (KPTL-8).
|
|
66
|
+
*/
|
|
67
|
+
export declare function bakeReflectionProbesPt(world: World, resourceManager: ResourceManager | undefined, options?: BakeReflectionProbesOptions): LightmapperBakedReflectionProbe[];
|
|
68
|
+
//# sourceMappingURL=probeVolume.d.ts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,CAAC;IACnB,OAAO,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,WAAW,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,KAAK,EACZ,eAAe,EAAE,eAAe,GAAG,SAAS,EAC5C,OAAO,CAAC,EAAE,2BAA2B,GACpC,+BAA+B,EAAE,CAyGnC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ResourceManager } from '@naanouff/w3dts-core';
|
|
2
|
+
import { LightmapperScenePayload } from './types';
|
|
3
|
+
export type RestoreLightmapAtlasResult = {
|
|
4
|
+
textures: GPUTexture[];
|
|
5
|
+
atlasSize: number;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Creates `rgb9e5ufloat` GPU textures from {@link LightmapperScenePayload.atlasPagesBase64}
|
|
9
|
+
* and registers them on the resource manager. Returns [] when pages are missing.
|
|
10
|
+
*/
|
|
11
|
+
export declare function restoreLightmapAtlasFromPayload(device: GPUDevice, resourceManager: ResourceManager, payload: LightmapperScenePayload): RestoreLightmapAtlasResult;
|
|
12
|
+
//# sourceMappingURL=restoreLightmapAtlas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restoreLightmapAtlas.d.ts","sourceRoot":"","sources":["../src/restoreLightmapAtlas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,SAAS,EACjB,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,uBAAuB,GAC/B,0BAA0B,CAsC5B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BakeSceneAccel } from './bakeSceneAccel';
|
|
2
|
+
import { BakeLight } from './collectBakeLights';
|
|
3
|
+
import { UvGBuffer } from './buildUvGBuffer';
|
|
4
|
+
export type RunGpuBakeDirectOptions = {
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
ambient?: readonly [number, number, number];
|
|
7
|
+
/** Tile edge; default {@link LIGHTMAP_TILE_SIZE}. */
|
|
8
|
+
tileSize?: number;
|
|
9
|
+
/** Optional scene BVH; when supplied, traces GPU soft-penumbra shadow rays + smooth contact AO. */
|
|
10
|
+
accel?: BakeSceneAccel | null;
|
|
11
|
+
/** Soft shadow rays per light (default 8 when `accel` is supplied). */
|
|
12
|
+
softShadowSamples?: number;
|
|
13
|
+
/** Contact AO rays per texel stored in output `.a` (default 8 when `accel` is supplied, 0 disables). */
|
|
14
|
+
aoSamples?: number;
|
|
15
|
+
/** Contact AO radius in world meters (default 0.45). */
|
|
16
|
+
aoRadius?: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Runs the GPU direct + AO kernel over {@link gbuffer} and returns linear RGBA float32
|
|
20
|
+
* (`rgb = shadowed direct irradiance`, `a = contact AO in [0.05..1]` on covered texels, `0` uncovered).
|
|
21
|
+
*/
|
|
22
|
+
export declare function runGpuBakeDirect(device: GPUDevice, gbuffer: UvGBuffer, lights: readonly BakeLight[], options?: RunGpuBakeDirectOptions): Promise<Float32Array>;
|
|
23
|
+
/** Fresh ArrayBuffer-backed view for WebGPU BufferSource typing. */
|
|
24
|
+
export declare function float32ToBufferSource(data: Float32Array): Uint8Array<ArrayBuffer>;
|
|
25
|
+
export declare function unpackFloat16(h: number): number;
|
|
26
|
+
/** Finish encoder with copy + map read of rgba16float → float32 RGBA. */
|
|
27
|
+
export declare function readbackRgba16(device: GPUDevice, encoder: GPUCommandEncoder, texture: GPUTexture, atlasSize: number): Promise<Float32Array>;
|
|
28
|
+
//# sourceMappingURL=runGpuBakeDirect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runGpuBakeDirect.d.ts","sourceRoot":"","sources":["../src/runGpuBakeDirect.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAKlD,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mGAAmG;IACnG,KAAK,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B,uEAAuE;IACvE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,wGAAwG;IACxG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,SAAS,EAClB,MAAM,EAAE,SAAS,SAAS,EAAE,EAC5B,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,YAAY,CAAC,CA8JvB;AAED,oEAAoE;AACpE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,YAAY,GAAG,UAAU,CAAC,WAAW,CAAC,CAKjF;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAO/C;AAED,yEAAyE;AACzE,wBAAsB,cAAc,CAClC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,UAAU,EACnB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,YAAY,CAAC,CAsCvB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BakeSceneAccel } from './bakeSceneAccel';
|
|
2
|
+
import { UvGBuffer } from './buildUvGBuffer';
|
|
3
|
+
export type RunGpuBakeGiBouncesOptions = {
|
|
4
|
+
signal?: AbortSignal;
|
|
5
|
+
bounces: number;
|
|
6
|
+
bounceSamples?: number;
|
|
7
|
+
maxDist?: number;
|
|
8
|
+
skyRadiance?: readonly [number, number, number];
|
|
9
|
+
denoise?: boolean;
|
|
10
|
+
onBounceComplete?: (bounceIndex: number) => void;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Evaluates `bounces` indirect GI passes on the GPU and returns accumulated linear RGBA float32
|
|
14
|
+
* (`rgb = total multi-bounce indirect irradiance`, `a = 1` on covered texels).
|
|
15
|
+
*/
|
|
16
|
+
export declare function runGpuBakeGiBounces(device: GPUDevice, gbuffer: UvGBuffer, accel: BakeSceneAccel, directRgba: Float32Array, coveredIndices: Uint32Array, options: RunGpuBakeGiBouncesOptions): Promise<Float32Array>;
|
|
17
|
+
//# sourceMappingURL=runGpuBakeGiBounces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runGpuBakeGiBounces.d.ts","sourceRoot":"","sources":["../src/runGpuBakeGiBounces.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,MAAM,MAAM,0BAA0B,GAAG;IACvC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAChD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD,CAAC;AAiBF;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,cAAc,EACrB,UAAU,EAAE,YAAY,EACxB,cAAc,EAAE,WAAW,EAC3B,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,YAAY,CAAC,CAgOvB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BakeLight, BakeOcclusionFn } from './collectBakeLights';
|
|
2
|
+
export type SoftVisibilityOptions = {
|
|
3
|
+
/** Samples for soft penumbra. Default 6. */
|
|
4
|
+
samples?: number;
|
|
5
|
+
/** Sun angular radius (radians). Default ~0.012 (~0.68° soft daylight penumbra). */
|
|
6
|
+
sunAngularRadius?: number;
|
|
7
|
+
/** Physical emitter radius (meters) for point & spot lights. Default 0.065. */
|
|
8
|
+
pointLightRadius?: number;
|
|
9
|
+
/** Deterministic per-texel hash seed for Cranley-Patterson rotation. */
|
|
10
|
+
jitterSeed?: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Visibility in [0,1] with stratified disk / cone sampling and per-texel Cranley-Patterson rotation.
|
|
14
|
+
*/
|
|
15
|
+
export declare function softLightVisibility(light: BakeLight, origin: readonly [number, number, number], toLightCenter: readonly [number, number, number], maxDist: number, occluded: BakeOcclusionFn | undefined, options?: SoftVisibilityOptions): number;
|
|
16
|
+
//# sourceMappingURL=softVisibility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"softVisibility.d.ts","sourceRoot":"","sources":["../src/softVisibility.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtE,MAAM,MAAM,qBAAqB,GAAG;IAClC,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oFAAoF;IACpF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,+EAA+E;IAC/E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAgBF;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EACzC,aAAa,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAChD,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,eAAe,GAAG,SAAS,EACrC,OAAO,CAAC,EAAE,qBAAqB,GAC9B,MAAM,CA8ER"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { LIGHTMAPPER_EXT_VERSION } from './constants';
|
|
2
|
+
export type LightmapperSettings = {
|
|
3
|
+
texelsPerUnit: number;
|
|
4
|
+
bounces: number;
|
|
5
|
+
samplesPerTexel: number;
|
|
6
|
+
atlasSize: number;
|
|
7
|
+
};
|
|
8
|
+
export type LightmapperBakedEntity = {
|
|
9
|
+
atlasIndex: number;
|
|
10
|
+
uvScaleOffset: [number, number, number, number];
|
|
11
|
+
};
|
|
12
|
+
export type LightmapperShVolume = {
|
|
13
|
+
boundsMin: [number, number, number];
|
|
14
|
+
boundsMax: [number, number, number];
|
|
15
|
+
resolution: [number, number, number];
|
|
16
|
+
/** Float32 SH L2 coefficients (9 × vec3 per probe), base64. */
|
|
17
|
+
coefficientsBase64: string;
|
|
18
|
+
};
|
|
19
|
+
export type LightmapperBakedReflectionProbe = {
|
|
20
|
+
entityId: string;
|
|
21
|
+
faceTextureIds: [string, string, string, string, string, string];
|
|
22
|
+
faceSize?: number;
|
|
23
|
+
/** Optional packed `rgb9e5ufloat` face payloads (Uint32 LE -> base64) for SceneDD persistence. */
|
|
24
|
+
facesBase64?: [string, string, string, string, string, string];
|
|
25
|
+
};
|
|
26
|
+
export type LightmapperScenePayload = {
|
|
27
|
+
extVersion: typeof LIGHTMAPPER_EXT_VERSION;
|
|
28
|
+
settings: LightmapperSettings;
|
|
29
|
+
atlasTextureIds: string[];
|
|
30
|
+
/**
|
|
31
|
+
* Packed `rgb9e5ufloat` atlas pages (Uint32 LE -> base64), one entry per
|
|
32
|
+
* {@link atlasTextureIds} index. Required for scenepak reload without rebake.
|
|
33
|
+
*/
|
|
34
|
+
atlasPagesBase64?: string[];
|
|
35
|
+
bakedEntities: Record<string, LightmapperBakedEntity>;
|
|
36
|
+
shVolumes: LightmapperShVolume[];
|
|
37
|
+
bakedReflectionProbes: LightmapperBakedReflectionProbe[];
|
|
38
|
+
};
|
|
39
|
+
export type PrepareAtlasOptions = {
|
|
40
|
+
atlasSize?: number;
|
|
41
|
+
padding?: number;
|
|
42
|
+
/** Target texels per world unit; density is reduced to fit one atlas. */
|
|
43
|
+
texelsPerUnit?: number;
|
|
44
|
+
};
|
|
45
|
+
export type PrepareAtlasChart = {
|
|
46
|
+
entity: number;
|
|
47
|
+
atlasIndex: number;
|
|
48
|
+
uvScaleOffset: [number, number, number, number];
|
|
49
|
+
surfaceArea: number;
|
|
50
|
+
/** Mesh with UV1 already written in atlas space. */
|
|
51
|
+
mesh: import('@naanouff/w3dts-core').Mesh;
|
|
52
|
+
px: number;
|
|
53
|
+
py: number;
|
|
54
|
+
pw: number;
|
|
55
|
+
ph: number;
|
|
56
|
+
};
|
|
57
|
+
export type PrepareAtlasResult = {
|
|
58
|
+
atlasSize: number;
|
|
59
|
+
texelsPerUnit: number;
|
|
60
|
+
entities: Array<{
|
|
61
|
+
entity: number;
|
|
62
|
+
atlasIndex: number;
|
|
63
|
+
uvScaleOffset: [number, number, number, number];
|
|
64
|
+
surfaceArea: number;
|
|
65
|
+
}>;
|
|
66
|
+
charts: PrepareAtlasChart[];
|
|
67
|
+
};
|
|
68
|
+
export type BakeProgress = {
|
|
69
|
+
phase: 'prepare' | 'gbuffer' | 'irradiance' | 'dilate' | 'denoise' | 'encode' | 'probes' | 'done';
|
|
70
|
+
completed: number;
|
|
71
|
+
total: number;
|
|
72
|
+
};
|
|
73
|
+
export type LightmapDenoiseGuides = {
|
|
74
|
+
/** RGBA float32 (`atlasSize * atlasSize * 4`): xyz = linear diffuse albedo, a = coverage. */
|
|
75
|
+
albedo: Float32Array;
|
|
76
|
+
/** RGBA float32 (`atlasSize * atlasSize * 4`): xyz = unit world normal, a = coverage. */
|
|
77
|
+
normal: Float32Array;
|
|
78
|
+
};
|
|
79
|
+
export type BakeLightingOptions = {
|
|
80
|
+
settings?: Partial<LightmapperSettings>;
|
|
81
|
+
signal?: AbortSignal;
|
|
82
|
+
onProgress?: (p: BakeProgress) => void;
|
|
83
|
+
/** Ambient irradiance used in direct lighting and probe fallback. */
|
|
84
|
+
ambientIrradiance?: [number, number, number];
|
|
85
|
+
/** Sky / HDRI radiance added when GI bounce or probe rays escape the scene (`!hit`). */
|
|
86
|
+
skyRadiance?: [number, number, number];
|
|
87
|
+
/** Hemisphere AO samples per texel (0 disables). Default 6. */
|
|
88
|
+
aoSamples?: number;
|
|
89
|
+
/** AO ray length in world units. Default 0.45. */
|
|
90
|
+
aoRadius?: number;
|
|
91
|
+
/** Enable geometry-guided À-Trous & bilateral denoising. Default true. */
|
|
92
|
+
denoise?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Optional HDR neural denoise (e.g. oidn-web). Receives the pre-dilation RGBA atlas and
|
|
95
|
+
* optional auxiliary `albedo` + `normal` guides (`rt_hdr_alb_nrm_small.tza`).
|
|
96
|
+
*/
|
|
97
|
+
denoiseHdr?: (rgba: Float32Array, atlasSize: number, signal?: AbortSignal, guides?: LightmapDenoiseGuides) => Promise<Float32Array | null>;
|
|
98
|
+
/**
|
|
99
|
+
* Run GPU direct + AO compute kernel (`bake_lightmap.compute.wgsl`) when `device` is supplied.
|
|
100
|
+
* Defaults to `true` when `device` is present; falls back to CPU on error.
|
|
101
|
+
*/
|
|
102
|
+
gpuDirect?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Run GPU multi-bounce GI compute kernel (`bake_gi_bounce.compute.wgsl`) when `device` is supplied.
|
|
105
|
+
* Defaults to `true` when `device` is present; falls back to CPU on error.
|
|
106
|
+
*/
|
|
107
|
+
gpuBounces?: boolean;
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,MAAM,mBAAmB,GAAG;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,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