@woosh/meep-engine 2.109.16 → 2.109.19
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 +86 -50
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +86 -50
- package/package.json +1 -1
- package/src/core/color/Color.d.ts.map +1 -1
- package/src/core/color/Color.js +29 -6
- package/src/core/color/rgb2uint24.js +1 -0
- package/src/core/color/rgb2uint32.d.ts +10 -0
- package/src/core/color/rgb2uint32.d.ts.map +1 -0
- package/src/core/color/rgb2uint32.js +18 -0
- package/src/core/geom/3d/Ray3.d.ts +1 -1
- package/src/core/geom/3d/Ray3.d.ts.map +1 -1
- package/src/core/geom/3d/Ray3.js +1 -1
- package/src/core/geom/3d/aabb/aabb3_raycast.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/aabb3_raycast.js +3 -2
- package/src/core/geom/3d/apply_mat4_transform_to_direction_v3_array.d.ts.map +1 -1
- package/src/core/geom/3d/apply_mat4_transform_to_direction_v3_array.js +3 -1
- package/src/core/geom/3d/decompose_matrix_4_array.js +4 -4
- package/src/core/geom/3d/frustum/frustum_from_projection_matrix_array.d.ts.map +1 -1
- package/src/core/geom/3d/frustum/frustum_from_projection_matrix_array.js +3 -1
- 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 +2 -1
- package/src/core/geom/3d/quaternion/quat_encode_to_uint32.d.ts.map +1 -1
- package/src/core/geom/3d/quaternion/quat_encode_to_uint32.js +2 -1
- package/src/core/geom/3d/ray/ray3_array_apply_matrix4.d.ts.map +1 -1
- package/src/core/geom/3d/ray/ray3_array_apply_matrix4.js +3 -1
- package/src/core/geom/3d/ray/ray3_interval_array_apply_matrix4.d.ts.map +1 -1
- package/src/core/geom/3d/ray/ray3_interval_array_apply_matrix4.js +3 -1
- package/src/core/geom/3d/shape/TransformedShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/TransformedShape3D.js +7 -6
- package/src/core/geom/3d/shape/UnitSphereShape3D.js +1 -1
- package/src/core/geom/3d/topology/tm_vertex_compute_normal.d.ts.map +1 -1
- package/src/core/geom/3d/topology/tm_vertex_compute_normal.js +2 -1
- package/src/core/geom/3d/v3_compute_triangle_normal.spec.js +2 -1
- package/src/core/geom/mat3/m3_rm_extract_scale.d.ts.map +1 -1
- package/src/core/geom/mat3/m3_rm_extract_scale.js +4 -2
- package/src/core/geom/vec2/v2_length.d.ts +8 -0
- package/src/core/geom/vec2/v2_length.d.ts.map +1 -0
- package/src/core/geom/vec2/v2_length.js +11 -0
- package/src/core/geom/vec3/v3_distance.d.ts.map +1 -1
- package/src/core/geom/vec3/v3_distance.js +3 -1
- package/src/core/geom/vec3/v3_length.js +1 -1
- package/src/core/geom/vec3/v3_matrix4_rotate.d.ts.map +1 -1
- package/src/core/geom/vec3/v3_matrix4_rotate.js +3 -1
- package/src/core/geom/vec3/v3_normalize_array.d.ts.map +1 -1
- package/src/core/geom/vec3/v3_normalize_array.js +3 -1
- package/src/core/json/abstractJSONSerializer.d.ts +1 -1
- package/src/core/json/abstractJSONSerializer.d.ts.map +1 -1
- package/src/core/json/abstractJSONSerializer.js +32 -6
- package/src/engine/asset/loaders/material/computeTextureHash.d.ts.map +1 -1
- package/src/engine/asset/loaders/material/computeTextureHash.js +5 -1
- package/src/engine/graphics/canvas/canvas2d_draw_linear_scale.d.ts.map +1 -1
- package/src/engine/graphics/canvas/canvas2d_draw_linear_scale.js +2 -1
- package/src/engine/graphics/ecs/highlight/HighlightDefinition.d.ts +3 -0
- package/src/engine/graphics/ecs/highlight/HighlightDefinition.d.ts.map +1 -1
- package/src/engine/graphics/ecs/highlight/HighlightDefinition.js +31 -28
- package/src/engine/graphics/ecs/path/tube/build/build_geometry_catmullrom.d.ts.map +1 -1
- package/src/engine/graphics/ecs/path/tube/build/build_geometry_catmullrom.js +2 -1
- package/src/engine/graphics/ecs/path/tube/build/compute_smooth_profile_normals.d.ts.map +1 -1
- package/src/engine/graphics/ecs/path/tube/build/compute_smooth_profile_normals.js +5 -3
- package/src/engine/graphics/ecs/path/tube/build/makeTubeGeometry.d.ts.map +1 -1
- package/src/engine/graphics/ecs/path/tube/build/makeTubeGeometry.js +2 -1
- package/src/engine/graphics/ecs/path/tube/build/make_cap.d.ts.map +1 -1
- package/src/engine/graphics/ecs/path/tube/build/make_cap.js +3 -2
- package/src/engine/graphics/ecs/path/tube/build/make_ring_vertices.d.ts.map +1 -1
- package/src/engine/graphics/ecs/path/tube/build/make_ring_vertices.js +6 -5
- package/src/engine/graphics/sh3/gi/material/common.glsl +51 -9
- package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts.map +1 -1
- package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.js +3 -3
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +5 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +11 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js +1 -1
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js +30 -15
- package/src/engine/graphics/sh3/lpv/depth/octahedral/stitching/frag.glsl +88 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/stitching/prototype.d.ts +2 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/stitching/prototype.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/stitching/prototype.js +96 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/stitching/vert.glsl +65 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.js +2 -1
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.frag.glsl +283 -27
- 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 +2 -6
- package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.js +1 -0
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/sampling/getBiasedNormalSample.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/sampling/getBiasedNormalSample.js +2 -1
- package/src/engine/graphics/sh3/path_tracer/sampling/getCosineDirection.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/sampling/getCosineDirection.js +2 -1
- package/src/engine/graphics/sh3/path_tracer/sampling/v3_orthonormal_matrix_from_normal.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/sampling/v3_orthonormal_matrix_from_normal.js +3 -1
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +8 -6
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
vec3 inverseTransformDirection(in vec3 normal, in mat4 matrix) {
|
|
4
2
|
// matrix is assumed to be orthogonal
|
|
5
3
|
return normalize((vec4(normal, 0.0) * matrix).xyz);
|
|
@@ -25,11 +23,22 @@ ivec2 lpv_index_to_256_coordinate(uint index) {
|
|
|
25
23
|
return ivec2(int(pixel_x), int(pixel_y));
|
|
26
24
|
}
|
|
27
25
|
|
|
26
|
+
float sign_not_zero(float x) {
|
|
27
|
+
return x >= 0.0 ? 1.0 : -1.0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
vec2 sign_not_zero(vec2 x) {
|
|
31
|
+
return vec2(
|
|
32
|
+
sign_not_zero(x.x),
|
|
33
|
+
sign_not_zero(x.y)
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
28
37
|
vec3 sign_not_zero(vec3 x) {
|
|
29
38
|
return vec3(
|
|
30
|
-
x.x
|
|
31
|
-
x.y
|
|
32
|
-
x.z
|
|
39
|
+
sign_not_zero(x.x),
|
|
40
|
+
sign_not_zero(x.y),
|
|
41
|
+
sign_not_zero(x.z)
|
|
33
42
|
);
|
|
34
43
|
}
|
|
35
44
|
|
|
@@ -56,23 +65,45 @@ vec4 quadBlendWieghts(vec2 coords)
|
|
|
56
65
|
return res;
|
|
57
66
|
}
|
|
58
67
|
|
|
59
|
-
|
|
60
|
-
|
|
68
|
+
//vec2 VecToSphereOct(vec3 v)
|
|
69
|
+
//{
|
|
70
|
+
// float l1norm = abs(v.x) + abs(v.y) + abs(v.z);
|
|
71
|
+
//
|
|
72
|
+
// vec2 result = v.xz / l1norm;
|
|
73
|
+
//
|
|
74
|
+
// if (v.y < 0.0) {
|
|
75
|
+
// result = (1.0 - abs(result.yx)) * sign_not_zero(result.xy);
|
|
76
|
+
// }
|
|
77
|
+
//
|
|
78
|
+
// return result;
|
|
79
|
+
//}
|
|
80
|
+
|
|
81
|
+
vec3 OctaSphereEnc(vec2 coord)
|
|
61
82
|
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
vec3 octahedron = direction / sum;
|
|
83
|
+
coord = (coord - 0.5) * 2.0;
|
|
84
|
+
vec3 position = vec3(coord.x, 0.0, coord.y);
|
|
85
|
+
vec2 absolute = abs(position.xz);
|
|
86
|
+
position.y = 1.0 - absolute.x - absolute.y;
|
|
67
87
|
|
|
68
|
-
if (
|
|
88
|
+
if (position.y < 0.0)
|
|
69
89
|
{
|
|
70
|
-
|
|
90
|
+
position.xz = sign(position.xz) * vec2(1.0 - absolute.y, 1.0 - absolute.x);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return position;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
vec2 VecToSphereOct(vec3 v)
|
|
97
|
+
{
|
|
98
|
+
float l1norm = abs(v.x) + abs(v.y) + abs(v.z);
|
|
99
|
+
|
|
100
|
+
vec2 result = v.xz / l1norm;
|
|
71
101
|
|
|
72
|
-
|
|
102
|
+
if (v.y < 0.0) {
|
|
103
|
+
result = (1.0 - abs(result.yx)) * sign_not_zero(result.xy);
|
|
73
104
|
}
|
|
74
105
|
|
|
75
|
-
return
|
|
106
|
+
return result;
|
|
76
107
|
}
|
|
77
108
|
|
|
78
109
|
float SampleBlended(sampler2D tex, vec2 uv0, vec2 uv1, vec2 uv2, vec4 weights) {
|
|
@@ -129,22 +160,245 @@ float lpv_probe_getDepth(uint probe_index, vec3 direction) {
|
|
|
129
160
|
);
|
|
130
161
|
}
|
|
131
162
|
|
|
132
|
-
|
|
133
|
-
|
|
163
|
+
float lpv_bilinear_lerp(float v00, float v01, float v10, float v11, vec2 fraction) {
|
|
164
|
+
|
|
165
|
+
float x0 = mix(v00, v01, fraction.x);
|
|
166
|
+
float x1 = mix(v10, v11, fraction.x);
|
|
167
|
+
|
|
168
|
+
return mix(x0, x1, fraction.y);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
vec2 lpv_sample_bilinear(sampler2D tex, ivec2 texel_position, vec2 fraction) {
|
|
172
|
+
|
|
173
|
+
float texel_00 = texelFetch(tex, texel_position, 0).r;
|
|
174
|
+
float texel_01 = texelFetch(tex, texel_position + ivec2(1, 0), 0).r;
|
|
175
|
+
float texel_10 = texelFetch(tex, texel_position + ivec2(0, 1), 0).r;
|
|
176
|
+
float texel_11 = texelFetch(tex, texel_position + ivec2(1, 1), 0).r;
|
|
177
|
+
|
|
178
|
+
return vec2(
|
|
179
|
+
lpv_bilinear_lerp(
|
|
180
|
+
texel_00, texel_01,
|
|
181
|
+
texel_10, texel_11,
|
|
182
|
+
fraction
|
|
183
|
+
),
|
|
184
|
+
lpv_bilinear_lerp(
|
|
185
|
+
texel_00 * texel_00, texel_01 * texel_01,
|
|
186
|
+
texel_10 * texel_10, texel_11 * texel_11,
|
|
187
|
+
fraction
|
|
188
|
+
)
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
ivec2 wrapOctahedralTexelCoordinatesNone(in ivec2 texelCoord, in int texture_size) {
|
|
193
|
+
return texelCoord;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
ivec2 wrapOctahedralTexelCoordinatesV0(in ivec2 texelCoord, in int texture_size) {
|
|
197
|
+
// return texelCoord;
|
|
198
|
+
// Decrement the texture size by 1 to get the maximum valid index
|
|
199
|
+
int maxIndex = texture_size - 1;
|
|
200
|
+
|
|
201
|
+
// Wrap the texel coordinates
|
|
202
|
+
ivec2 wrappedCoord = texelCoord;
|
|
203
|
+
|
|
204
|
+
// Wrap the X coordinate
|
|
205
|
+
if (wrappedCoord.x > maxIndex) {
|
|
206
|
+
wrappedCoord.x = maxIndex;
|
|
207
|
+
wrappedCoord.y += 1;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Wrap the Y coordinate
|
|
211
|
+
if (wrappedCoord.y > maxIndex) {
|
|
212
|
+
wrappedCoord.y = maxIndex - wrappedCoord.y; // Wrap from top to bottom
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return wrappedCoord;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
ivec2 wrapOctahedralTexelCoordinates(const in ivec2 texel, const in int texture_size) {
|
|
219
|
+
ivec2 wrapped = ((texel % texture_size) + texture_size) % texture_size;
|
|
220
|
+
|
|
221
|
+
int fx = (abs(texel.x / texture_size) + int(texel.x < 0));
|
|
222
|
+
int fy = (abs(texel.y / texture_size) + int(texel.y < 0));
|
|
223
|
+
|
|
224
|
+
if (((fx ^ fy) & 1) != 0) {
|
|
225
|
+
return (texture_size - (wrapped + ivec2(1)));
|
|
226
|
+
return wrapped;
|
|
227
|
+
} else {
|
|
228
|
+
return wrapped;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
vec2 lpv_probe_getDepthBilinear(uint probe_index, vec3 direction) {
|
|
234
|
+
// get offset
|
|
235
|
+
int depth_tile_resolution = int(lpv_u_probe_depth_resolution);
|
|
236
|
+
ivec2 tile_resolution = ivec2(depth_tile_resolution);
|
|
237
|
+
const ivec2 atlas_size = ivec2(4096);
|
|
238
|
+
|
|
239
|
+
int tiles_per_row = atlas_size.x / depth_tile_resolution;
|
|
240
|
+
|
|
241
|
+
int tile_x = int(probe_index) % tiles_per_row;
|
|
242
|
+
int tile_y = int(probe_index) / tiles_per_row;
|
|
243
|
+
|
|
244
|
+
ivec2 tile_offset = ivec2(
|
|
245
|
+
tile_x * depth_tile_resolution,
|
|
246
|
+
tile_y * depth_tile_resolution
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
// convert direction to UV
|
|
250
|
+
vec2 octahedral_uv = clamp(VecToSphereOct(direction) * 0.5 + 0.5, 0.0, 1.0);
|
|
251
|
+
vec2 grid = octahedral_uv * vec2(depth_tile_resolution) - 0.5;
|
|
252
|
+
|
|
253
|
+
vec2 gridFrac = fract(grid);
|
|
254
|
+
|
|
255
|
+
ivec2 texel_position = ivec2(floor(grid));
|
|
256
|
+
|
|
257
|
+
ivec2 tile_p_00;
|
|
258
|
+
ivec2 tile_p_01;
|
|
259
|
+
ivec2 tile_p_10;
|
|
260
|
+
ivec2 tile_p_11;
|
|
261
|
+
|
|
262
|
+
tile_p_00 = wrapOctahedralTexelCoordinates(texel_position , depth_tile_resolution);
|
|
263
|
+
tile_p_01 = wrapOctahedralTexelCoordinates(texel_position + ivec2(1, 0), depth_tile_resolution);
|
|
264
|
+
tile_p_10 = wrapOctahedralTexelCoordinates(texel_position + ivec2(0, 1), depth_tile_resolution);
|
|
265
|
+
tile_p_11 = wrapOctahedralTexelCoordinates(texel_position + ivec2(1, 1), depth_tile_resolution);
|
|
266
|
+
|
|
267
|
+
float texel_00 = texelFetch(lpv_t_probe_depth, tile_offset + tile_p_00, 0).r;
|
|
268
|
+
float texel_01 = texelFetch(lpv_t_probe_depth, tile_offset + tile_p_01, 0).r;
|
|
269
|
+
float texel_10 = texelFetch(lpv_t_probe_depth, tile_offset + tile_p_10, 0).r;
|
|
270
|
+
float texel_11 = texelFetch(lpv_t_probe_depth, tile_offset + tile_p_11, 0).r;
|
|
271
|
+
|
|
272
|
+
return vec2(
|
|
273
|
+
lpv_bilinear_lerp(
|
|
274
|
+
texel_00, texel_01,
|
|
275
|
+
texel_10, texel_11,
|
|
276
|
+
gridFrac
|
|
277
|
+
),
|
|
278
|
+
lpv_bilinear_lerp(
|
|
279
|
+
texel_00 * texel_00, texel_01 * texel_01,
|
|
280
|
+
texel_10 * texel_10, texel_11 * texel_11,
|
|
281
|
+
gridFrac
|
|
282
|
+
)
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
vec2 lpv_probe_getDepthTriangular(uint probe_index, vec3 direction) {
|
|
287
|
+
// get offset
|
|
288
|
+
uint depth_tile_resolution = lpv_u_probe_depth_resolution;
|
|
289
|
+
uvec2 atlas_size = uvec2(4096u);
|
|
290
|
+
|
|
291
|
+
uint tiles_per_row = atlas_size.x / depth_tile_resolution;
|
|
292
|
+
|
|
293
|
+
uint tile_x = probe_index % tiles_per_row;
|
|
294
|
+
uint tile_y = probe_index / tiles_per_row;
|
|
295
|
+
|
|
296
|
+
vec2 tile_offset = vec2(
|
|
297
|
+
tile_x * depth_tile_resolution,
|
|
298
|
+
tile_y * depth_tile_resolution
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
// convert direction to UV
|
|
302
|
+
vec2 octahedral_uv = clamp(VecToSphereOct(direction) * 0.5 + 0.5, 0.0, 1.0);
|
|
303
|
+
vec2 grid = octahedral_uv * vec2(depth_tile_resolution - 1u);
|
|
304
|
+
|
|
305
|
+
vec2 gridFrac = fract(grid);
|
|
306
|
+
vec2 gridFloor = floor(grid);
|
|
307
|
+
|
|
308
|
+
vec4 weights = quadBlendWieghts(gridFrac);
|
|
309
|
+
|
|
310
|
+
//3 nearest frames
|
|
311
|
+
vec2 frame0 = gridFloor;
|
|
312
|
+
vec2 frame1 = gridFloor + mix(vec2(0, 1), vec2(1, 0), weights.w);
|
|
313
|
+
vec2 frame2 = gridFloor + vec2(1.0, 1.0);
|
|
314
|
+
|
|
315
|
+
// move frames to atlas space
|
|
316
|
+
frame0 += tile_offset;
|
|
317
|
+
frame1 += tile_offset;
|
|
318
|
+
frame2 += tile_offset;
|
|
319
|
+
|
|
320
|
+
float samp0 = texelFetch(lpv_t_probe_depth, ivec2(frame0), 0).r;
|
|
321
|
+
float samp1 = texelFetch(lpv_t_probe_depth, ivec2(frame1), 0).r;
|
|
322
|
+
float samp2 = texelFetch(lpv_t_probe_depth, ivec2(frame2), 0).r;
|
|
323
|
+
|
|
324
|
+
float d0 = samp0 * weights.x;
|
|
325
|
+
float d1 = samp1 * weights.y;
|
|
326
|
+
float d2 = samp2 * weights.z;
|
|
327
|
+
|
|
328
|
+
float mean = d0 + d1 + d2;
|
|
329
|
+
float mean2 = samp0 * d0 + samp1 * d1 + samp2 * d2;
|
|
330
|
+
|
|
331
|
+
return vec2(mean, mean2);
|
|
134
332
|
}
|
|
333
|
+
vec3 lpv_DEBUG(uint probe_index, vec3 direction) {
|
|
334
|
+
// get offset
|
|
335
|
+
int depth_tile_resolution = int(lpv_u_probe_depth_resolution);
|
|
336
|
+
const ivec2 atlas_size = ivec2(4096);
|
|
135
337
|
|
|
136
|
-
|
|
338
|
+
int tiles_per_row = atlas_size.x / depth_tile_resolution;
|
|
137
339
|
|
|
138
|
-
|
|
340
|
+
int tile_x = int(probe_index) % tiles_per_row;
|
|
341
|
+
int tile_y = int(probe_index) / tiles_per_row;
|
|
139
342
|
|
|
140
|
-
|
|
343
|
+
ivec2 tile_offset = ivec2(
|
|
344
|
+
tile_x * depth_tile_resolution,
|
|
345
|
+
tile_y * depth_tile_resolution
|
|
346
|
+
);
|
|
141
347
|
|
|
142
|
-
|
|
348
|
+
// convert direction to UV
|
|
349
|
+
vec2 octahedral_uv = clamp(VecToSphereOct(direction) * 0.5 + 0.5, 0.0, 1.0);
|
|
350
|
+
vec2 grid = octahedral_uv * vec2(depth_tile_resolution);
|
|
143
351
|
|
|
144
|
-
|
|
352
|
+
vec2 gridFrac = fract(grid);
|
|
353
|
+
|
|
354
|
+
ivec2 texel_position = ivec2(floor(grid));
|
|
355
|
+
|
|
356
|
+
ivec2 tile_p_01 = wrapOctahedralTexelCoordinates(texel_position + ivec2(1, 0), depth_tile_resolution);
|
|
357
|
+
ivec2 tile_p_10 = wrapOctahedralTexelCoordinates(texel_position + ivec2(0, 1), depth_tile_resolution);
|
|
358
|
+
ivec2 tile_p_11 = wrapOctahedralTexelCoordinates(texel_position + ivec2(1, 1), depth_tile_resolution);
|
|
359
|
+
|
|
360
|
+
return mix(vec3(
|
|
361
|
+
tile_p_01.x == depth_tile_resolution ? 1.0 : 0.0,
|
|
362
|
+
tile_p_10.y == depth_tile_resolution ? 1.0 : 0.0,
|
|
363
|
+
0.0
|
|
364
|
+
), vec3(octahedral_uv, 0.0), 0.0);
|
|
365
|
+
|
|
366
|
+
float texel_00 = texelFetch(lpv_t_probe_depth, tile_offset + texel_position, 0).r;
|
|
367
|
+
float texel_01 = texelFetch(lpv_t_probe_depth, tile_offset + tile_p_01, 0).r;
|
|
368
|
+
float texel_10 = texelFetch(lpv_t_probe_depth, tile_offset + tile_p_10, 0).r;
|
|
369
|
+
float texel_11 = texelFetch(lpv_t_probe_depth, tile_offset + tile_p_11, 0).r;
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
vec3 dir_00 = OctaSphereEnc(vec2(texel_position) / float(depth_tile_resolution));
|
|
373
|
+
vec3 dir_01 = OctaSphereEnc(vec2(tile_p_01) / float(depth_tile_resolution));
|
|
374
|
+
vec3 dir_10 = OctaSphereEnc(vec2(tile_p_10) / float(depth_tile_resolution));
|
|
375
|
+
vec3 dir_11 = OctaSphereEnc(vec2(tile_p_11) / float(depth_tile_resolution));
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
vec3 dir = vec3(
|
|
379
|
+
lpv_bilinear_lerp(
|
|
380
|
+
dir_00.x, dir_01.x,
|
|
381
|
+
dir_10.x, dir_11.x,
|
|
382
|
+
gridFrac
|
|
383
|
+
), lpv_bilinear_lerp(
|
|
384
|
+
dir_00.y, dir_01.y,
|
|
385
|
+
dir_10.y, dir_11.y,
|
|
386
|
+
gridFrac
|
|
387
|
+
), lpv_bilinear_lerp(
|
|
388
|
+
dir_00.z, dir_01.z,
|
|
389
|
+
dir_10.z, dir_11.z,
|
|
390
|
+
gridFrac
|
|
391
|
+
)
|
|
392
|
+
) * 0.5 + 0.5;
|
|
393
|
+
|
|
394
|
+
return dir;
|
|
395
|
+
|
|
396
|
+
return vec3(octahedral_uv, 1.0);
|
|
397
|
+
}
|
|
145
398
|
|
|
146
|
-
|
|
147
|
-
|
|
399
|
+
|
|
400
|
+
vec3 lpv_probe_getPosition(uint probe_index) {
|
|
401
|
+
return texelFetch(lpv_t_probe_positions, lpv_index_to_256_coordinate(probe_index), 0).rgb;
|
|
148
402
|
}
|
|
149
403
|
|
|
150
404
|
varying vec3 vNormal;
|
|
@@ -154,8 +408,10 @@ void main() {
|
|
|
154
408
|
vec3 normal = normalize(vNormal);
|
|
155
409
|
vec3 worldNormal = normalize(inverseTransformDirection(normal, viewMatrix));
|
|
156
410
|
|
|
157
|
-
float depth =
|
|
411
|
+
float depth = lpv_probe_getDepthBilinear(instance_index, worldNormal).r / 7.0;
|
|
412
|
+
// float depth = lpv_probe_getDepthTriangular(instance_index, worldNormal).r / 7.0;
|
|
158
413
|
|
|
414
|
+
// gl_FragColor = vec4(lpv_DEBUG(instance_index, worldNormal), 1.0);
|
|
159
415
|
gl_FragColor = vec4(vec3(depth), 1.0);
|
|
160
|
-
// gl_FragColor = vec4( 1.0);
|
|
416
|
+
// gl_FragColor = vec4( 1.0);
|
|
161
417
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probe_volume_to_textures.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/probe_volume_to_textures.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,6EAHW,MAAM,EAAE,eACR,MAAM,
|
|
1
|
+
{"version":3,"file":"probe_volume_to_textures.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/probe_volume_to_textures.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,6EAHW,MAAM,EAAE,eACR,MAAM,QAiChB;AAGD;;;;;;GAMG;AACH,2DALW,oBAAoB,UACpB,MAAM,EAAE,eACR,MAAM,eACN,MAAM,QAiBhB;qCAhEoC,uCAAuC"}
|
|
@@ -27,18 +27,14 @@ export function octahedral_depth_to_atlas(lpv, atlas_data, atlas_width) {
|
|
|
27
27
|
|
|
28
28
|
const tile_pixel_index = pixel_y * tile_resolution + pixel_x;
|
|
29
29
|
|
|
30
|
-
const
|
|
31
|
-
const source_pixel_address = source_pixel_index * 2;
|
|
30
|
+
const source_value = probe_depth[source_offset + tile_pixel_index];
|
|
32
31
|
|
|
33
32
|
const target_pixel_x = tile_x * tile_resolution + pixel_x;
|
|
34
33
|
const target_pixel_y = tile_y * tile_resolution + pixel_y;
|
|
35
34
|
|
|
36
35
|
const target_pixel_index = target_pixel_y * atlas_width + target_pixel_x;
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
atlas_data[target_pixel_address] = probe_depth[source_pixel_address];
|
|
41
|
-
atlas_data[target_pixel_address + 1] = probe_depth[source_pixel_address + 1];
|
|
37
|
+
atlas_data[target_pixel_index] = source_value;
|
|
42
38
|
}
|
|
43
39
|
}
|
|
44
40
|
}
|
package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LightProbeVolumeSerializationAdapter.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.js"],"names":[],"mappings":"AAGA;IAEI,+BAAwB;IAGxB;;;;OAIG;IACH,8BAFW,gBAAgB,QAiB1B;IAED;;;;OAIG;IACH,gCAFW,gBAAgB,
|
|
1
|
+
{"version":3,"file":"LightProbeVolumeSerializationAdapter.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.js"],"names":[],"mappings":"AAGA;IAEI,+BAAwB;IAGxB;;;;OAIG;IACH,8BAFW,gBAAgB,QAiB1B;IAED;;;;OAIG;IACH,gCAFW,gBAAgB,QAkB1B;CACJ;gDApD+C,mEAAmE;iCAClF,wBAAwB"}
|
|
@@ -45,6 +45,7 @@ export class LightProbeVolumeSerializationAdapter extends BinaryClassSerializati
|
|
|
45
45
|
|
|
46
46
|
// depth
|
|
47
47
|
const depth_resolution = buffer.readUint32();
|
|
48
|
+
value.depth_map_resolution = depth_resolution;
|
|
48
49
|
buffer.readFloat32Array(value.depth, 0, depth_resolution * depth_resolution * count);
|
|
49
50
|
|
|
50
51
|
value.mesh.deserialize(buffer);
|
|
@@ -464,7 +464,7 @@ function* render(target, pt, camera, scene, progress = { current: 0, total: 0 })
|
|
|
464
464
|
|
|
465
465
|
for (let i = 0; i < pixel_sample_count; i++) {
|
|
466
466
|
|
|
467
|
-
ray.
|
|
467
|
+
ray.projectFromPerspectiveCamera(
|
|
468
468
|
_x + random() * pixel_scale_x * 2,
|
|
469
469
|
_y + random() * pixel_scale_y * 2,
|
|
470
470
|
0.5,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBiasedNormalSample.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/path_tracer/sampling/getBiasedNormalSample.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getBiasedNormalSample.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/path_tracer/sampling/getBiasedNormalSample.js"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,2CAPW,MAAM,EAAE,cACR,MAAM,UACN,MAAM,EAAE,iBACR,MAAM,SACN,MAAM,gBACK,MAAM,QAsD3B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { v3_length } from "../../../../../core/geom/vec3/v3_length.js";
|
|
1
2
|
import { PI2 } from "../../../../../core/math/PI2.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -37,7 +38,7 @@ export function getBiasedNormalSample(
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
// normalize orthonormal vector
|
|
40
|
-
const o1_norm = 1 /
|
|
41
|
+
const o1_norm = 1 / v3_length(o1_x, o1_y, o1_z);
|
|
41
42
|
|
|
42
43
|
o1_x *= o1_norm;
|
|
43
44
|
o1_y *= o1_norm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCosineDirection.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/path_tracer/sampling/getCosineDirection.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getCosineDirection.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/path_tracer/sampling/getCosineDirection.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,wCANW,MAAM,EAAE,cACR,MAAM,UACN,MAAM,EAAE,iBACR,MAAM,gBACK,MAAM,QAgC3B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { v3_length } from "../../../../../core/geom/vec3/v3_length.js";
|
|
1
2
|
import { PI2 } from "../../../../../core/math/PI2.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -33,7 +34,7 @@ export function getCosineDirection(
|
|
|
33
34
|
let out_dir_y = dir_y + k1;
|
|
34
35
|
let out_dir_z = dir_z + r_y;
|
|
35
36
|
|
|
36
|
-
const len2 = 1 /
|
|
37
|
+
const len2 = 1 / v3_length(out_dir_x, out_dir_y, out_dir_z);
|
|
37
38
|
|
|
38
39
|
out[out_offset] = out_dir_x * len2;
|
|
39
40
|
out[out_offset + 1] = out_dir_y * len2;
|
package/src/engine/graphics/sh3/path_tracer/sampling/v3_orthonormal_matrix_from_normal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v3_orthonormal_matrix_from_normal.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/path_tracer/sampling/v3_orthonormal_matrix_from_normal.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"v3_orthonormal_matrix_from_normal.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/path_tracer/sampling/v3_orthonormal_matrix_from_normal.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,uDANW,MAAM,EAAE,cACR,MAAM,SACN,MAAM,SACN,MAAM,SACN,MAAM,QAsChB"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { v3_length } from "../../../../../core/geom/vec3/v3_length.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Build orthonormal matrix from direction vector
|
|
3
5
|
* @param {number[]} out
|
|
@@ -21,7 +23,7 @@ export function v3_orthonormal_matrix_from_normal(out, out_offset, dir_x, dir_y,
|
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
// normalize orthonormal vector
|
|
24
|
-
const o1_norm = 1 /
|
|
26
|
+
const o1_norm = 1 / v3_length(o1_x, o1_y, o1_z);
|
|
25
27
|
|
|
26
28
|
o1_x *= o1_norm;
|
|
27
29
|
o1_y *= o1_norm;
|
|
@@ -22,6 +22,7 @@ import { kelvin_to_rgb } from "../../../core/color/kelvin/kelvin_to_rgb.js";
|
|
|
22
22
|
import { compose_matrix4_array } from "../../../core/geom/3d/compose_matrix4_array.js";
|
|
23
23
|
import { visualize_tetrahedral_mesh } from "../../../core/geom/3d/tetrahedra/visualize_tetrahedral_mesh.js";
|
|
24
24
|
import Quaternion from "../../../core/geom/Quaternion.js";
|
|
25
|
+
import { v3_length } from "../../../core/geom/vec3/v3_length.js";
|
|
25
26
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
26
27
|
import { max2 } from "../../../core/math/max2.js";
|
|
27
28
|
import { min2 } from "../../../core/math/min2.js";
|
|
@@ -245,7 +246,7 @@ async function getVolume({
|
|
|
245
246
|
engine,
|
|
246
247
|
ecd,
|
|
247
248
|
bounds: mesh_bounds,
|
|
248
|
-
density:
|
|
249
|
+
density: 5000
|
|
249
250
|
});
|
|
250
251
|
|
|
251
252
|
const buffer = new BinaryBuffer();
|
|
@@ -383,13 +384,13 @@ async function main(engine) {
|
|
|
383
384
|
// const path = 'data/models/samples/cyberpunk_bike/scene.gltf';
|
|
384
385
|
// const path = 'data/models/LowPolyTownshipSet/Town_Hall/model.gltf';
|
|
385
386
|
// const path = 'data/models/sibenik/3-window-less/model.gltf';
|
|
386
|
-
|
|
387
|
-
// const path = 'data/models/sponza-pbr/gltf/sponza.glb';
|
|
388
|
-
const path = 'data/models/pica_pica/pica_pica.gltf';
|
|
387
|
+
const path = 'data/models/sponza-pbr/gltf/sponza.glb';
|
|
389
388
|
// const path = 'data/models/samples/susanne.glb';
|
|
390
389
|
// const path = 'data/models/samples/teapot.gltf';
|
|
391
390
|
// const path = 'data/models/samples/salle_de_bain/model.glb';
|
|
392
391
|
// const path = 'data/models/samples/conference/model-no-curtains.glb';
|
|
392
|
+
// const path = 'data/models/pica_pica/pica_pica.gltf';
|
|
393
|
+
// const path = 'data/models/samples/gi_box_01/model.glb';
|
|
393
394
|
|
|
394
395
|
const mesh_asset = await engine.assetManager.promise(path, 'model/gltf+json');
|
|
395
396
|
const gltf = mesh_asset.gltf;
|
|
@@ -445,7 +446,7 @@ async function main(engine) {
|
|
|
445
446
|
graphics: engine.graphics
|
|
446
447
|
});
|
|
447
448
|
|
|
448
|
-
const model_footprint =
|
|
449
|
+
const model_footprint = v3_length(mesh_bounds.getExtentsX(), mesh_bounds.getExtentsY(), mesh_bounds.getExtentsZ());
|
|
449
450
|
|
|
450
451
|
|
|
451
452
|
const camera = ecd.getAnyComponent(Camera);
|
|
@@ -499,7 +500,7 @@ async function main(engine) {
|
|
|
499
500
|
|
|
500
501
|
|
|
501
502
|
const probe_viz = volume.visualize_probes({ size: model_footprint * 0.002 });
|
|
502
|
-
probe_viz.build(ecd);
|
|
503
|
+
// probe_viz.build(ecd);
|
|
503
504
|
|
|
504
505
|
const mesh_viz = visualize_tetrahedral_mesh({
|
|
505
506
|
mesh: volume.mesh,
|
|
@@ -508,6 +509,7 @@ async function main(engine) {
|
|
|
508
509
|
});
|
|
509
510
|
|
|
510
511
|
const depth_viz = VLPDepthMapVisualisation.from(volume).build();
|
|
512
|
+
depth_viz.build(ecd);
|
|
511
513
|
|
|
512
514
|
// volume.visualize_mesh({ ecd, opacity: 0.5 });
|
|
513
515
|
|