@woosh/meep-engine 2.165.0 → 2.165.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -108
- package/build/bundle-worker-image-decoder.js +1 -1
- package/package.json +1 -1
- package/samples/generation/SampleGenerator0.js +3 -3
- package/samples/generation/filters/SampleGroundMoistureFilter.js +63 -56
- package/samples/generation/filters/SampleNoise20_0.js +6 -1
- package/samples/generation/themes/SampleTheme0.js +47 -47
- package/src/core/color/YCoCg/rgb_to_ycocg.d.ts +17 -0
- package/src/core/color/YCoCg/rgb_to_ycocg.d.ts.map +1 -0
- package/src/core/color/YCoCg/rgb_to_ycocg.js +20 -0
- package/src/core/color/YCoCg/ycocg_to_rgb.d.ts +14 -0
- package/src/core/color/YCoCg/ycocg_to_rgb.d.ts.map +1 -0
- package/src/core/color/YCoCg/ycocg_to_rgb.js +17 -0
- package/src/engine/REVIEW_2026_07_03.md +211 -0
- package/src/engine/animation/curve/actionProcessorOperations/curveActions.d.ts.map +1 -1
- package/src/engine/animation/curve/actionProcessorOperations/curveActions.js +3 -2
- package/src/engine/animation/curve/compression/sample_animation_curve_to_float_array.js +1 -1
- package/src/engine/animation/keyed2/AnimationTrackPlayback.d.ts.map +1 -1
- package/src/engine/animation/keyed2/AnimationTrackPlayback.js +3 -1
- package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.js +2 -2
- package/src/engine/asset/preloader/AssetPreloader.d.ts.map +1 -1
- package/src/engine/asset/preloader/AssetPreloader.js +6 -0
- package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.d.ts.map +1 -1
- package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.js +5 -2
- package/src/engine/ecs/Entity.js +1 -1
- package/src/engine/ecs/EntityComponentDataset.d.ts.map +1 -1
- package/src/engine/ecs/EntityComponentDataset.js +1 -0
- package/src/engine/ecs/EntityManager.d.ts.map +1 -1
- package/src/engine/ecs/EntityManager.js +12 -8
- package/src/engine/ecs/EntityObserver.js +1 -1
- package/src/engine/ecs/System.d.ts.map +1 -1
- package/src/engine/ecs/System.js +4 -0
- package/src/engine/ecs/animation/AnimationClip.js +1 -1
- package/src/engine/ecs/attachment/AttachmentSystem.js +2 -2
- package/src/engine/ecs/attachment/TransformAttachmentBinding.d.ts.map +1 -1
- package/src/engine/ecs/attachment/TransformAttachmentBinding.js +11 -0
- package/src/engine/ecs/fow/FogOfWar.js +2 -2
- package/src/engine/ecs/fow/shader/screenSpaceFogOfWarShader.d.ts.map +1 -1
- package/src/engine/ecs/fow/shader/screenSpaceFogOfWarShader.js +27 -9
- package/src/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +1 -1
- package/src/engine/ecs/gui/position/ViewportPosition.d.ts +3 -1
- package/src/engine/ecs/gui/position/ViewportPosition.d.ts.map +1 -1
- package/src/engine/ecs/gui/position/ViewportPosition.js +4 -1
- package/src/engine/ecs/storage/binary/BinarySerializationRegistry.d.ts +10 -0
- package/src/engine/ecs/storage/binary/BinarySerializationRegistry.d.ts.map +1 -1
- package/src/engine/ecs/storage/binary/BinarySerializationRegistry.js +43 -0
- package/src/engine/ecs/storage/binary/object-v2/BinaryObjectDeSerializer.d.ts +93 -0
- package/src/engine/ecs/storage/binary/object-v2/BinaryObjectDeSerializer.d.ts.map +1 -0
- package/src/engine/ecs/storage/binary/object-v2/BinaryObjectDeSerializer.js +315 -0
- package/src/engine/ecs/storage/binary/object-v2/BinaryObjectSerializer.d.ts +48 -0
- package/src/engine/ecs/storage/binary/object-v2/BinaryObjectSerializer.d.ts.map +1 -0
- package/src/engine/ecs/storage/binary/object-v2/BinaryObjectSerializer.js +331 -0
- package/src/engine/ecs/storage/binary/object-v2/DESIGN.md +199 -0
- package/src/engine/ecs/storage/binary/object-v2/ObjectBinaryFormat.d.ts +53 -0
- package/src/engine/ecs/storage/binary/object-v2/ObjectBinaryFormat.d.ts.map +1 -0
- package/src/engine/ecs/storage/binary/object-v2/ObjectBinaryFormat.js +57 -0
- package/src/engine/ecs/storage/binary/object-v2/ObjectSerializationAdapter.d.ts +53 -0
- package/src/engine/ecs/storage/binary/object-v2/ObjectSerializationAdapter.d.ts.map +1 -0
- package/src/engine/ecs/storage/binary/object-v2/ObjectSerializationAdapter.js +56 -0
- package/src/engine/ecs/storage/binary/object-v2/README.md +110 -0
- package/src/engine/ecs/storage/binary/object-v2/objectStringCodec.d.ts +13 -0
- package/src/engine/ecs/storage/binary/object-v2/objectStringCodec.d.ts.map +1 -0
- package/src/engine/ecs/storage/binary/object-v2/objectStringCodec.js +48 -0
- package/src/engine/ecs/storage/binary/object-v2/serializerTestHarness.d.ts +29 -0
- package/src/engine/ecs/storage/binary/object-v2/serializerTestHarness.d.ts.map +1 -0
- package/src/engine/ecs/storage/binary/object-v2/serializerTestHarness.js +44 -0
- package/src/engine/ecs/system_validate_class.d.ts.map +1 -1
- package/src/engine/ecs/system_validate_class.js +9 -2
- package/src/engine/graphics/camera/makeScreenScissorFrustum.d.ts.map +1 -1
- package/src/engine/graphics/camera/makeScreenScissorFrustum.js +11 -10
- package/src/engine/graphics/canvas/canvas2d_draw_linear_scale.d.ts.map +1 -1
- package/src/engine/graphics/canvas/canvas2d_draw_linear_scale.js +3 -1
- package/src/engine/graphics/ecs/animation/animator/graph/definition/serialization/readAnimationGraphDefinitionFromJSON.d.ts +1 -1
- package/src/engine/graphics/ecs/animation/animator/graph/definition/serialization/readAnimationGraphDefinitionFromJSON.d.ts.map +1 -1
- package/src/engine/graphics/ecs/animation/animator/graph/definition/serialization/readAnimationGraphDefinitionFromJSON.js +2 -2
- package/src/engine/graphics/ecs/animation/animator/graph/definition/serialization/writeAnimationGraphDefinitionToJSON.d.ts.map +1 -1
- package/src/engine/graphics/ecs/animation/animator/graph/definition/serialization/writeAnimationGraphDefinitionToJSON.js +2 -0
- package/src/engine/graphics/ecs/camera/Camera.d.ts.map +1 -1
- package/src/engine/graphics/ecs/camera/Camera.js +4 -0
- package/src/engine/graphics/ecs/camera/auto_set_camera_clipping_planes.d.ts.map +1 -1
- package/src/engine/graphics/ecs/camera/auto_set_camera_clipping_planes.js +7 -2
- package/src/engine/graphics/ecs/camera/set_camera_aspect_ratio.js +1 -1
- package/src/engine/graphics/ecs/highlight/system/ShadedGeometryHighlightSystem.d.ts.map +1 -1
- package/src/engine/graphics/ecs/highlight/system/ShadedGeometryHighlightSystem.js +4 -1
- package/src/engine/graphics/ecs/light/binding/LightBinding.js +2 -2
- package/src/engine/graphics/ecs/mesh/MeshSystem.js +1 -1
- package/src/engine/graphics/ecs/mesh/SkeletonUtils.js +1 -1
- package/src/engine/graphics/ecs/mesh-v2/sg_hierarchy_compute_bounding_box_via_parent_entity.js +1 -1
- package/src/engine/graphics/ecs/water/WaterSystem.d.ts +6 -0
- package/src/engine/graphics/ecs/water/WaterSystem.d.ts.map +1 -1
- package/src/engine/graphics/ecs/water/WaterSystem.js +12 -1
- package/src/engine/graphics/geometry/buffered/ensureGeometryBoundingSphere.js +1 -1
- package/src/engine/graphics/geometry/buffered/query/bvh32_geometry_nearest.d.ts.map +1 -1
- package/src/engine/graphics/geometry/buffered/query/bvh32_geometry_nearest.js +0 -15
- package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +10 -10
- package/src/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js +1 -1
- package/src/engine/graphics/material/SplatMaterial.js +1 -1
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +3 -2
- package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +1 -1
- package/src/engine/graphics/particles/particular/group/ParticleGroup.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/group/ParticleGroup.js +3 -2
- package/src/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +1 -1
- package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts +1 -8
- package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/gi/material/MaterialTransformer.js +2 -14
- package/src/engine/graphics/sh3/gi/material/ProbeResolutionStage.d.ts +9 -0
- package/src/engine/graphics/sh3/gi/material/ProbeResolutionStage.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/ProbeResolutionStage.js +14 -0
- package/src/engine/graphics/sh3/lightmap/bake_lightmap_for_scene.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lightmap/bake_lightmap_for_scene.js +4 -1
- package/src/engine/graphics/sh3/lpg/LightProbeGrid.d.ts +69 -0
- package/src/engine/graphics/sh3/lpg/LightProbeGrid.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpg/LightProbeGrid.js +173 -0
- package/src/engine/graphics/sh3/lpg/LightProbeGridBaker.d.ts +24 -0
- package/src/engine/graphics/sh3/lpg/LightProbeGridBaker.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpg/LightProbeGridBaker.js +88 -0
- package/src/engine/graphics/sh3/lpg/build_light_probe_grid_for_scene.d.ts +20 -0
- package/src/engine/graphics/sh3/lpg/build_light_probe_grid_for_scene.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpg/build_light_probe_grid_for_scene.js +79 -0
- package/src/engine/graphics/sh3/lpg/light_probe_grid_obtain_storage_cached.d.ts +11 -0
- package/src/engine/graphics/sh3/lpg/light_probe_grid_obtain_storage_cached.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpg/light_probe_grid_obtain_storage_cached.js +84 -0
- package/src/engine/graphics/sh3/lpg/light_probe_grid_textures.d.ts +29 -0
- package/src/engine/graphics/sh3/lpg/light_probe_grid_textures.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpg/light_probe_grid_textures.js +160 -0
- package/src/engine/graphics/sh3/lpg/material/LightProbeGridMaterialTransformer.d.ts +23 -0
- package/src/engine/graphics/sh3/lpg/material/LightProbeGridMaterialTransformer.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpg/material/LightProbeGridMaterialTransformer.js +228 -0
- package/src/engine/graphics/sh3/lpg/material/chunk_lpg_get_irradiance_at.d.ts +2 -0
- package/src/engine/graphics/sh3/lpg/material/chunk_lpg_get_irradiance_at.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpg/material/chunk_lpg_get_irradiance_at.js +24 -0
- package/src/engine/graphics/sh3/lpg/material/common.d.ts +3 -0
- package/src/engine/graphics/sh3/lpg/material/common.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpg/material/common.js +73 -0
- package/src/engine/graphics/sh3/lpg/material/space_fragment/build_fragment_shader.d.ts +6 -0
- package/src/engine/graphics/sh3/lpg/material/space_fragment/build_fragment_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpg/material/space_fragment/build_fragment_shader.js +42 -0
- package/src/engine/graphics/sh3/lpg/material/space_fragment/build_vertex_shader.d.ts +6 -0
- package/src/engine/graphics/sh3/lpg/material/space_fragment/build_vertex_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpg/material/space_fragment/build_vertex_shader.js +49 -0
- package/src/engine/graphics/sh3/lpg/material/space_fragment/space_fragment_transform_shader.d.ts +9 -0
- package/src/engine/graphics/sh3/lpg/material/space_fragment/space_fragment_transform_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpg/material/space_fragment/space_fragment_transform_shader.js +12 -0
- package/src/engine/graphics/sh3/lpg/material/space_vertex/build_fragment_shader.d.ts +6 -0
- package/src/engine/graphics/sh3/lpg/material/space_vertex/build_fragment_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpg/material/space_vertex/build_fragment_shader.js +30 -0
- package/src/engine/graphics/sh3/lpg/material/space_vertex/build_vertex_shader.d.ts +6 -0
- package/src/engine/graphics/sh3/lpg/material/space_vertex/build_vertex_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpg/material/space_vertex/build_vertex_shader.js +41 -0
- package/src/engine/graphics/sh3/lpg/material/space_vertex/preamble.frag.d.ts +3 -0
- package/src/engine/graphics/sh3/lpg/material/space_vertex/preamble.frag.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpg/material/space_vertex/preamble.frag.js +15 -0
- package/src/engine/graphics/sh3/lpg/material/space_vertex/preamble.vert.d.ts +3 -0
- package/src/engine/graphics/sh3/lpg/material/space_vertex/preamble.vert.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpg/material/space_vertex/preamble.vert.js +9 -0
- package/src/engine/graphics/sh3/lpg/material/space_vertex/space_vertex_transform_shader.d.ts +9 -0
- package/src/engine/graphics/sh3/lpg/material/space_vertex/space_vertex_transform_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpg/material/space_vertex/space_vertex_transform_shader.js +12 -0
- package/src/engine/graphics/sh3/lpg/serialization/LightProbeGridSerializationAdapter.d.ts +20 -0
- package/src/engine/graphics/sh3/lpg/serialization/LightProbeGridSerializationAdapter.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpg/serialization/LightProbeGridSerializationAdapter.js +59 -0
- package/src/engine/graphics/sh3/path_tracer/material/MaterialConverter.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/material/MaterialConverter.js +8 -0
- package/src/engine/graphics/sh3/prototypeLightProbeGrid.d.ts +2 -0
- package/src/engine/graphics/sh3/prototypeLightProbeGrid.d.ts.map +1 -0
- package/src/engine/graphics/sh3/prototypeLightProbeGrid.js +170 -0
- package/src/engine/graphics/texture/atlas/AtlasLookupTexture.js +1 -1
- package/src/engine/graphics/texture/atlas/CachingTextureAtlas.js +1 -1
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_lanczos.js +1 -1
- package/src/engine/graphics/texture/sampler/sampler2d_copy_with_margins.js +3 -3
- package/src/engine/graphics/util/build_max_height_pyramid.d.ts.map +1 -1
- package/src/engine/graphics/util/build_max_height_pyramid.js +5 -2
- package/src/engine/grid/transform2grid/Transform2GridPositionSystem.js +1 -1
- package/src/engine/input/ecs/components/InputBinding.d.ts +7 -1
- package/src/engine/input/ecs/components/InputBinding.d.ts.map +1 -1
- package/src/engine/input/ecs/components/InputBinding.js +8 -1
- package/src/engine/input/ecs/systems/InputControllerSystem.js +1 -1
- package/src/engine/intelligence/behavior/decorator/OverrideContextBehavior.d.ts +2 -1
- package/src/engine/intelligence/behavior/decorator/OverrideContextBehavior.d.ts.map +1 -1
- package/src/engine/intelligence/behavior/decorator/OverrideContextBehavior.js +6 -2
- package/src/engine/intelligence/behavior/selector/WeightedElement.js +1 -1
- package/src/engine/knowledge/database/StaticKnowledgeDatabase.d.ts.map +1 -1
- package/src/engine/knowledge/database/StaticKnowledgeDatabase.js +2 -4
- package/src/engine/logging/elastic/ElasticSearchLogger.d.ts +1 -2
- package/src/engine/logging/elastic/ElasticSearchLogger.d.ts.map +1 -1
- package/src/engine/logging/elastic/ElasticSearchLogger.js +14 -10
- package/src/engine/navigation/ecs/path_following/PathFollower.js +1 -1
- package/src/engine/navigation/grid/find_path_on_grid_astar.d.ts.map +1 -1
- package/src/engine/navigation/grid/find_path_on_grid_astar.js +5 -2
- package/src/engine/network/orchestrator/ServerAuthoritativeServer.d.ts +1 -1
- package/src/engine/network/orchestrator/ServerAuthoritativeServer.d.ts.map +1 -1
- package/src/engine/network/orchestrator/ServerAuthoritativeServer.js +17 -0
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/engine/physics/fluid/ecs/FluidSystem.d.ts +3 -3
- package/src/engine/scene/SceneManager.d.ts.map +1 -1
- package/src/engine/scene/SceneManager.js +4 -2
- package/src/engine/simulation/Ticker.d.ts.map +1 -1
- package/src/engine/simulation/Ticker.js +9 -0
- package/src/engine/sound/ecs/emitter/SoundEmitterSystem.d.ts.map +1 -1
- package/src/engine/sound/ecs/emitter/SoundEmitterSystem.js +6 -1
- package/src/engine/sound/material/concrete/json/serializeSoundMaterialToJSON.js +1 -1
- package/src/generation/theme/ThemeEngine.d.ts +9 -0
- package/src/generation/theme/ThemeEngine.d.ts.map +1 -1
- package/src/generation/theme/ThemeEngine.js +37 -2
|
@@ -243,7 +243,10 @@ export function bake_lightmap_for_scene({
|
|
|
243
243
|
transform.updateMatrix();
|
|
244
244
|
});
|
|
245
245
|
|
|
246
|
-
|
|
246
|
+
if (background !== undefined) {
|
|
247
|
+
scene.__background_sampler = background;
|
|
248
|
+
}
|
|
249
|
+
|
|
247
250
|
populate_path_traced_scene_from_ecd(ecd, scene);
|
|
248
251
|
scene.optimize();
|
|
249
252
|
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dense irradiance field representation.
|
|
3
|
+
*
|
|
4
|
+
* Light probes are placed on a regular 3d grid spanning {@link #bounds}, probes on each axis are placed so that the
|
|
5
|
+
* first and the last layer lie exactly on the bounding box faces (spacing = extent / (resolution - 1)).
|
|
6
|
+
* Probe order matches WebGL 3d texture raster order: X varies fastest, then Y, then Z.
|
|
7
|
+
*
|
|
8
|
+
* Unlike {@link LightProbeVolume} there is no connectivity structure and no depth data, the field is intended to be
|
|
9
|
+
* uploaded into 3d textures and sampled with hardware trilinear filtering.
|
|
10
|
+
*
|
|
11
|
+
* @see "Irradiance Volumes" by G.Greger, 1998
|
|
12
|
+
*/
|
|
13
|
+
export class LightProbeGrid {
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @return {number}
|
|
17
|
+
*/
|
|
18
|
+
get version(): number;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @return {AABB3}
|
|
22
|
+
*/
|
|
23
|
+
get bounds(): AABB3;
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @return {number}
|
|
27
|
+
*/
|
|
28
|
+
get resolution_x(): number;
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @return {number}
|
|
32
|
+
*/
|
|
33
|
+
get resolution_y(): number;
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @return {number}
|
|
37
|
+
*/
|
|
38
|
+
get resolution_z(): number;
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @return {number}
|
|
42
|
+
*/
|
|
43
|
+
get count(): number;
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* @return {Float32Array}
|
|
47
|
+
*/
|
|
48
|
+
get harmonics(): Float32Array;
|
|
49
|
+
clear(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Allocate probe storage for a given region and grid resolution. Existing data is discarded.
|
|
52
|
+
* @param {AABB3} bounds
|
|
53
|
+
* @param {number} resolution_x number of probe layers along X, at least 2
|
|
54
|
+
* @param {number} resolution_y
|
|
55
|
+
* @param {number} resolution_z
|
|
56
|
+
*/
|
|
57
|
+
build(bounds: AABB3, resolution_x: number, resolution_y: number, resolution_z: number): void;
|
|
58
|
+
/**
|
|
59
|
+
* World-space position of a probe
|
|
60
|
+
* @param {number[]|Float32Array} result probe position is written here as [x, y, z]
|
|
61
|
+
* @param {number} result_offset
|
|
62
|
+
* @param {number} index probe index
|
|
63
|
+
*/
|
|
64
|
+
probe_position(result: number[] | Float32Array, result_offset: number, index: number): void;
|
|
65
|
+
incrementVersion(): void;
|
|
66
|
+
#private;
|
|
67
|
+
}
|
|
68
|
+
import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
|
|
69
|
+
//# sourceMappingURL=LightProbeGrid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LightProbeGrid.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpg/LightProbeGrid.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH;IAkBI;;;OAGG;IACH,sBAEC;IAED;;;OAGG;IACH,oBAEC;IAED;;;OAGG;IACH,2BAEC;IAED;;;OAGG;IACH,2BAEC;IAED;;;OAGG;IACH,2BAEC;IAED;;;OAGG;IACH,oBAEC;IAED;;;OAGG;IACH,8BAEC;IAED,cAUC;IAED;;;;;;OAMG;IACH,cALW,KAAK,gBACL,MAAM,gBACN,MAAM,gBACN,MAAM,QAoChB;IAED;;;;;OAKG;IACH,uBAJW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,SACN,MAAM,QAmBhB;IAED,yBAEC;;CACJ;sBA3KqB,wCAAwC"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { assert } from "../../../../core/assert.js";
|
|
2
|
+
import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Dense irradiance field representation.
|
|
6
|
+
*
|
|
7
|
+
* Light probes are placed on a regular 3d grid spanning {@link #bounds}, probes on each axis are placed so that the
|
|
8
|
+
* first and the last layer lie exactly on the bounding box faces (spacing = extent / (resolution - 1)).
|
|
9
|
+
* Probe order matches WebGL 3d texture raster order: X varies fastest, then Y, then Z.
|
|
10
|
+
*
|
|
11
|
+
* Unlike {@link LightProbeVolume} there is no connectivity structure and no depth data, the field is intended to be
|
|
12
|
+
* uploaded into 3d textures and sampled with hardware trilinear filtering.
|
|
13
|
+
*
|
|
14
|
+
* @see "Irradiance Volumes" by G.Greger, 1998
|
|
15
|
+
*/
|
|
16
|
+
export class LightProbeGrid {
|
|
17
|
+
#version = 0;
|
|
18
|
+
|
|
19
|
+
#bounds = new AABB3(0, 0, 0, 0, 0, 0);
|
|
20
|
+
|
|
21
|
+
#resolution_x = 0;
|
|
22
|
+
#resolution_y = 0;
|
|
23
|
+
#resolution_z = 0;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Probe irradiance color data
|
|
27
|
+
* Base-2 spherical harmonics, 4 coefficients per color channel for a total of 12 coefficients per probe
|
|
28
|
+
* Layout is coefficient-major with an RGB triplet per coefficient, matching the first 4 coefficients of
|
|
29
|
+
* {@link LightProbeVolume#harmonics}
|
|
30
|
+
* @type {Float32Array}
|
|
31
|
+
*/
|
|
32
|
+
#sh2_rgb = new Float32Array(0);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @return {number}
|
|
37
|
+
*/
|
|
38
|
+
get version() {
|
|
39
|
+
return this.#version;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @return {AABB3}
|
|
45
|
+
*/
|
|
46
|
+
get bounds() {
|
|
47
|
+
return this.#bounds;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @return {number}
|
|
53
|
+
*/
|
|
54
|
+
get resolution_x() {
|
|
55
|
+
return this.#resolution_x;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @return {number}
|
|
61
|
+
*/
|
|
62
|
+
get resolution_y() {
|
|
63
|
+
return this.#resolution_y;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* @return {number}
|
|
69
|
+
*/
|
|
70
|
+
get resolution_z() {
|
|
71
|
+
return this.#resolution_z;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
*
|
|
76
|
+
* @return {number}
|
|
77
|
+
*/
|
|
78
|
+
get count() {
|
|
79
|
+
return this.#resolution_x * this.#resolution_y * this.#resolution_z;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
*
|
|
84
|
+
* @return {Float32Array}
|
|
85
|
+
*/
|
|
86
|
+
get harmonics() {
|
|
87
|
+
return this.#sh2_rgb;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
clear() {
|
|
91
|
+
this.#bounds.setBounds(0, 0, 0, 0, 0, 0);
|
|
92
|
+
|
|
93
|
+
this.#resolution_x = 0;
|
|
94
|
+
this.#resolution_y = 0;
|
|
95
|
+
this.#resolution_z = 0;
|
|
96
|
+
|
|
97
|
+
this.#sh2_rgb = new Float32Array(0);
|
|
98
|
+
|
|
99
|
+
this.#version++;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Allocate probe storage for a given region and grid resolution. Existing data is discarded.
|
|
104
|
+
* @param {AABB3} bounds
|
|
105
|
+
* @param {number} resolution_x number of probe layers along X, at least 2
|
|
106
|
+
* @param {number} resolution_y
|
|
107
|
+
* @param {number} resolution_z
|
|
108
|
+
*/
|
|
109
|
+
build(bounds, resolution_x, resolution_y, resolution_z) {
|
|
110
|
+
assert.isInstanceOf(bounds, AABB3, 'bounds');
|
|
111
|
+
|
|
112
|
+
assert.isNonNegativeInteger(resolution_x, 'resolution_x');
|
|
113
|
+
assert.isNonNegativeInteger(resolution_y, 'resolution_y');
|
|
114
|
+
assert.isNonNegativeInteger(resolution_z, 'resolution_z');
|
|
115
|
+
|
|
116
|
+
assert.greaterThanOrEqual(resolution_x, 2, 'resolution_x');
|
|
117
|
+
assert.greaterThanOrEqual(resolution_y, 2, 'resolution_y');
|
|
118
|
+
assert.greaterThanOrEqual(resolution_z, 2, 'resolution_z');
|
|
119
|
+
|
|
120
|
+
this.#bounds.copy(bounds);
|
|
121
|
+
|
|
122
|
+
this.#resolution_x = resolution_x;
|
|
123
|
+
this.#resolution_y = resolution_y;
|
|
124
|
+
this.#resolution_z = resolution_z;
|
|
125
|
+
|
|
126
|
+
const count = this.count;
|
|
127
|
+
|
|
128
|
+
const data = new Float32Array(count * 12);
|
|
129
|
+
|
|
130
|
+
// neutral-ambient placeholder for not-yet-baked probes: DC coefficient only, band-1 stays zero.
|
|
131
|
+
// Filling all 12 coefficients would reconstruct a directional gradient (negative for some normals), not white.
|
|
132
|
+
for (let i = 0; i < count; i++) {
|
|
133
|
+
const offset = i * 12;
|
|
134
|
+
|
|
135
|
+
data[offset] = 1;
|
|
136
|
+
data[offset + 1] = 1;
|
|
137
|
+
data[offset + 2] = 1;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
this.#sh2_rgb = data;
|
|
141
|
+
|
|
142
|
+
this.#version++;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* World-space position of a probe
|
|
147
|
+
* @param {number[]|Float32Array} result probe position is written here as [x, y, z]
|
|
148
|
+
* @param {number} result_offset
|
|
149
|
+
* @param {number} index probe index
|
|
150
|
+
*/
|
|
151
|
+
probe_position(result, result_offset, index) {
|
|
152
|
+
assert.isNonNegativeInteger(index, 'index');
|
|
153
|
+
assert.lessThan(index, this.count, 'index');
|
|
154
|
+
|
|
155
|
+
const resolution_x = this.#resolution_x;
|
|
156
|
+
const resolution_y = this.#resolution_y;
|
|
157
|
+
const resolution_z = this.#resolution_z;
|
|
158
|
+
|
|
159
|
+
const x = index % resolution_x;
|
|
160
|
+
const y = ((index / resolution_x) | 0) % resolution_y;
|
|
161
|
+
const z = (index / (resolution_x * resolution_y)) | 0;
|
|
162
|
+
|
|
163
|
+
const bounds = this.#bounds;
|
|
164
|
+
|
|
165
|
+
result[result_offset] = bounds.x0 + (x / (resolution_x - 1)) * bounds.getExtentsX();
|
|
166
|
+
result[result_offset + 1] = bounds.y0 + (y / (resolution_y - 1)) * bounds.getExtentsY();
|
|
167
|
+
result[result_offset + 2] = bounds.z0 + (z / (resolution_z - 1)) * bounds.getExtentsZ();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
incrementVersion() {
|
|
171
|
+
this.#version++;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export class LightProbeGridBaker {
|
|
2
|
+
/**
|
|
3
|
+
* Renderer used to bake probes. Exposed so callers (and tests) can configure the underlying scene.
|
|
4
|
+
* @return {ProbeRenderer}
|
|
5
|
+
*/
|
|
6
|
+
get renderer(): ProbeRenderer;
|
|
7
|
+
/**
|
|
8
|
+
* Bake light probes
|
|
9
|
+
* @returns {TaskGroup}
|
|
10
|
+
* @param {LightProbeGrid} grid
|
|
11
|
+
* @param {EntityComponentDataset} ecd
|
|
12
|
+
*/
|
|
13
|
+
bake(grid: LightProbeGrid, ecd: EntityComponentDataset): TaskGroup;
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param {ProbeRenderer} renderer
|
|
17
|
+
* @param {LightProbeGrid} grid
|
|
18
|
+
* @param {number} probe_index
|
|
19
|
+
*/
|
|
20
|
+
bake_probe(renderer: ProbeRenderer, grid: LightProbeGrid, probe_index: number): void;
|
|
21
|
+
#private;
|
|
22
|
+
}
|
|
23
|
+
import TaskGroup from "../../../../core/process/task/TaskGroup.js";
|
|
24
|
+
//# sourceMappingURL=LightProbeGridBaker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LightProbeGridBaker.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpg/LightProbeGridBaker.js"],"names":[],"mappings":"AAWA;IAII;;;OAGG;IACH,8BAEC;IAED;;;;;OAKG;IACH,yDAJa,SAAS,CA2CrB;IAED;;;;;OAKG;IACH,uEAFW,MAAM,QAYhB;;CACJ;sBArFqB,4CAA4C"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { assert } from "../../../../core/assert.js";
|
|
2
|
+
import { array_copy } from "../../../../core/collection/array/array_copy.js";
|
|
3
|
+
import TaskGroup from "../../../../core/process/task/TaskGroup.js";
|
|
4
|
+
import { actionTask } from "../../../../core/process/task/util/actionTask.js";
|
|
5
|
+
import { countTask } from "../../../../core/process/task/util/countTask.js";
|
|
6
|
+
import { promiseTask } from "../../../../core/process/task/util/promiseTask.js";
|
|
7
|
+
import { PathTracerProbeRenderer } from "../lpv/PathTracerProbeRenderer.js";
|
|
8
|
+
|
|
9
|
+
const __position = new Float32Array(3);
|
|
10
|
+
const __sh3_rgb = new Float64Array(27);
|
|
11
|
+
|
|
12
|
+
export class LightProbeGridBaker {
|
|
13
|
+
|
|
14
|
+
#ren = new PathTracerProbeRenderer();
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Renderer used to bake probes. Exposed so callers (and tests) can configure the underlying scene.
|
|
18
|
+
* @return {ProbeRenderer}
|
|
19
|
+
*/
|
|
20
|
+
get renderer() {
|
|
21
|
+
return this.#ren;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Bake light probes
|
|
26
|
+
* @returns {TaskGroup}
|
|
27
|
+
* @param {LightProbeGrid} grid
|
|
28
|
+
* @param {EntityComponentDataset} ecd
|
|
29
|
+
*/
|
|
30
|
+
bake(grid, ecd) {
|
|
31
|
+
const renderer = this.#ren;
|
|
32
|
+
|
|
33
|
+
// async IIFE (not a Promise executor): a throw in build_scene/bake_start rejects the task rather than
|
|
34
|
+
// leaving the promise unsettled and hanging the bake forever
|
|
35
|
+
const tPrepare = promiseTask((async () => {
|
|
36
|
+
renderer.build_scene(ecd);
|
|
37
|
+
await renderer.bake_start(ecd);
|
|
38
|
+
})(), 'Prepare');
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
const probe_count = grid.count;
|
|
42
|
+
|
|
43
|
+
const tBakeIrradiance = countTask(0, probe_count, (probe_index) => {
|
|
44
|
+
this.bake_probe(renderer, grid, probe_index);
|
|
45
|
+
|
|
46
|
+
});
|
|
47
|
+
tBakeIrradiance.estimatedDuration = probe_count;
|
|
48
|
+
|
|
49
|
+
tBakeIrradiance.promise().then(() => {
|
|
50
|
+
|
|
51
|
+
const duration = tBakeIrradiance.__executedCpuTime;
|
|
52
|
+
|
|
53
|
+
console.log(`Baked ${probe_count} probes in ${duration}ms, ~${(duration / probe_count).toFixed(2)}ms per probe`);
|
|
54
|
+
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const tFinish = actionTask(() => {
|
|
58
|
+
renderer.bake_end();
|
|
59
|
+
|
|
60
|
+
grid.incrementVersion();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
tFinish.addDependency(tBakeIrradiance);
|
|
64
|
+
tBakeIrradiance.addDependency(tPrepare);
|
|
65
|
+
|
|
66
|
+
return new TaskGroup([
|
|
67
|
+
tPrepare, tBakeIrradiance, tFinish
|
|
68
|
+
], "LightProbeGrid Bake");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
* @param {ProbeRenderer} renderer
|
|
74
|
+
* @param {LightProbeGrid} grid
|
|
75
|
+
* @param {number} probe_index
|
|
76
|
+
*/
|
|
77
|
+
bake_probe(renderer, grid, probe_index) {
|
|
78
|
+
assert.isNonNegativeInteger(probe_index, 'probe_index');
|
|
79
|
+
|
|
80
|
+
grid.probe_position(__position, 0, probe_index);
|
|
81
|
+
|
|
82
|
+
// render a full SH3 probe with the shared facilities
|
|
83
|
+
renderer.bake(__position, 0, __sh3_rgb, 0);
|
|
84
|
+
|
|
85
|
+
// keep only bands 0 and 1: the coefficient-major layout puts them in the first 12 values
|
|
86
|
+
array_copy(__sh3_rgb, 0, grid.harmonics, probe_index * 12, 12);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {LightProbeGrid} grid
|
|
4
|
+
* @param {EntityComponentDataset} ecd
|
|
5
|
+
* @param {Engine} engine
|
|
6
|
+
* @return {Promise<void>}
|
|
7
|
+
*/
|
|
8
|
+
export function light_probe_grid_bake_via_task(grid: LightProbeGrid, ecd: EntityComponentDataset, engine: Engine): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param {LightProbeGrid} [grid]
|
|
12
|
+
* @param {Engine} engine
|
|
13
|
+
* @param {EntityComponentDataset} ecd
|
|
14
|
+
* @param {AABB3} bounds
|
|
15
|
+
* @param {number} [spacing] desired distance between probes, in world units
|
|
16
|
+
* @returns {Promise<LightProbeGrid>}
|
|
17
|
+
*/
|
|
18
|
+
export function build_light_probe_grid_for_scene({ grid, engine, ecd, bounds, spacing }?: LightProbeGrid): Promise<LightProbeGrid>;
|
|
19
|
+
import { LightProbeGrid } from "./LightProbeGrid.js";
|
|
20
|
+
//# sourceMappingURL=build_light_probe_grid_for_scene.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_light_probe_grid_for_scene.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpg/build_light_probe_grid_for_scene.js"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,qDALW,cAAc,gDAGb,QAAQ,IAAI,CAAC,CA2BxB;AAED;;;;;;;;GAQG;AACH,0FAPW,cAAc,GAKZ,QAAQ,cAAc,CAAC,CA2BnC;+BAvE8B,qBAAqB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
|
|
2
|
+
import Vector2 from "../../../../core/geom/Vector2.js";
|
|
3
|
+
import { max2 } from "../../../../core/math/max2.js";
|
|
4
|
+
import Entity from "../../../ecs/Entity.js";
|
|
5
|
+
import GUIElement from "../../../ecs/gui/GUIElement.js";
|
|
6
|
+
import ViewportPosition from "../../../ecs/gui/position/ViewportPosition.js";
|
|
7
|
+
import { makeSimpleTaskProgressView } from "../../../makeSimpleTaskProgressView.js";
|
|
8
|
+
import { LightProbeGrid } from "./LightProbeGrid.js";
|
|
9
|
+
import { LightProbeGridBaker } from "./LightProbeGridBaker.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param {LightProbeGrid} grid
|
|
14
|
+
* @param {EntityComponentDataset} ecd
|
|
15
|
+
* @param {Engine} engine
|
|
16
|
+
* @return {Promise<void>}
|
|
17
|
+
*/
|
|
18
|
+
export async function light_probe_grid_bake_via_task(grid, ecd, engine) {
|
|
19
|
+
const baker = new LightProbeGridBaker();
|
|
20
|
+
const task = baker.bake(grid, ecd);
|
|
21
|
+
|
|
22
|
+
const progress = makeSimpleTaskProgressView({
|
|
23
|
+
task,
|
|
24
|
+
localization: engine.localization,
|
|
25
|
+
size: new Vector2(512, 64)
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const progress_entity = new Entity();
|
|
29
|
+
progress_entity
|
|
30
|
+
.add(GUIElement.fromView(progress))
|
|
31
|
+
.add(ViewportPosition.fromJSON({
|
|
32
|
+
position: new Vector2(0, 1),
|
|
33
|
+
anchor: new Vector2(0, 1),
|
|
34
|
+
offset: new Vector2(16, -16)
|
|
35
|
+
}))
|
|
36
|
+
.build(ecd);
|
|
37
|
+
|
|
38
|
+
task.promise().finally(() => progress_entity.destroy())
|
|
39
|
+
|
|
40
|
+
engine.executor.runGroup(task);
|
|
41
|
+
|
|
42
|
+
await task.promise();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @param {LightProbeGrid} [grid]
|
|
48
|
+
* @param {Engine} engine
|
|
49
|
+
* @param {EntityComponentDataset} ecd
|
|
50
|
+
* @param {AABB3} bounds
|
|
51
|
+
* @param {number} [spacing] desired distance between probes, in world units
|
|
52
|
+
* @returns {Promise<LightProbeGrid>}
|
|
53
|
+
*/
|
|
54
|
+
export async function build_light_probe_grid_for_scene(
|
|
55
|
+
{
|
|
56
|
+
grid = new LightProbeGrid(),
|
|
57
|
+
engine,
|
|
58
|
+
ecd,
|
|
59
|
+
bounds,
|
|
60
|
+
spacing = 1
|
|
61
|
+
}
|
|
62
|
+
) {
|
|
63
|
+
|
|
64
|
+
const grid_bounds = new AABB3(0, 0, 0, 0, 0, 0);
|
|
65
|
+
grid_bounds.copy(bounds);
|
|
66
|
+
|
|
67
|
+
// push probe layers slightly past the geometry so that boundary surfaces are not sampled exactly at a probe shell
|
|
68
|
+
grid_bounds.grow(spacing * 1.05);
|
|
69
|
+
|
|
70
|
+
const resolution_x = max2(2, Math.ceil(grid_bounds.getExtentsX() / spacing) + 1);
|
|
71
|
+
const resolution_y = max2(2, Math.ceil(grid_bounds.getExtentsY() / spacing) + 1);
|
|
72
|
+
const resolution_z = max2(2, Math.ceil(grid_bounds.getExtentsZ() / spacing) + 1);
|
|
73
|
+
|
|
74
|
+
grid.build(grid_bounds, resolution_x, resolution_y, resolution_z);
|
|
75
|
+
|
|
76
|
+
await light_probe_grid_bake_via_task(grid, ecd, engine);
|
|
77
|
+
|
|
78
|
+
return grid;
|
|
79
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {Engine} engine
|
|
4
|
+
* @param {string} path
|
|
5
|
+
* @param {LightProbeGrid} [grid]
|
|
6
|
+
* @param {number} [spacing] only used when building, if loading this parameter is ignored
|
|
7
|
+
* @return {Promise<LightProbeGrid>}
|
|
8
|
+
*/
|
|
9
|
+
export function light_probe_grid_obtain_storage_cached({ engine, path, grid, spacing }: Engine): Promise<LightProbeGrid>;
|
|
10
|
+
import { LightProbeGrid } from "./LightProbeGrid.js";
|
|
11
|
+
//# sourceMappingURL=light_probe_grid_obtain_storage_cached.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"light_probe_grid_obtain_storage_cached.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpg/light_probe_grid_obtain_storage_cached.js"],"names":[],"mappings":"AASA;;;;;;;GAOG;AACH,iGAFY,QAAQ,cAAc,CAAC,CAoElC;+BA7E8B,qBAAqB"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { BinaryBuffer } from "../../../../core/binary/BinaryBuffer.js";
|
|
2
|
+
import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
|
|
3
|
+
import { number_pretty_print } from "../../../../core/primitives/numbers/number_pretty_print.js";
|
|
4
|
+
import { Transform } from "../../../ecs/transform/Transform.js";
|
|
5
|
+
import { ShadedGeometry } from "../../ecs/mesh-v2/ShadedGeometry.js";
|
|
6
|
+
import { build_light_probe_grid_for_scene } from "./build_light_probe_grid_for_scene.js";
|
|
7
|
+
import { LightProbeGrid } from "./LightProbeGrid.js";
|
|
8
|
+
import { LightProbeGridSerializationAdapter } from "./serialization/LightProbeGridSerializationAdapter.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param {Engine} engine
|
|
13
|
+
* @param {string} path
|
|
14
|
+
* @param {LightProbeGrid} [grid]
|
|
15
|
+
* @param {number} [spacing] only used when building, if loading this parameter is ignored
|
|
16
|
+
* @return {Promise<LightProbeGrid>}
|
|
17
|
+
*/
|
|
18
|
+
export async function light_probe_grid_obtain_storage_cached({
|
|
19
|
+
engine,
|
|
20
|
+
path,
|
|
21
|
+
grid = new LightProbeGrid(),
|
|
22
|
+
spacing = 1
|
|
23
|
+
}) {
|
|
24
|
+
|
|
25
|
+
grid.clear();
|
|
26
|
+
|
|
27
|
+
const key = `lpg:${path}`;
|
|
28
|
+
|
|
29
|
+
const adapter = new LightProbeGridSerializationAdapter();
|
|
30
|
+
|
|
31
|
+
if (await engine.storage.promiseContains(key)) {
|
|
32
|
+
const data = await engine.storage.promiseLoadBinary(key);
|
|
33
|
+
|
|
34
|
+
console.log(`LPG data size ${number_pretty_print(data.byteLength)} bytes`);
|
|
35
|
+
|
|
36
|
+
const buffer = BinaryBuffer.fromArrayBuffer(data);
|
|
37
|
+
|
|
38
|
+
adapter.deserialize(buffer, grid);
|
|
39
|
+
|
|
40
|
+
return grid;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
const ecd = engine.entityManager.dataset;
|
|
45
|
+
|
|
46
|
+
// build bounding box for the scene
|
|
47
|
+
const mesh_bounds = new AABB3();
|
|
48
|
+
mesh_bounds.setNegativelyInfiniteBounds();
|
|
49
|
+
|
|
50
|
+
ecd.traverseEntities([ShadedGeometry, Transform],
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @param {ShadedGeometry} sg
|
|
54
|
+
* @param transform
|
|
55
|
+
* @param entity
|
|
56
|
+
*/
|
|
57
|
+
(sg, transform, entity) => {
|
|
58
|
+
|
|
59
|
+
const box = new AABB3();
|
|
60
|
+
|
|
61
|
+
sg.getBoundingBox(box);
|
|
62
|
+
|
|
63
|
+
mesh_bounds.union(box);
|
|
64
|
+
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
await build_light_probe_grid_for_scene({
|
|
68
|
+
grid,
|
|
69
|
+
engine,
|
|
70
|
+
ecd,
|
|
71
|
+
bounds: mesh_bounds,
|
|
72
|
+
spacing
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const buffer = new BinaryBuffer();
|
|
76
|
+
|
|
77
|
+
adapter.serialize(buffer, grid);
|
|
78
|
+
|
|
79
|
+
buffer.trim();
|
|
80
|
+
|
|
81
|
+
engine.storage.promiseStoreBinary(key, buffer.data)
|
|
82
|
+
|
|
83
|
+
return grid;
|
|
84
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create the half-float luminance volume of a {@link LightProbeGrid}. Each texel holds the 4 SH2 Y coefficients in RGBA.
|
|
3
|
+
* @param {number} resolution_x
|
|
4
|
+
* @param {number} resolution_y
|
|
5
|
+
* @param {number} resolution_z
|
|
6
|
+
* @returns {DataTexture3D}
|
|
7
|
+
*/
|
|
8
|
+
export function make_light_probe_grid_luma_texture(resolution_x: number, resolution_y: number, resolution_z: number): DataTexture3D;
|
|
9
|
+
/**
|
|
10
|
+
* Create an 8-bit chrominance volume (one of Co / Cg) of a {@link LightProbeGrid}. Each texel holds the 4 SH2
|
|
11
|
+
* coefficients of that chroma channel in RGBA.
|
|
12
|
+
* @param {number} resolution_x
|
|
13
|
+
* @param {number} resolution_y
|
|
14
|
+
* @param {number} resolution_z
|
|
15
|
+
* @returns {DataTexture3D}
|
|
16
|
+
*/
|
|
17
|
+
export function make_light_probe_grid_chroma_texture(resolution_x: number, resolution_y: number, resolution_z: number): DataTexture3D;
|
|
18
|
+
/**
|
|
19
|
+
* Write probe data of a grid into the YCoCg textures created by {@link make_light_probe_grid_luma_texture} and
|
|
20
|
+
* {@link make_light_probe_grid_chroma_texture}. Texture dimensions must match the grid resolution.
|
|
21
|
+
* @param {LightProbeGrid} grid
|
|
22
|
+
* @param {DataTexture3D} texture_y luminance, half-float
|
|
23
|
+
* @param {DataTexture3D} texture_co chroma-orange, 8-bit
|
|
24
|
+
* @param {DataTexture3D} texture_cg chroma-green, 8-bit
|
|
25
|
+
*/
|
|
26
|
+
export function light_probe_grid_write_textures(grid: LightProbeGrid, texture_y: DataTexture3D, texture_co: DataTexture3D, texture_cg: DataTexture3D): void;
|
|
27
|
+
export const LPG_CHROMA_SCALE: 0.25;
|
|
28
|
+
import { DataTexture3D } from "three";
|
|
29
|
+
//# sourceMappingURL=light_probe_grid_textures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"light_probe_grid_textures.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpg/light_probe_grid_textures.js"],"names":[],"mappings":"AA+BA;;;;;;GAMG;AACH,iEALW,MAAM,gBACN,MAAM,gBACN,MAAM,GACJ,aAAa,CA+BzB;AAED;;;;;;;GAOG;AACH,mEALW,MAAM,gBACN,MAAM,gBACN,MAAM,GACJ,aAAa,CA+BzB;AAUD;;;;;;;GAOG;AACH,iFAJW,aAAa,cACb,aAAa,cACb,aAAa,QAqCvB;AAtID,oCAAqC;8BAlB9B,OAAO"}
|