@woosh/meep-engine 2.33.3 → 2.33.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/core/bvh2/LeafNode.js +6 -1
- package/core/bvh2/aabb3/AABB3.js +21 -1
- package/core/bvh2/aabb3/aabb3_intersects_frustum.js +10 -2
- package/core/collection/RingBuffer.js +40 -10
- package/core/collection/array/copyArray.js +2 -2
- package/core/collection/array/typed/typed_array_copy.js +2 -2
- package/core/collection/set/compute_set_difference.js +32 -0
- package/core/collection/set/compute_set_intersection.js +22 -0
- package/core/collection/set/set_remove.js +15 -0
- package/core/collection/table/RowFirstTableSpec.js +8 -0
- package/core/color/Color.js +1 -0
- package/core/color/ColorUtils.js +12 -3
- package/core/geom/3d/aabb/aabb3_compute_projected_area.js +6 -4
- package/core/geom/3d/aabb/aabb3_estimate_projected_area2.js +59 -0
- package/core/geom/3d/aabb/aabb3_from_min_max.js +15 -0
- package/core/geom/3d/aabb/aabb3_matrix4_project.js +33 -0
- package/core/geom/3d/aabb/aabb3_matrix4_project.spec.js +41 -0
- package/core/geom/3d/aabb/aabb3_matrix4_project_by_corners.js +96 -0
- package/{engine/graphics/micron/render/v1 → core/geom/3d}/apply_mat4_transform_to_v3_array.js +0 -0
- package/{engine/graphics/micron/build/bounds → core/geom/3d}/compute_bounding_cone_of_2_cones.js +3 -3
- package/{engine/graphics/micron/build/bounds → core/geom/3d}/compute_bounding_cone_of_2_cones.spec.js +1 -1
- package/{engine/graphics/micron/build/bounds → core/geom/3d}/compute_bounding_sphere_of_2_spheres.js +3 -3
- package/{engine/graphics/micron/util → core/geom/3d}/encode_unit3_hemioct.js +0 -0
- package/core/geom/3d/frustum/array_normalize_plane.js +25 -0
- package/core/geom/3d/frustum/array_setFromProjectionMatrix.js +60 -0
- package/{engine/graphics/micron/util → core/geom/3d}/unit_hemioct.spec.js +1 -1
- package/{engine/graphics/micron/build → core}/graph/MultiNode.js +0 -0
- package/{engine/graphics/micron/build → core}/graph/SquareMatrix.js +2 -2
- package/{engine/graphics/micron/build → core}/graph/SquareMatrix.spec.js +1 -1
- package/{engine/graphics/micron/build → core}/graph/WeightedEdge.js +1 -1
- package/{engine/graphics/micron/build → core}/graph/build_face_graph_from_mesh.js +2 -2
- package/{engine/graphics/micron/build/clustering → core/graph}/cluster_mesh_metis.js +2 -6
- package/{engine/graphics/micron/build → core}/graph/coarsen_graph.js +1 -1
- package/{engine/graphics/micron/build → core}/graph/coarsen_graph.spec.js +1 -1
- package/{engine/graphics/micron/build → core}/graph/eigen/eigen.js +0 -0
- package/{engine/graphics/micron/build → core}/graph/eigen/eigen.spec.js +1 -1
- package/{engine/graphics/micron/build/hierarchy → core/graph/eigen}/eigen_values_find_spectral_gap.js +0 -0
- package/{engine/graphics/micron/build → core}/graph/graph_adjacency_matrix.js +0 -0
- package/{engine/graphics/micron/build → core}/graph/graph_compute_disconnected_clusters.js +0 -0
- package/{engine/graphics/micron/build → core}/graph/graph_degree_matrix.js +0 -0
- package/{engine/graphics/micron/build → core}/graph/graph_k_means_cluster.js +5 -5
- package/{engine/graphics/micron/build → core}/graph/graph_laplacian_matrix.js +1 -1
- package/{engine/graphics/micron/build → core}/graph/metis/metis.js +2 -2
- package/{engine/graphics/micron/build → core}/graph/metis/metis_options.js +0 -0
- package/{engine/graphics/micron/build → core}/graph/mn_graph_collapse_weighted_edge.js +0 -0
- package/core/process/undo/ActionProcessor.d.ts +2 -0
- package/core/process/undo/ActionProcessor.js +59 -1
- package/core/process/undo/ActionProcessor.spec.js +59 -0
- package/core/process/undo/Mark.js +2 -1
- package/engine/Engine.d.ts +2 -0
- package/engine/EngineHarness.js +4 -4
- package/engine/asset/loaders/material/bitmap2sampler_gl.js +19 -0
- package/engine/asset/loaders/material/computeImageBitmapEquality.js +7 -19
- package/engine/ecs/transform/Transform.js +2 -1
- package/engine/graphics/GraphicsEngine.js +9 -116
- package/engine/graphics/ecs/mesh/updateNodeByTransformAndBBB.js +22 -37
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +155 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +68 -0
- package/engine/graphics/ecs/mesh-v2/prototypeShadedGeometry.js +31 -0
- package/engine/graphics/filter/FlipArrayInPlace.js +25 -0
- package/engine/graphics/filter/FlipArrayViaCanvas.js +13 -0
- package/engine/graphics/filter/ImageFilter.js +20 -51
- package/engine/graphics/{micron → geometry}/aabb3_to_buffer_geometry.js +0 -0
- package/engine/graphics/{micron/build → geometry/buffered}/compute_buffer_geometry_byte_size.js +0 -0
- package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +25 -16
- package/engine/graphics/material/SplatMaterial.js +4 -97
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +2 -6
- package/engine/graphics/micron/build/clustering/build_clustering_2.js +2 -2
- package/engine/graphics/micron/build/clustering/build_leaf_patches_metis.js +1 -1
- package/engine/graphics/micron/build/fill_patch_geometry_data.js +2 -0
- package/engine/graphics/micron/build/hierarchy/buildAbstractPatchHierarchy.js +3 -3
- package/engine/graphics/micron/build/hierarchy/build_intermediate_patch_topology.js +0 -72
- package/engine/graphics/micron/build/hierarchy/build_merge_graph.js +2 -2
- package/engine/graphics/micron/build/hierarchy/computePatchMergeScore.js +3 -3
- package/engine/graphics/micron/build/hierarchy/merge_patches.js +6 -3
- package/engine/graphics/micron/build/hierarchy/metis_cluster_clusters.js +1 -1
- package/engine/graphics/micron/build/hierarchy/optimize_graph_partitioning_balance.js +1 -1
- package/engine/graphics/micron/build/hierarchy/patch_combine.js +2 -2
- package/engine/graphics/micron/build/hierarchy/qvdr_build_simplified_clusters.js +2 -1
- package/engine/graphics/micron/format/MicronGeometryBufferAttributeSpec.js +1 -1
- package/engine/graphics/micron/format/MicronGeometryPatch.js +11 -3
- package/engine/graphics/micron/format/MicronVertexDataSpec.js +25 -3
- package/engine/graphics/micron/prototypeVirtualGeometry.js +4 -4
- package/engine/graphics/micron/render/VirtualGeometryBuilder.js +28 -26
- package/engine/graphics/micron/render/culling/{PathCullingSystem.js → PatchCullingSystem.js} +1 -1
- package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +2 -4
- package/engine/graphics/micron/render/refinement/ActivePatchList.js +40 -80
- package/engine/graphics/micron/render/refinement/ActivePatchRecord.js +4 -2
- package/engine/graphics/micron/render/refinement/RefinementSpec.js +98 -0
- package/engine/graphics/micron/render/v1/MaterialVertexSpec.js +21 -0
- package/engine/graphics/micron/render/v1/VGThreeRenderer.js +12 -9
- package/engine/graphics/micron/render/v1/getTransformedPositionsCached.js +1 -1
- package/engine/graphics/render/buffer/buffers/ColorAndDepthFrameBuffer.js +5 -3
- package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +8 -10
- package/engine/graphics/render/forward_plus/LightManager.js +5 -7
- package/engine/graphics/render/forward_plus/data/NumericType.js +9 -0
- package/engine/graphics/render/forward_plus/{TextureBackedMemoryRegion.js → data/TextureBackedMemoryRegion.js} +11 -190
- package/engine/graphics/render/forward_plus/data/channelCountToThreIntegerTextureType.js +16 -0
- package/engine/graphics/render/forward_plus/data/computeDataType.js +36 -0
- package/engine/graphics/render/forward_plus/data/computeThreeTextureFormat.js +18 -0
- package/engine/graphics/render/forward_plus/data/computeThreeTextureInternalFormatFromDataType.js +63 -0
- package/engine/graphics/render/forward_plus/data/computeThreeTextureTypeFromDataType.js +41 -0
- package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
- package/engine/graphics/render/forward_plus/prototypeLightManager.js +1 -1
- package/engine/graphics/render/visibility/hiz/buffer/HierarchicalZBuffer.js +198 -0
- package/engine/graphics/render/visibility/hiz/buffer/ReductionShader.js +51 -0
- package/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +179 -0
- package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +435 -0
- package/engine/graphics/render/visibility/hiz/query/BatchOcclusionQuery.js +174 -0
- package/engine/graphics/render/visibility/hiz/query/QueryShader.js +173 -0
- package/engine/graphics/shadows/ShadowMapRenderer.js +12 -2
- package/engine/graphics/texture/cubemap/buildCubeURLs.js +13 -0
- package/engine/graphics/texture/cubemap/load_environment_map.d.ts +8 -0
- package/engine/graphics/texture/cubemap/load_environment_map.js +163 -0
- package/engine/graphics/texture/sampler/Sampler2D.js +18 -62
- package/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +3 -2
- package/engine/graphics/texture/sampler/debug/paintSamplerOnHTML.js +3 -2
- package/engine/graphics/texture/sampler/differenceSampler.js +31 -0
- package/engine/graphics/texture/sampler/typedArrayConstructorByInstance.js +25 -0
- package/engine/graphics/texture/sampler/util/drawSamplerHTML.js +3 -2
- package/engine/graphics/texture/virtual/v2/ShaderUsage.js +6 -5
- package/engine/graphics/texture/virtual/v2/prototype.js +16 -6
- package/engine/plugin/EnginePluginManager.d.ts +9 -0
- package/engine/reference/v2/Reference.d.ts +7 -0
- package/package.json +1 -1
- package/view/minimap/gl/MinimapMarkersGL.js +2 -2
- package/engine/graphics/micron/build/clustering/cluster_mesh_vertices.js +0 -3
- package/engine/graphics/micron/render/RefinementSpec.js +0 -159
|
@@ -1,36 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
RGIntegerFormat,
|
|
13
|
-
ShortType,
|
|
14
|
-
UnsignedByteType,
|
|
15
|
-
UnsignedIntType,
|
|
16
|
-
UnsignedShortType
|
|
17
|
-
} from "three";
|
|
18
|
-
import { DataType } from "../../../../core/collection/table/DataType.js";
|
|
19
|
-
import { assert } from "../../../../core/assert.js";
|
|
20
|
-
import { DataType2TypedArrayConstructorMapping } from "../../../../core/collection/table/DataType2TypedArrayConstructorMapping.js";
|
|
21
|
-
import { max2 } from "../../../../core/math/max2.js";
|
|
22
|
-
import { channelCountToThreeTextureFormat } from "../../texture/channelCountToThreeTextureFormat.js";
|
|
23
|
-
import { DataTypeByteSizes } from "../../../../core/collection/table/RowFirstTableSpec.js";
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* @enum {number}
|
|
28
|
-
*/
|
|
29
|
-
export const NumericType = {
|
|
30
|
-
Uint: 0,
|
|
31
|
-
Int: 1,
|
|
32
|
-
Float: 2
|
|
33
|
-
};
|
|
1
|
+
import { DataTexture, NearestFilter, RedFormat, UnsignedByteType } from "three";
|
|
2
|
+
import { DataType } from "../../../../../core/collection/table/DataType.js";
|
|
3
|
+
import { assert } from "../../../../../core/assert.js";
|
|
4
|
+
import { DataType2TypedArrayConstructorMapping } from "../../../../../core/collection/table/DataType2TypedArrayConstructorMapping.js";
|
|
5
|
+
import { max2 } from "../../../../../core/math/max2.js";
|
|
6
|
+
import { DataTypeByteSizes } from "../../../../../core/collection/table/RowFirstTableSpec.js";
|
|
7
|
+
import { NumericType } from "./NumericType.js";
|
|
8
|
+
import { computeDataType } from "./computeDataType.js";
|
|
9
|
+
import { computeThreeTextureTypeFromDataType } from "./computeThreeTextureTypeFromDataType.js";
|
|
10
|
+
import { computeThreeTextureInternalFormatFromDataType } from "./computeThreeTextureInternalFormatFromDataType.js";
|
|
11
|
+
import { computeThreeTextureFormat } from "./computeThreeTextureFormat.js";
|
|
34
12
|
|
|
35
13
|
/**
|
|
36
14
|
* How wide a data texture is
|
|
@@ -42,163 +20,6 @@ const SHRINK_FACTOR = 0.5;
|
|
|
42
20
|
const GROW_FACTOR = 1.05;
|
|
43
21
|
|
|
44
22
|
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
* @param {NumericType} type
|
|
48
|
-
* @param {number} precision
|
|
49
|
-
* @returns {DataType}
|
|
50
|
-
*/
|
|
51
|
-
export function computeDataType(type, precision) {
|
|
52
|
-
if (type === NumericType.Uint) {
|
|
53
|
-
if (precision <= 8) {
|
|
54
|
-
return DataType.Uint8;
|
|
55
|
-
} else if (precision <= 16) {
|
|
56
|
-
return DataType.Uint16;
|
|
57
|
-
} else if (precision <= 32) {
|
|
58
|
-
return DataType.Uint32;
|
|
59
|
-
}
|
|
60
|
-
} else if (type === NumericType.Int) {
|
|
61
|
-
if (precision <= 8) {
|
|
62
|
-
return DataType.Int8;
|
|
63
|
-
} else if (precision <= 16) {
|
|
64
|
-
return DataType.Int16;
|
|
65
|
-
} else if (precision <= 32) {
|
|
66
|
-
return DataType.Int32;
|
|
67
|
-
}
|
|
68
|
-
} else if (type === NumericType.Float) {
|
|
69
|
-
if (precision <= 32) {
|
|
70
|
-
return DataType.Float32;
|
|
71
|
-
} else if (precision <= 64) {
|
|
72
|
-
return DataType.Float64;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
throw new Error(`Unsupported numeric type(=${type}) and precision(=${precision}) combination`);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
*
|
|
81
|
-
* @param {DataType} dt
|
|
82
|
-
* @returns {number}
|
|
83
|
-
*/
|
|
84
|
-
export function computeThreeTextureTypeFromDataType(dt) {
|
|
85
|
-
switch (dt) {
|
|
86
|
-
case DataType.Uint8:
|
|
87
|
-
return UnsignedByteType;
|
|
88
|
-
case DataType.Uint16:
|
|
89
|
-
return UnsignedShortType;
|
|
90
|
-
case DataType.Uint32:
|
|
91
|
-
return UnsignedIntType;
|
|
92
|
-
case DataType.Int8:
|
|
93
|
-
return ByteType;
|
|
94
|
-
case DataType.Int16:
|
|
95
|
-
return ShortType;
|
|
96
|
-
case DataType.Int32:
|
|
97
|
-
return IntType;
|
|
98
|
-
case DataType.Float16:
|
|
99
|
-
return HalfFloatType;
|
|
100
|
-
case DataType.Float32:
|
|
101
|
-
return FloatType;
|
|
102
|
-
case DataType.Float64:
|
|
103
|
-
return FloatType;
|
|
104
|
-
default:
|
|
105
|
-
throw new Error(`Unsupported data type '${dt}'`);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
*
|
|
112
|
-
* @param {DataType} dt
|
|
113
|
-
* @param {number} channel_count
|
|
114
|
-
* @returns {string|THREE.PixelFormatGPU}
|
|
115
|
-
*/
|
|
116
|
-
export function computeThreeTextureInternalFormatFromDataType(dt, channel_count) {
|
|
117
|
-
let suffix = '';
|
|
118
|
-
switch (dt) {
|
|
119
|
-
case DataType.Uint8:
|
|
120
|
-
suffix = '8UI';
|
|
121
|
-
break;
|
|
122
|
-
case DataType.Uint16:
|
|
123
|
-
suffix = '16UI';
|
|
124
|
-
break;
|
|
125
|
-
case DataType.Uint32:
|
|
126
|
-
suffix = '32UI';
|
|
127
|
-
break;
|
|
128
|
-
case DataType.Int8:
|
|
129
|
-
suffix = '8I';
|
|
130
|
-
break;
|
|
131
|
-
case DataType.Int16:
|
|
132
|
-
suffix = '16I';
|
|
133
|
-
break;
|
|
134
|
-
case DataType.Int32:
|
|
135
|
-
suffix = '32I';
|
|
136
|
-
break;
|
|
137
|
-
case DataType.Float16:
|
|
138
|
-
suffix = '16F';
|
|
139
|
-
break;
|
|
140
|
-
case DataType.Float32:
|
|
141
|
-
suffix = '32F';
|
|
142
|
-
break;
|
|
143
|
-
case DataType.Float64:
|
|
144
|
-
suffix = '64F';
|
|
145
|
-
break;
|
|
146
|
-
default:
|
|
147
|
-
throw new Error(`Unsupported data type '${dt}'`);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
let prefix = '';
|
|
151
|
-
|
|
152
|
-
switch (channel_count) {
|
|
153
|
-
case 1:
|
|
154
|
-
prefix = 'R';
|
|
155
|
-
break;
|
|
156
|
-
case 2:
|
|
157
|
-
prefix = 'RG';
|
|
158
|
-
break;
|
|
159
|
-
case 3:
|
|
160
|
-
prefix = 'RGB';
|
|
161
|
-
break;
|
|
162
|
-
case 4:
|
|
163
|
-
prefix = 'RGBA';
|
|
164
|
-
break;
|
|
165
|
-
default:
|
|
166
|
-
throw new Error(`Unsupported channel count '${channel_count}'`);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return prefix + suffix;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function channelCountToThreIntegerTextureType(channel_count) {
|
|
173
|
-
switch (channel_count) {
|
|
174
|
-
case 1:
|
|
175
|
-
return RedIntegerFormat;
|
|
176
|
-
case 2:
|
|
177
|
-
return RGIntegerFormat;
|
|
178
|
-
case 3:
|
|
179
|
-
return RGBIntegerFormat;
|
|
180
|
-
case 4:
|
|
181
|
-
return RGBAIntegerFormat;
|
|
182
|
-
default:
|
|
183
|
-
throw new Error(`Unsupported channel count '${channel_count}'`);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
*
|
|
189
|
-
* @param {NumericType} type
|
|
190
|
-
* @param {number} channel_count
|
|
191
|
-
*/
|
|
192
|
-
function computeThreeTextureFormat(type, channel_count) {
|
|
193
|
-
if (type === NumericType.Uint || type === NumericType.Int) {
|
|
194
|
-
return channelCountToThreIntegerTextureType(channel_count);
|
|
195
|
-
} else if (type === NumericType.Float) {
|
|
196
|
-
return channelCountToThreeTextureFormat(channel_count);
|
|
197
|
-
} else {
|
|
198
|
-
throw new Error(`Unsupported numeric type '${type}'`);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
23
|
export class TextureBackedMemoryRegion {
|
|
203
24
|
|
|
204
25
|
constructor() {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RedIntegerFormat, RGBAIntegerFormat, RGBIntegerFormat, RGIntegerFormat } from "three";
|
|
2
|
+
|
|
3
|
+
export function channelCountToThreIntegerTextureType(channel_count) {
|
|
4
|
+
switch (channel_count) {
|
|
5
|
+
case 1:
|
|
6
|
+
return RedIntegerFormat;
|
|
7
|
+
case 2:
|
|
8
|
+
return RGIntegerFormat;
|
|
9
|
+
case 3:
|
|
10
|
+
return RGBIntegerFormat;
|
|
11
|
+
case 4:
|
|
12
|
+
return RGBAIntegerFormat;
|
|
13
|
+
default:
|
|
14
|
+
throw new Error(`Unsupported channel count '${channel_count}'`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { NumericType } from "./NumericType.js";
|
|
2
|
+
import { DataType } from "../../../../../core/collection/table/DataType.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {NumericType} type
|
|
7
|
+
* @param {number} precision
|
|
8
|
+
* @returns {DataType}
|
|
9
|
+
*/
|
|
10
|
+
export function computeDataType(type, precision) {
|
|
11
|
+
if (type === NumericType.Uint) {
|
|
12
|
+
if (precision <= 8) {
|
|
13
|
+
return DataType.Uint8;
|
|
14
|
+
} else if (precision <= 16) {
|
|
15
|
+
return DataType.Uint16;
|
|
16
|
+
} else if (precision <= 32) {
|
|
17
|
+
return DataType.Uint32;
|
|
18
|
+
}
|
|
19
|
+
} else if (type === NumericType.Int) {
|
|
20
|
+
if (precision <= 8) {
|
|
21
|
+
return DataType.Int8;
|
|
22
|
+
} else if (precision <= 16) {
|
|
23
|
+
return DataType.Int16;
|
|
24
|
+
} else if (precision <= 32) {
|
|
25
|
+
return DataType.Int32;
|
|
26
|
+
}
|
|
27
|
+
} else if (type === NumericType.Float) {
|
|
28
|
+
if (precision <= 32) {
|
|
29
|
+
return DataType.Float32;
|
|
30
|
+
} else if (precision <= 64) {
|
|
31
|
+
return DataType.Float64;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
throw new Error(`Unsupported numeric type(=${type}) and precision(=${precision}) combination`);
|
|
36
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NumericType } from "./NumericType.js";
|
|
2
|
+
import { channelCountToThreIntegerTextureType } from "./channelCountToThreIntegerTextureType.js";
|
|
3
|
+
import { channelCountToThreeTextureFormat } from "../../../texture/channelCountToThreeTextureFormat.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {NumericType} type
|
|
8
|
+
* @param {number} channel_count
|
|
9
|
+
*/
|
|
10
|
+
export function computeThreeTextureFormat(type, channel_count) {
|
|
11
|
+
if (type === NumericType.Uint || type === NumericType.Int) {
|
|
12
|
+
return channelCountToThreIntegerTextureType(channel_count);
|
|
13
|
+
} else if (type === NumericType.Float) {
|
|
14
|
+
return channelCountToThreeTextureFormat(channel_count);
|
|
15
|
+
} else {
|
|
16
|
+
throw new Error(`Unsupported numeric type '${type}'`);
|
|
17
|
+
}
|
|
18
|
+
}
|
package/engine/graphics/render/forward_plus/data/computeThreeTextureInternalFormatFromDataType.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { DataType } from "../../../../../core/collection/table/DataType.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {DataType} dt
|
|
6
|
+
* @param {number} channel_count
|
|
7
|
+
* @returns {string|THREE.PixelFormatGPU}
|
|
8
|
+
*/
|
|
9
|
+
export function computeThreeTextureInternalFormatFromDataType(dt, channel_count) {
|
|
10
|
+
let suffix = '';
|
|
11
|
+
switch (dt) {
|
|
12
|
+
case DataType.Uint8:
|
|
13
|
+
suffix = '8UI';
|
|
14
|
+
break;
|
|
15
|
+
case DataType.Uint16:
|
|
16
|
+
suffix = '16UI';
|
|
17
|
+
break;
|
|
18
|
+
case DataType.Uint32:
|
|
19
|
+
suffix = '32UI';
|
|
20
|
+
break;
|
|
21
|
+
case DataType.Int8:
|
|
22
|
+
suffix = '8I';
|
|
23
|
+
break;
|
|
24
|
+
case DataType.Int16:
|
|
25
|
+
suffix = '16I';
|
|
26
|
+
break;
|
|
27
|
+
case DataType.Int32:
|
|
28
|
+
suffix = '32I';
|
|
29
|
+
break;
|
|
30
|
+
case DataType.Float16:
|
|
31
|
+
suffix = '16F';
|
|
32
|
+
break;
|
|
33
|
+
case DataType.Float32:
|
|
34
|
+
suffix = '32F';
|
|
35
|
+
break;
|
|
36
|
+
case DataType.Float64:
|
|
37
|
+
suffix = '64F';
|
|
38
|
+
break;
|
|
39
|
+
default:
|
|
40
|
+
throw new Error(`Unsupported data type '${dt}'`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let prefix = '';
|
|
44
|
+
|
|
45
|
+
switch (channel_count) {
|
|
46
|
+
case 1:
|
|
47
|
+
prefix = 'R';
|
|
48
|
+
break;
|
|
49
|
+
case 2:
|
|
50
|
+
prefix = 'RG';
|
|
51
|
+
break;
|
|
52
|
+
case 3:
|
|
53
|
+
prefix = 'RGB';
|
|
54
|
+
break;
|
|
55
|
+
case 4:
|
|
56
|
+
prefix = 'RGBA';
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
throw new Error(`Unsupported channel count '${channel_count}'`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return prefix + suffix;
|
|
63
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DataType } from "../../../../../core/collection/table/DataType.js";
|
|
2
|
+
import {
|
|
3
|
+
ByteType,
|
|
4
|
+
FloatType,
|
|
5
|
+
HalfFloatType,
|
|
6
|
+
IntType,
|
|
7
|
+
ShortType,
|
|
8
|
+
UnsignedByteType,
|
|
9
|
+
UnsignedIntType,
|
|
10
|
+
UnsignedShortType
|
|
11
|
+
} from "three";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param {DataType} dt
|
|
16
|
+
* @returns {number}
|
|
17
|
+
*/
|
|
18
|
+
export function computeThreeTextureTypeFromDataType(dt) {
|
|
19
|
+
switch (dt) {
|
|
20
|
+
case DataType.Uint8:
|
|
21
|
+
return UnsignedByteType;
|
|
22
|
+
case DataType.Uint16:
|
|
23
|
+
return UnsignedShortType;
|
|
24
|
+
case DataType.Uint32:
|
|
25
|
+
return UnsignedIntType;
|
|
26
|
+
case DataType.Int8:
|
|
27
|
+
return ByteType;
|
|
28
|
+
case DataType.Int16:
|
|
29
|
+
return ShortType;
|
|
30
|
+
case DataType.Int32:
|
|
31
|
+
return IntType;
|
|
32
|
+
case DataType.Float16:
|
|
33
|
+
return HalfFloatType;
|
|
34
|
+
case DataType.Float32:
|
|
35
|
+
return FloatType;
|
|
36
|
+
case DataType.Float64:
|
|
37
|
+
return FloatType;
|
|
38
|
+
default:
|
|
39
|
+
throw new Error(`Unsupported data type '${dt}'`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -45,7 +45,6 @@ import { SerializationMetadataSystem } from "../../../../ecs/systems/Serializati
|
|
|
45
45
|
import { InverseKinematicsSystem } from "../../../../ecs/animation/InverseKinematicsSystem.js";
|
|
46
46
|
import { PathDisplaySystem } from "../../../ecs/path/PathDisplaySystem.js";
|
|
47
47
|
import { Line, LineBasicMaterial, MeshStandardMaterial, TorusKnotBufferGeometry } from "three";
|
|
48
|
-
import { buildCubeURLs } from "../../../GraphicsEngine.js";
|
|
49
48
|
import RenderSystem from "../../../../ecs/systems/RenderSystem.js";
|
|
50
49
|
import { makeEngineOptionsModel } from "../../../../../../model/game/options/makeEngineOptionsModel.js";
|
|
51
50
|
import { enableEditor } from "../../../../../editor/enableEditor.js";
|
|
@@ -77,6 +76,7 @@ import { GameAssetType } from "../../../../asset/GameAssetType.js";
|
|
|
77
76
|
import { GLTFAssetLoader } from "../../../../asset/loaders/GLTFAssetLoader.js";
|
|
78
77
|
import { ImageRGBADataLoader } from "../../../../asset/loaders/image/ImageRGBADataLoader.js";
|
|
79
78
|
import { MicronRenderPlugin } from "../../../micron/plugin/MicronRenderPlugin.js";
|
|
79
|
+
import { buildCubeURLs } from "../../../texture/cubemap/buildCubeURLs.js";
|
|
80
80
|
|
|
81
81
|
const engineHarness = new EngineHarness();
|
|
82
82
|
|
|
@@ -233,7 +233,7 @@ function prepare_scene_0() {
|
|
|
233
233
|
|
|
234
234
|
controls.minDistance = 2;
|
|
235
235
|
|
|
236
|
-
for (let i = 0; i <
|
|
236
|
+
for (let i = 0; i < 500; i++) {
|
|
237
237
|
const radius = randomFloatBetween(random, 4, 4);
|
|
238
238
|
const intensity = randomFloatBetween(random, 2, 2);
|
|
239
239
|
addPointLight([
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { max2 } from "../../../../../../core/math/max2.js";
|
|
2
|
+
import { ceilPowerOfTwo } from "../../../../../../core/binary/operations/ceilPowerOfTwo.js";
|
|
3
|
+
import { ClampToEdgeWrapping, FloatType, NearestFilter, RedFormat, WebGLRenderTarget } from "three";
|
|
4
|
+
import { renderScreenSpace } from "../../../utils/renderScreenSpace.js";
|
|
5
|
+
import { makeReductionShader } from "./ReductionShader.js";
|
|
6
|
+
import Vector2 from "../../../../../../core/geom/Vector2.js";
|
|
7
|
+
|
|
8
|
+
export class HierarchicalZBuffer {
|
|
9
|
+
constructor() {
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @type {THREE.Texture|null}
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
this.__input_buffer = null;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @type {THREE.WebGLRenderer|null}
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
this.__renderer = null;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @type {THREE.WebGLRenderTarget[]}
|
|
27
|
+
*/
|
|
28
|
+
this.mips = [];
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @type {ShaderMaterial}
|
|
33
|
+
* @private
|
|
34
|
+
*/
|
|
35
|
+
this.__material = makeReductionShader();
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @type {Vector2}
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
this.__resolution = new Vector2(0, 0);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @type {Vector2}
|
|
48
|
+
* @private
|
|
49
|
+
*/
|
|
50
|
+
this.__limits = new Vector2(1, 1);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @return {Vector2}
|
|
56
|
+
*/
|
|
57
|
+
get mip_limits() {
|
|
58
|
+
return this.__limits;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {THREE.WebGLRenderer} v
|
|
63
|
+
*/
|
|
64
|
+
set renderer(v) {
|
|
65
|
+
this.__renderer = v;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @param {THREE.Texture} v
|
|
70
|
+
*/
|
|
71
|
+
set input(v) {
|
|
72
|
+
this.__input_buffer = v;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
build_mip_chain() {
|
|
76
|
+
const size_max = ceilPowerOfTwo(max2(this.__resolution.x, this.__resolution.y));
|
|
77
|
+
const mip_depth = Math.log2(size_max);
|
|
78
|
+
|
|
79
|
+
const mips = this.mips;
|
|
80
|
+
const existing_mip_depth = mips.length;
|
|
81
|
+
|
|
82
|
+
if (existing_mip_depth > mip_depth) {
|
|
83
|
+
|
|
84
|
+
for (let i = mip_depth; i < existing_mip_depth; i++) {
|
|
85
|
+
mips[i].dispose();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
mips.splice(mip_depth, existing_mip_depth - mip_depth);
|
|
89
|
+
|
|
90
|
+
} else {
|
|
91
|
+
|
|
92
|
+
for (let i = existing_mip_depth; i < mip_depth; i++) {
|
|
93
|
+
|
|
94
|
+
mips[i] = new WebGLRenderTarget(1, 1, {
|
|
95
|
+
minFilter: NearestFilter,
|
|
96
|
+
magFilter: NearestFilter,
|
|
97
|
+
format: RedFormat,
|
|
98
|
+
type: FloatType,
|
|
99
|
+
internalFormat: 'R32F',
|
|
100
|
+
depthBuffer: false,
|
|
101
|
+
stencilBuffer: false,
|
|
102
|
+
wrapS: ClampToEdgeWrapping,
|
|
103
|
+
wrapT: ClampToEdgeWrapping,
|
|
104
|
+
generateMipmaps: false
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
*
|
|
114
|
+
* @param {number} x
|
|
115
|
+
* @param {number} y
|
|
116
|
+
*/
|
|
117
|
+
set_resolution(x, y) {
|
|
118
|
+
this.__resolution.set(x, y);
|
|
119
|
+
|
|
120
|
+
const mips = this.mips;
|
|
121
|
+
const mip_count = mips.length;
|
|
122
|
+
|
|
123
|
+
let _x = ceilPowerOfTwo(x);
|
|
124
|
+
let _y = ceilPowerOfTwo(y);
|
|
125
|
+
|
|
126
|
+
for (let i = 0; i < mip_count; i++) {
|
|
127
|
+
const mip = mips[i];
|
|
128
|
+
|
|
129
|
+
const _nx = max2(1, _x >> 1);
|
|
130
|
+
const _ny = max2(1, _y >> 1);
|
|
131
|
+
|
|
132
|
+
if (mip.width !== _nx || mip.height !== _ny) {
|
|
133
|
+
mip.setSize(_nx, _ny);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (_nx === 1 && _x !== _nx) {
|
|
137
|
+
this.__limits.x = i;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (_ny === 1 && _y !== _ny) {
|
|
141
|
+
this.__limits.y = i;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
_x = _nx;
|
|
145
|
+
_y = _ny;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
build_mips() {
|
|
150
|
+
const mips = this.mips;
|
|
151
|
+
|
|
152
|
+
let t0 = null;
|
|
153
|
+
let t1 = {
|
|
154
|
+
texture: this.__input_buffer
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
for (let i = 0; i < mips.length; i++) {
|
|
158
|
+
t0 = t1;
|
|
159
|
+
t1 = mips[i];
|
|
160
|
+
|
|
161
|
+
this.reduce_mip(t0.texture, t1);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
this.__input_buffer.generateMipmaps = false;
|
|
165
|
+
this.__input_buffer.mips = mips.map(m => m.texture);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @private
|
|
170
|
+
* @param {THREE.Texture} input
|
|
171
|
+
* @param {THREE.WebGLRenderTarget} output
|
|
172
|
+
*/
|
|
173
|
+
reduce_mip(input, output) {
|
|
174
|
+
|
|
175
|
+
const material = this.__material;
|
|
176
|
+
material.uniforms.source_texture.value = input;
|
|
177
|
+
material.uniforms.destination_resolution.value.set(output.width, output.height);
|
|
178
|
+
material.uniforms.source_resolution.value.set(input.image.width, input.image.height);
|
|
179
|
+
|
|
180
|
+
const renderer = this.__renderer;
|
|
181
|
+
|
|
182
|
+
const __rt = renderer.getRenderTarget();
|
|
183
|
+
|
|
184
|
+
renderer.setRenderTarget(output);
|
|
185
|
+
|
|
186
|
+
renderScreenSpace(renderer, material);
|
|
187
|
+
|
|
188
|
+
renderer.setRenderTarget(__rt);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Depth texture with mips
|
|
193
|
+
* @returns {THREE.Texture}
|
|
194
|
+
*/
|
|
195
|
+
getTexture() {
|
|
196
|
+
return this.__input_buffer;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { GLSL3, ShaderMaterial, Vector2 } from "three";
|
|
2
|
+
|
|
3
|
+
export function makeReductionShader() {
|
|
4
|
+
return new ShaderMaterial({
|
|
5
|
+
vertexShader: `
|
|
6
|
+
void main() {
|
|
7
|
+
gl_Position = vec4( position, 1.0 );
|
|
8
|
+
}
|
|
9
|
+
`,
|
|
10
|
+
fragmentShader: `
|
|
11
|
+
uniform sampler2D source_texture;
|
|
12
|
+
|
|
13
|
+
uniform vec2 source_resolution;
|
|
14
|
+
uniform vec2 destination_resolution;
|
|
15
|
+
|
|
16
|
+
out highp float out_value;
|
|
17
|
+
|
|
18
|
+
float reduce(float a, float b, float c, float d){
|
|
19
|
+
return max( a, max( b, max( c, d ) ) );
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
void main() {
|
|
23
|
+
vec2 source_uv = gl_FragCoord.xy / destination_resolution;
|
|
24
|
+
vec2 uv_mapping = source_resolution/destination_resolution;
|
|
25
|
+
|
|
26
|
+
ivec2 source_texel_uv_0 = ivec2( source_uv * source_resolution);
|
|
27
|
+
|
|
28
|
+
float d0 = texelFetch(source_texture, source_texel_uv_0, 0).x;
|
|
29
|
+
float d1 = texelFetch(source_texture, source_texel_uv_0 + ivec2( uv_mapping.x, 0 ), 0).x;
|
|
30
|
+
float d2 = texelFetch(source_texture, source_texel_uv_0 + ivec2( 0, uv_mapping.y ), 0).x;
|
|
31
|
+
float d3 = texelFetch(source_texture, source_texel_uv_0 + ivec2( uv_mapping.x, uv_mapping.y ), 0).x;
|
|
32
|
+
|
|
33
|
+
out_value = reduce(d0, d1, d2, d3);
|
|
34
|
+
}
|
|
35
|
+
`,
|
|
36
|
+
depthTest: false,
|
|
37
|
+
depthWrite: false,
|
|
38
|
+
uniforms: {
|
|
39
|
+
source_texture: {
|
|
40
|
+
value: null
|
|
41
|
+
},
|
|
42
|
+
destination_resolution: {
|
|
43
|
+
value: new Vector2()
|
|
44
|
+
},
|
|
45
|
+
source_resolution: {
|
|
46
|
+
value: new Vector2()
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
glslVersion: GLSL3
|
|
50
|
+
});
|
|
51
|
+
}
|