@woosh/meep-engine 2.109.6 → 2.109.8
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/build/bundle-worker-terrain.js +1 -1
- package/build/meep.cjs +203 -174
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +203 -174
- package/editor/tools/v2/TransformControls.js +39 -33
- package/package.json +1 -1
- package/src/core/bvh2/bvh3/BVH.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/BVH.js +8 -0
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +11 -9
- package/src/core/geom/3d/Ray3.js +1 -1
- package/src/core/geom/3d/aabb/AABB3.js +1 -1
- package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts +4 -4
- package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts.map +1 -1
- package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js +15 -11
- package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.d.ts.map +1 -1
- package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.js +13 -7
- package/src/core/geom/3d/normal/octahedron/encoding.spec.js +26 -1
- package/src/core/geom/3d/normal/octahedron/prototype.d.ts +2 -0
- package/src/core/geom/3d/normal/octahedron/prototype.d.ts.map +1 -0
- package/src/core/geom/3d/normal/octahedron/prototype.js +226 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate_bl.d.ts +1 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate_bl.js +4 -4
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts +3 -3
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +10 -5
- package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts +7 -1
- package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.js +6 -0
- package/src/core/geom/vec3/v3_distance.d.ts.map +1 -1
- package/src/core/geom/vec3/v3_distance.js +5 -5
- package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts +10 -0
- package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts.map +1 -0
- package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.js +34 -0
- package/src/core/model/node-graph/DataType.d.ts.map +1 -1
- package/src/core/model/node-graph/DataType.js +16 -10
- package/src/core/model/node-graph/ParametricDataType.d.ts +34 -0
- package/src/core/model/node-graph/ParametricDataType.d.ts.map +1 -0
- package/src/core/model/node-graph/ParametricDataType.js +63 -0
- package/src/core/model/node-graph/json/serializeNodeGraphToJSON.d.ts +5 -1
- package/src/core/model/node-graph/json/serializeNodeGraphToJSON.d.ts.map +1 -1
- package/src/core/model/node-graph/json/serializeNodeGraphToJSON.js +11 -6
- package/src/engine/asset/loaders/AssetLoader.d.ts.map +1 -1
- package/src/engine/asset/loaders/AssetLoader.js +1 -1
- package/src/engine/asset/loaders/material/computeTextureEquality.d.ts.map +1 -1
- package/src/engine/asset/loaders/material/computeTextureEquality.js +6 -1
- package/src/engine/asset/loaders/material/computeTextureHash.d.ts.map +1 -1
- package/src/engine/asset/loaders/material/computeTextureHash.js +8 -3
- package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.d.ts.map +1 -1
- package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +9 -15
- package/src/engine/graphics/geometry/instancing/geometry_copy.d.ts +7 -0
- package/src/engine/graphics/geometry/instancing/geometry_copy.d.ts.map +1 -0
- package/src/engine/graphics/geometry/instancing/geometry_copy.js +15 -0
- package/src/engine/graphics/impostors/octahedral/ImpostorBaker.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/ImpostorBaker.js +28 -20
- package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.d.ts +1 -0
- package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.js +4 -0
- package/src/engine/graphics/impostors/octahedral/grid/OctahedralUvEncoder.js +6 -6
- package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +16 -7
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts +3 -2
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +25 -14
- package/src/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +1 -0
- package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/gi/material/MaterialTransformer.js +59 -37
- package/src/engine/graphics/sh3/gi/material/common.glsl +484 -0
- package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.d.ts +8 -0
- package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.js +35 -0
- package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts +8 -0
- package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.js +28 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.js +51 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/build_vertex_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/build_vertex_shader.js +29 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.d.ts +9 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.js +12 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.d.ts +6 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.js +26 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.d.ts +6 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.js +62 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/preable.frag.glsl +43 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/preable.vert.glsl +9 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.d.ts +9 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.js +12 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +2 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +35 -3
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js +26 -9
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts +11 -1
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +27 -61
- package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +8 -6
- package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.d.ts +17 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.js +100 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts +12 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js +58 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.d.ts +11 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.js +45 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/visualize.frag.glsl +126 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/visualize.vert.glsl +10 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.d.ts +13 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.js +149 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.frag.glsl +161 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.vert.glsl +13 -0
- package/src/engine/graphics/sh3/lpv/depth/sh3_bake_depth.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/{sh3_bake_depth.js → depth/sh3_bake_depth.js} +7 -7
- package/src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.d.ts +8 -0
- package/src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.js +50 -0
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts +3 -6
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +34 -58
- package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.js +8 -0
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts +2 -2
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js +8 -5
- package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.d.ts +7 -0
- package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.js +50 -0
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +40 -3
- package/src/engine/graphics/sh3/path_tracer/sorting/build_bvh_nodes_distances_along_ray.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_along_ray.js → sorting/build_bvh_nodes_distances_along_ray.js} +2 -2
- package/src/engine/graphics/sh3/path_tracer/sorting/build_bvh_nodes_distances_sqr_to_point.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_sqr_to_point.js → sorting/build_bvh_nodes_distances_sqr_to_point.js} +2 -2
- package/src/engine/graphics/sh3/path_tracer/sorting/sort_bvh_nodes_by_distance_to_point.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/{sort_bvh_nodes_by_distance_to_point.js → sorting/sort_bvh_nodes_by_distance_to_point.js} +3 -3
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +41 -8
- package/src/engine/graphics/sh3/shader/SH3VisualisationMaterial.d.ts.map +1 -0
- package/src/engine/graphics/sh3/shader/SH3VisualisationMaterial.js +29 -0
- package/src/engine/graphics/sh3/shader/visualize.frag.glsl +41 -0
- package/src/engine/graphics/sh3/shader/visualize.vert.glsl +9 -0
- package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.js +1 -1
- package/src/engine/graphics/texture/debug_preview_texture.d.ts +8 -0
- package/src/engine/graphics/texture/debug_preview_texture.d.ts.map +1 -0
- package/src/engine/graphics/texture/debug_preview_texture.js +38 -0
- package/src/view/View.d.ts.map +1 -1
- package/src/view/View.js +2 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.d.ts +0 -8
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.d.ts.map +0 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.js +0 -32
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts +0 -8
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts.map +0 -1
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.js +0 -44
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts +0 -8
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts.map +0 -1
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.js +0 -86
- package/src/engine/graphics/sh3/SH3VisualisationMaterial.d.ts.map +0 -1
- package/src/engine/graphics/sh3/SH3VisualisationMaterial.js +0 -83
- package/src/engine/graphics/sh3/gi/material/build_fragment_shader.d.ts.map +0 -1
- package/src/engine/graphics/sh3/gi/material/build_fragment_shader.js +0 -71
- package/src/engine/graphics/sh3/gi/material/build_vertex_shader.d.ts.map +0 -1
- package/src/engine/graphics/sh3/gi/material/build_vertex_shader.js +0 -256
- package/src/engine/graphics/sh3/lpv/sh3_bake_depth.d.ts.map +0 -1
- package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.d.ts.map +0 -1
- package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.d.ts.map +0 -1
- package/src/engine/graphics/sh3/path_tracer/ray_reflect.d.ts +0 -2
- package/src/engine/graphics/sh3/path_tracer/ray_reflect.d.ts.map +0 -1
- package/src/engine/graphics/sh3/path_tracer/ray_reflect.js +0 -27
- package/src/engine/graphics/sh3/path_tracer/sort_bvh_nodes_by_distance_to_point.d.ts.map +0 -1
- /package/src/engine/graphics/sh3/gi/material/{build_fragment_shader.d.ts → space_fragment/build_fragment_shader.d.ts} +0 -0
- /package/src/engine/graphics/sh3/gi/material/{build_vertex_shader.d.ts → space_fragment/build_vertex_shader.d.ts} +0 -0
- /package/src/engine/graphics/sh3/lpv/{sh3_bake_depth.d.ts → depth/sh3_bake_depth.d.ts} +0 -0
- /package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_along_ray.d.ts → sorting/build_bvh_nodes_distances_along_ray.d.ts} +0 -0
- /package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_sqr_to_point.d.ts → sorting/build_bvh_nodes_distances_sqr_to_point.d.ts} +0 -0
- /package/src/engine/graphics/sh3/path_tracer/{sort_bvh_nodes_by_distance_to_point.d.ts → sorting/sort_bvh_nodes_by_distance_to_point.d.ts} +0 -0
- /package/src/engine/graphics/sh3/{SH3VisualisationMaterial.d.ts → shader/SH3VisualisationMaterial.d.ts} +0 -0
|
@@ -1,25 +1,38 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { assert } from "../../../../../core/assert.js";
|
|
4
|
+
import { array_copy } from "../../../../../core/collection/array/array_copy.js";
|
|
5
|
+
import { compute_polygon_area_2d } from "../../../../../core/geom/2d/compute_polygon_area_2d.js";
|
|
4
6
|
import { convex_hull_jarvis_2d } from "../../../../../core/geom/2d/convex-hull/convex_hull_jarvis_2d.js";
|
|
5
7
|
import { fixed_convex_hull_relaxation } from "../../../../../core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js";
|
|
6
|
-
import { array_copy } from "../../../../../core/collection/array/array_copy.js";
|
|
7
|
-
import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
|
|
8
8
|
import { max2 } from "../../../../../core/math/max2.js";
|
|
9
|
-
import {
|
|
9
|
+
import { renderSamplerFromTexture } from "../../../render/visibility/hiz/buildCanvasViewFromTexture.js";
|
|
10
|
+
import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
|
|
10
11
|
import {
|
|
11
12
|
make_edge_condition_channel_threshold
|
|
12
13
|
} from "../../../texture/sampler/search/make_edge_condition_channel_threshold.js";
|
|
13
|
-
import {
|
|
14
|
+
import { sampler2d_find_pixels } from "../../../texture/sampler/search/sampler2d_find_pixels.js";
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* TODO For this specific use-case with octahedral impostors we can get away tracing a circular shape in general.
|
|
17
18
|
* A circle is a lot easier to quantize (as long as we make sure we place edges outside of the circle)
|
|
18
19
|
* @param {ImpostorDescription} impostor
|
|
19
20
|
* @param {THREE.WebGLRenderer} renderer
|
|
20
|
-
* @
|
|
21
|
+
* @param {number} vertex_limit how many vertices to use for the billboard, more vertices will provide better fit and lower area reducing overdraw at the cost of extra triangles. Prefer values between 4 and 16
|
|
22
|
+
* @returns {number[]}
|
|
21
23
|
*/
|
|
22
|
-
export function build_cutout_from_atlas_by_alpha(
|
|
24
|
+
export function build_cutout_from_atlas_by_alpha({
|
|
25
|
+
|
|
26
|
+
impostor,
|
|
27
|
+
renderer,
|
|
28
|
+
vertex_limit = 8
|
|
29
|
+
}) {
|
|
30
|
+
|
|
31
|
+
assert.isNonNegativeInteger(vertex_limit, 'vertex_limit');
|
|
32
|
+
assert.greaterThanOrEqual(vertex_limit, 3);
|
|
33
|
+
|
|
34
|
+
assert.defined(renderer, 'renderer');
|
|
35
|
+
|
|
23
36
|
// get impostor data first
|
|
24
37
|
|
|
25
38
|
const ctrl = renderSamplerFromTexture({
|
|
@@ -98,23 +111,21 @@ export function build_cutout_from_atlas_by_alpha(impostor, renderer) {
|
|
|
98
111
|
array_copy(filtered_edge_pixels, hpi * 2, hull_points, i * 2, 2);
|
|
99
112
|
}
|
|
100
113
|
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
const cutout_points = new Float32Array(cutout_vertex_count * 2);
|
|
114
|
+
const cutout_points = new Float32Array(vertex_limit * 2);
|
|
104
115
|
|
|
105
|
-
fixed_convex_hull_relaxation(cutout_points, 0,
|
|
116
|
+
fixed_convex_hull_relaxation(cutout_points, 0, vertex_limit, hull_points, hull_point_indices.length);
|
|
106
117
|
|
|
107
118
|
// normalize points
|
|
108
|
-
for (let i = 0; i <
|
|
119
|
+
for (let i = 0; i < vertex_limit; i++) {
|
|
109
120
|
cutout_points[i * 2] /= frame_size;
|
|
110
121
|
cutout_points[i * 2 + 1] /= frame_size;
|
|
111
122
|
}
|
|
112
123
|
|
|
113
|
-
const area = compute_polygon_area_2d(cutout_points,
|
|
124
|
+
const area = compute_polygon_area_2d(cutout_points, vertex_limit);
|
|
114
125
|
|
|
115
126
|
console.log(`Cutout area: ${area}`);
|
|
116
127
|
|
|
117
|
-
if (area >= 0.99 &&
|
|
128
|
+
if (area >= 0.99 && vertex_limit >= 4) {
|
|
118
129
|
// default back to aligned quad, produced result is a degradation
|
|
119
130
|
return new Float32Array([
|
|
120
131
|
0, 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaterialTransformer.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/gi/material/MaterialTransformer.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MaterialTransformer.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/gi/material/MaterialTransformer.js"],"names":[],"mappings":"AAiCA;IA0II;;;OAGG;IACH,0CAOC;IAnBD;;;OAGG;IACH,2BAEC;IAdD;;;OAGG;IACH,wBAEC;IAuBD,sBAIC;IAED,sBA2CC;IAED,eA+CC;IAED,4BA2BC;;CACJ;4CAlT2C,0DAA0D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Vector3 } from "three";
|
|
2
2
|
import { BinaryDataType } from "../../../../../core/binary/type/BinaryDataType.js";
|
|
3
3
|
import { AABB3 } from "../../../../../core/geom/3d/aabb/AABB3.js";
|
|
4
4
|
import { aabb3_from_v3_array } from "../../../../../core/geom/3d/aabb/aabb3_from_v3_array.js";
|
|
@@ -7,38 +7,29 @@ import { composeCompile } from "../../../material/composeCompile.js";
|
|
|
7
7
|
import { AbstractMaterialTransformer } from "../../../material/manager/AbstractMaterialTransformer.js";
|
|
8
8
|
import { isLitMaterial } from "../../../render/forward_plus/plugin/isLitMaterial.js";
|
|
9
9
|
import { AttributeDataTexture } from "../../../texture/AttributeDataTexture.js";
|
|
10
|
-
import { vector_buffer_to_attribute_texture } from "../../lpv/probe_volume_to_textures.js";
|
|
10
|
+
import { octahedral_depth_to_atlas, vector_buffer_to_attribute_texture } from "../../lpv/probe_volume_to_textures.js";
|
|
11
11
|
import { tetrahedral_mesh_to_texture } from "../tetrahedral_mesh_to_texture.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { makeLookupTexture3D } from "./makeLookupTexture3D.js";
|
|
13
|
+
import { makeOctahedralDepthAtlas } from "./makeOctahedralDepthAtlas.js";
|
|
14
|
+
import { space_fragment_transform_shader } from "./space_fragment/space_fragment_transform_shader.js";
|
|
15
|
+
import { space_vertex_transform_shader } from "./space_vertex/space_vertex_transform_shader.js";
|
|
14
16
|
|
|
15
17
|
const PROPERTY_TRANSFORMER_MARKER = '@light-probe-volume-material-transformer';
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
lookup.magFilter = NearestFilter;
|
|
32
|
-
lookup.minFilter = NearestFilter;
|
|
33
|
-
|
|
34
|
-
lookup.type = UnsignedIntType;
|
|
35
|
-
lookup.format = RedIntegerFormat;
|
|
36
|
-
lookup.internalFormat = "R32UI";
|
|
37
|
-
|
|
38
|
-
lookup.needsUpdate = true;
|
|
39
|
-
|
|
40
|
-
return lookup;
|
|
41
|
-
}
|
|
19
|
+
/**
|
|
20
|
+
* Where should probes be resolved?
|
|
21
|
+
* @enum {number}
|
|
22
|
+
*/
|
|
23
|
+
const ProbeResolutionSpace = {
|
|
24
|
+
/**
|
|
25
|
+
* Cheaper, but less precise
|
|
26
|
+
*/
|
|
27
|
+
Vertex: 0,
|
|
28
|
+
/**
|
|
29
|
+
* More expensive, necessary for large geometries with few vertices
|
|
30
|
+
*/
|
|
31
|
+
Fragment: 1
|
|
32
|
+
};
|
|
42
33
|
|
|
43
34
|
export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
44
35
|
|
|
@@ -48,9 +39,15 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
|
48
39
|
*/
|
|
49
40
|
#volume = null;
|
|
50
41
|
|
|
51
|
-
#mesh_lookup =
|
|
42
|
+
#mesh_lookup = makeLookupTexture3D(32);
|
|
52
43
|
#mesh_bounds = new AABB3();
|
|
53
44
|
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @type {ProbeResolutionSpace|number}
|
|
48
|
+
*/
|
|
49
|
+
#space = ProbeResolutionSpace.Fragment
|
|
50
|
+
|
|
54
51
|
#textures = {
|
|
55
52
|
vertex: new AttributeDataTexture(
|
|
56
53
|
AttributeSpec.fromJSON({
|
|
@@ -87,7 +84,8 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
|
87
84
|
normalized: false
|
|
88
85
|
}),
|
|
89
86
|
256, 9
|
|
90
|
-
)
|
|
87
|
+
),
|
|
88
|
+
depth: makeOctahedralDepthAtlas()
|
|
91
89
|
};
|
|
92
90
|
|
|
93
91
|
#uniforms = {
|
|
@@ -107,6 +105,13 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
|
107
105
|
type: "t",
|
|
108
106
|
value: this.#textures.harmonics.texture
|
|
109
107
|
},
|
|
108
|
+
lpv_t_probe_depth: {
|
|
109
|
+
type: "t",
|
|
110
|
+
value: this.#textures.depth
|
|
111
|
+
},
|
|
112
|
+
lpv_u_probe_depth_resolution: {
|
|
113
|
+
value: 1
|
|
114
|
+
},
|
|
110
115
|
lpv_t_mesh_lookup: {
|
|
111
116
|
type: "t",
|
|
112
117
|
value: this.#mesh_lookup
|
|
@@ -134,8 +139,16 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
|
134
139
|
#onBeforeCompile = (shader) => {
|
|
135
140
|
Object.assign(shader.uniforms, this.#uniforms);
|
|
136
141
|
|
|
137
|
-
|
|
138
|
-
|
|
142
|
+
switch (this.#space) {
|
|
143
|
+
case ProbeResolutionSpace.Vertex:
|
|
144
|
+
space_vertex_transform_shader(shader);
|
|
145
|
+
break;
|
|
146
|
+
case ProbeResolutionSpace.Fragment:
|
|
147
|
+
space_fragment_transform_shader(shader);
|
|
148
|
+
break;
|
|
149
|
+
default:
|
|
150
|
+
throw new Error(`Unsupported resolution space ${this.#space}`);
|
|
151
|
+
}
|
|
139
152
|
};
|
|
140
153
|
|
|
141
154
|
#materials = [];
|
|
@@ -166,6 +179,7 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
|
166
179
|
super();
|
|
167
180
|
|
|
168
181
|
this.#volume = volume;
|
|
182
|
+
|
|
169
183
|
}
|
|
170
184
|
|
|
171
185
|
update_bounds() {
|
|
@@ -204,7 +218,7 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
|
204
218
|
const w_y = n_y * bounds.getExtentsY() + bounds.y0;
|
|
205
219
|
const w_z = n_z * bounds.getExtentsZ() + bounds.z0;
|
|
206
220
|
|
|
207
|
-
const tet = volume.mesh.
|
|
221
|
+
const tet = volume.mesh.walkToTetraContainingPoint(w_x, w_y, w_z, volume.points, last_tet);
|
|
208
222
|
|
|
209
223
|
if (tet !== -1) {
|
|
210
224
|
last_tet = tet;
|
|
@@ -232,15 +246,19 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
|
232
246
|
|
|
233
247
|
this.update_lookup();
|
|
234
248
|
|
|
235
|
-
|
|
249
|
+
const uniforms = this.#uniforms;
|
|
236
250
|
|
|
237
|
-
|
|
251
|
+
uniforms.lpv_u_mesh_tet_count.value = lpv.mesh.count;
|
|
252
|
+
|
|
253
|
+
uniforms.lpv_v3_bounds_min.value.set(
|
|
238
254
|
this.#mesh_bounds.x0, this.#mesh_bounds.y0, this.#mesh_bounds.z0
|
|
239
255
|
);
|
|
240
|
-
|
|
256
|
+
uniforms.lpv_v3_bounds_max.value.set(
|
|
241
257
|
this.#mesh_bounds.x1, this.#mesh_bounds.y1, this.#mesh_bounds.z1
|
|
242
258
|
);
|
|
243
259
|
|
|
260
|
+
uniforms.lpv_u_probe_depth_resolution.value = lpv.depth_map_resolution;
|
|
261
|
+
|
|
244
262
|
this.#uniform_version = lpv.version;
|
|
245
263
|
|
|
246
264
|
console.time('prepareTextures');
|
|
@@ -250,9 +268,13 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
|
250
268
|
tetrahedral_mesh_to_texture(
|
|
251
269
|
this.#textures.vertex, this.#textures.neighbour, lpv.mesh
|
|
252
270
|
);
|
|
271
|
+
octahedral_depth_to_atlas(lpv, this.#textures.depth.image.data, this.#textures.depth.image.width);
|
|
272
|
+
this.#textures.depth.needsUpdate = true;
|
|
253
273
|
|
|
254
274
|
console.timeEnd('prepareTextures');
|
|
255
275
|
|
|
276
|
+
console.log(this.#textures);
|
|
277
|
+
|
|
256
278
|
for (let i = 0; i < this.#materials.length; i++) {
|
|
257
279
|
const material = this.#materials[i];
|
|
258
280
|
|