@woosh/meep-engine 2.109.9 → 2.109.11
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/meep.cjs +3 -3
- package/build/meep.module.js +3 -3
- package/editor/tools/v2/GizmoNode.js +71 -0
- package/editor/tools/v2/TransformControls.js +10 -980
- package/editor/tools/v2/TransformControlsGizmo.js +774 -0
- package/editor/tools/v2/TransformControlsPlane.js +118 -0
- package/editor/tools/v2/TransformMode.js +8 -0
- package/editor/tools/v2/TranslateHelperGeometry.js +14 -0
- package/package.json +1 -1
- package/src/core/collection/array/arrayQuickSort.d.ts +4 -4
- package/src/core/collection/array/arrayQuickSort.d.ts.map +1 -1
- package/src/core/collection/array/arrayQuickSort.js +3 -3
- package/src/core/model/node-graph/NodeGraph.spec.js +1 -1
- package/src/core/model/node-graph/node/NodeDescription.d.ts +1 -1
- package/src/core/model/node-graph/node/NodeDescription.spec.js +1 -1
- package/src/core/model/node-graph/node/NodeInstance.spec.js +1 -1
- package/src/core/model/node-graph/node/NodeInstancePortReference.spec.js +1 -1
- package/src/core/model/node-graph/node/NodeRegistry.d.ts +1 -1
- package/src/core/model/node-graph/node/NodeRegistry.d.ts.map +1 -1
- package/src/core/model/node-graph/node/NodeRegistry.js +5 -5
- package/src/core/model/node-graph/node/NodeRegistry.spec.js +1 -1
- package/src/core/model/node-graph/node/Port.d.ts.map +1 -1
- package/src/core/model/node-graph/node/Port.js +1 -1
- package/src/core/model/node-graph/node/Port.spec.js +1 -1
- package/src/core/model/node-graph/type/DataType.d.ts.map +1 -0
- package/src/core/model/node-graph/{DataType.js → type/DataType.js} +2 -2
- package/src/core/model/node-graph/type/DataType.spec.d.ts.map +1 -0
- package/src/core/model/node-graph/{ParametricDataType.d.ts → type/ParametricDataType.d.ts} +6 -1
- package/src/core/model/node-graph/type/ParametricDataType.d.ts.map +1 -0
- package/src/core/model/node-graph/{ParametricDataType.js → type/ParametricDataType.js} +19 -4
- package/src/core/model/node-graph/type/ParametricDataType.spec.d.ts +2 -0
- package/src/core/model/node-graph/type/ParametricDataType.spec.d.ts.map +1 -0
- package/src/core/model/node-graph/type/ParametricDataType.spec.js +63 -0
- package/src/core/model/node-graph/type/deserializeDataTypeFromJSON.d.ts +8 -0
- package/src/core/model/node-graph/type/deserializeDataTypeFromJSON.d.ts.map +1 -0
- package/src/core/model/node-graph/type/deserializeDataTypeFromJSON.js +24 -0
- package/src/engine/graphics/geometry/CircleGeometry.d.ts +20 -0
- package/src/engine/graphics/geometry/CircleGeometry.d.ts.map +1 -0
- package/src/engine/graphics/geometry/CircleGeometry.js +17 -0
- package/src/engine/graphics/particles/node-based/nodes/ParticleDataTypes.js +1 -1
- package/src/engine/graphics/particles/node-based/particle/ParticleAttributeSpecification.d.ts +10 -8
- package/src/engine/graphics/particles/node-based/particle/ParticleAttributeSpecification.d.ts.map +1 -1
- package/src/engine/graphics/sh3/gi/material/common.glsl +115 -93
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +4 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +4 -0
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.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 +52 -0
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +5 -5
- package/src/core/model/node-graph/DataType.d.ts.map +0 -1
- package/src/core/model/node-graph/DataType.spec.d.ts.map +0 -1
- package/src/core/model/node-graph/ParametricDataType.d.ts.map +0 -1
- /package/src/core/model/node-graph/{DataType.d.ts → type/DataType.d.ts} +0 -0
- /package/src/core/model/node-graph/{DataType.spec.d.ts → type/DataType.spec.d.ts} +0 -0
- /package/src/core/model/node-graph/{DataType.spec.js → type/DataType.spec.js} +0 -0
|
@@ -62,11 +62,22 @@ vec3[9] lpv_probe_getData(uint probe_index) {
|
|
|
62
62
|
return result;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
float sign_not_zero(float x) {
|
|
66
|
+
return x >= 0.0 ? 1.0 : -1.0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
vec2 sign_not_zero(vec2 x) {
|
|
70
|
+
return vec2(
|
|
71
|
+
sign_not_zero(x.x),
|
|
72
|
+
sign_not_zero(x.y)
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
65
76
|
vec3 sign_not_zero(vec3 x) {
|
|
66
77
|
return vec3(
|
|
67
|
-
x.x
|
|
68
|
-
x.y
|
|
69
|
-
x.z
|
|
78
|
+
sign_not_zero(x.x),
|
|
79
|
+
sign_not_zero(x.y),
|
|
80
|
+
sign_not_zero(x.z)
|
|
70
81
|
);
|
|
71
82
|
}
|
|
72
83
|
|
|
@@ -93,40 +104,17 @@ vec4 quadBlendWieghts(vec2 coords)
|
|
|
93
104
|
return res;
|
|
94
105
|
}
|
|
95
106
|
|
|
96
|
-
|
|
97
|
-
//{
|
|
98
|
-
// vec3 octant = sign_not_zero(direction);
|
|
99
|
-
//
|
|
100
|
-
// // |x| + |y| + |z| = 1
|
|
101
|
-
// float sum = dot(direction, octant);
|
|
102
|
-
// vec3 octahedron = direction / sum;
|
|
103
|
-
//
|
|
104
|
-
// if (direction.z < 0.0)
|
|
105
|
-
// {
|
|
106
|
-
// vec3 absolute = abs(octahedron);
|
|
107
|
-
//
|
|
108
|
-
// octahedron.xy = octant.xy * vec2(1.0f - absolute.y, 1.0f - absolute.x);
|
|
109
|
-
// }
|
|
110
|
-
//
|
|
111
|
-
// return octahedron.xy;
|
|
112
|
-
//}
|
|
113
|
-
|
|
114
|
-
vec2 VecToSphereOct(vec3 direction)
|
|
107
|
+
vec2 VecToSphereOct(vec3 v)
|
|
115
108
|
{
|
|
116
|
-
|
|
109
|
+
float l1norm = abs(v.x) + abs(v.y) + abs(v.z);
|
|
117
110
|
|
|
118
|
-
|
|
119
|
-
float sum = dot(direction, octant);
|
|
120
|
-
vec3 octahedron = direction / sum;
|
|
111
|
+
vec2 result = v.xz / l1norm;
|
|
121
112
|
|
|
122
|
-
if (
|
|
123
|
-
|
|
124
|
-
vec3 absolute = abs(octahedron);
|
|
125
|
-
|
|
126
|
-
octahedron.xz = octant.xz * vec2(1.0f - absolute.z, 1.0f - absolute.x);
|
|
113
|
+
if (v.y < 0.0) {
|
|
114
|
+
result = (1.0 - abs(result.yx)) * sign_not_zero(result.xy);
|
|
127
115
|
}
|
|
128
116
|
|
|
129
|
-
return
|
|
117
|
+
return result;
|
|
130
118
|
}
|
|
131
119
|
|
|
132
120
|
float SampleBlended(sampler2D tex, vec2 uv0, vec2 uv1, vec2 uv2, vec4 weights) {
|
|
@@ -176,8 +164,12 @@ vec2 lpv_probe_getDepth(uint probe_index, vec3 direction) {
|
|
|
176
164
|
float samp1 = texelFetch(lpv_t_probe_depth, ivec2(frame1), 0).r;
|
|
177
165
|
float samp2 = texelFetch(lpv_t_probe_depth, ivec2(frame2), 0).r;
|
|
178
166
|
|
|
179
|
-
float
|
|
180
|
-
float
|
|
167
|
+
float d0 = samp0 * weights.x;
|
|
168
|
+
float d1 = samp1 * weights.y;
|
|
169
|
+
float d2 = samp2 * weights.z;
|
|
170
|
+
|
|
171
|
+
float mean = d0 + d1 + d2;
|
|
172
|
+
float mean2 = samp0 * d0 + samp1 * d1 + samp2 * d2;
|
|
181
173
|
|
|
182
174
|
return vec2(mean, mean2);
|
|
183
175
|
}
|
|
@@ -219,15 +211,15 @@ in uint tet_guess,
|
|
|
219
211
|
out uint tet_index,
|
|
220
212
|
out vec4 weights
|
|
221
213
|
) {
|
|
222
|
-
uint came_from = 0u;
|
|
223
|
-
|
|
224
214
|
tet_index = tet_guess;
|
|
225
215
|
|
|
226
216
|
for (uint i = 0u; i < SEARCH_STEP_LIMIT; i++) {
|
|
227
217
|
|
|
228
218
|
weights = lpv_mesh_getBarycentricCoordinates(tet_index, position);
|
|
229
219
|
|
|
220
|
+
// Check if we're in the current "best guess" tetrahedron
|
|
230
221
|
if (weights.x >= 0.0 && weights.y >= 0.0 && weights.z >= 0.0 && weights.w >= 0.0) {
|
|
222
|
+
// success
|
|
231
223
|
return;
|
|
232
224
|
}
|
|
233
225
|
|
|
@@ -246,12 +238,6 @@ out vec4 weights
|
|
|
246
238
|
next_tet = neighbors[3];
|
|
247
239
|
}
|
|
248
240
|
|
|
249
|
-
if (next_tet == came_from) {
|
|
250
|
-
// numerical instability caused us to oscillate on the boundary
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
came_from = tet_index;
|
|
255
241
|
tet_index = next_tet;
|
|
256
242
|
}
|
|
257
243
|
|
|
@@ -262,11 +248,11 @@ float lpv_probe_getVisibilityMask(vec3 position, uint probe_index) {
|
|
|
262
248
|
|
|
263
249
|
vec3 probe_position = lpv_probe_getPosition(probe_index);
|
|
264
250
|
|
|
265
|
-
vec3 local_probe_offset =
|
|
251
|
+
vec3 local_probe_offset = position - probe_position;
|
|
266
252
|
|
|
267
253
|
float distToProbe = length(local_probe_offset);
|
|
268
254
|
|
|
269
|
-
vec3 direction =
|
|
255
|
+
vec3 direction = local_probe_offset / distToProbe;
|
|
270
256
|
|
|
271
257
|
vec2 temp = lpv_probe_getDepth(probe_index, direction);
|
|
272
258
|
|
|
@@ -280,7 +266,7 @@ float lpv_probe_getVisibilityMask(vec3 position, uint probe_index) {
|
|
|
280
266
|
float chebyshevWeight = variance / (variance + distance_delta * distance_delta);
|
|
281
267
|
|
|
282
268
|
// Increase contrast in the weight
|
|
283
|
-
|
|
269
|
+
chebyshevWeight = max(chebyshevWeight * chebyshevWeight * chebyshevWeight, 0.0);
|
|
284
270
|
|
|
285
271
|
return (distToProbe <= mean) ? 1.0 : chebyshevWeight;
|
|
286
272
|
}
|
|
@@ -299,35 +285,6 @@ vec4 lvp_mask_weights_by_visibility_by_depth(vec3 position, uint tet_index, vec4
|
|
|
299
285
|
return visibility * weights;
|
|
300
286
|
}
|
|
301
287
|
|
|
302
|
-
float lpv_probe_visibility_weight(uint probe_index, vec3 position, vec3 normal) {
|
|
303
|
-
float weight = 1.0;
|
|
304
|
-
|
|
305
|
-
vec3 probe_position = lpv_probe_getPosition(probe_index);
|
|
306
|
-
|
|
307
|
-
vec3 direction_to_probe = normalize(probe_position - position);
|
|
308
|
-
|
|
309
|
-
// Smooth backface test
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
// The naive soft backface weight would ignore a probe when
|
|
313
|
-
// it is behind the surface. That's good for walls. But for small details inside of a
|
|
314
|
-
// room, the normals on the details might rule out all of the probes that have mutual
|
|
315
|
-
// visibility to the point. So, we instead use a "wrap shading" test below inspired by
|
|
316
|
-
// NPR work.
|
|
317
|
-
// weight *= max(0.0001, dot(direction_to_probe, normal));
|
|
318
|
-
|
|
319
|
-
// The small offset at the end reduces the "going to zero" impact
|
|
320
|
-
// where this is really close to exactly opposite
|
|
321
|
-
float backface_term = max(0.0001, (dot(direction_to_probe, normal) + 1.0) * 0.5);
|
|
322
|
-
weight *= backface_term * backface_term + 0.2;
|
|
323
|
-
|
|
324
|
-
weight *= lpv_probe_getVisibilityMask(position, probe_index);
|
|
325
|
-
|
|
326
|
-
// Avoid zero weight
|
|
327
|
-
weight = max(0.000001, weight);
|
|
328
|
-
|
|
329
|
-
return weight;
|
|
330
|
-
}
|
|
331
288
|
|
|
332
289
|
vec4 lvp_mask_weights_by_visibility_by_normal(vec3 position, vec3 normal, uint tet_index, vec4 weights) {
|
|
333
290
|
|
|
@@ -346,16 +303,92 @@ vec4 lvp_mask_weights_by_visibility_by_normal(vec3 position, vec3 normal, uint t
|
|
|
346
303
|
return visibility * weights;
|
|
347
304
|
}
|
|
348
305
|
|
|
349
|
-
|
|
306
|
+
|
|
307
|
+
/** Slightly bump the location of the shadow test point away from the shadow casting surface.
|
|
308
|
+
The shadow casting surface is the boundary for shadow, so the nearer an imprecise value is
|
|
309
|
+
to it the more the light leaks.
|
|
310
|
+
*/
|
|
311
|
+
#define LPV_NORMAL_BIAS 0.01f
|
|
312
|
+
|
|
313
|
+
vec4 lvp_mask_weights_by_visibility(in vec3 position, in vec3 normal, in vec3 view_direction, in uint tet_index, in vec4 barycentric) {
|
|
350
314
|
|
|
351
315
|
uvec4 vertices = lpv_mesh_getVertices(tet_index);
|
|
352
316
|
|
|
353
317
|
vec4 visibility;
|
|
354
318
|
|
|
355
|
-
|
|
356
|
-
|
|
319
|
+
// Bias the position at which visibility is computed; this
|
|
320
|
+
// avoids performing a shadow test *at* a surface, which is a
|
|
321
|
+
// dangerous location because that is exactly the line between
|
|
322
|
+
// shadowed and unshadowed. If the normal bias is too small,
|
|
323
|
+
// there will be light and dark leaks. If it is too large,
|
|
324
|
+
// then samples can pass through thin occluders to the other
|
|
325
|
+
// side (this can only happen if there are MULTIPLE occluders
|
|
326
|
+
// near each other, a wall surface won't pass through itself.)
|
|
327
|
+
vec3 lookup_position = position + (normal - view_direction * 3.0) * LPV_NORMAL_BIAS;
|
|
328
|
+
|
|
329
|
+
float weight_sum = 0.0;
|
|
330
|
+
|
|
331
|
+
for (uint i = 0u; i < 4u; i++) {
|
|
332
|
+
|
|
333
|
+
float weight = 1.0;
|
|
334
|
+
|
|
335
|
+
uint probe_index = vertices[i];
|
|
336
|
+
|
|
337
|
+
vec3 probe_position = lpv_probe_getPosition(probe_index);
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
// Smooth backface test
|
|
341
|
+
{
|
|
342
|
+
|
|
343
|
+
// Computed without the biasing applied to the "dir" variable.
|
|
344
|
+
// This test can cause reflection-map looking errors in the image
|
|
345
|
+
// (stuff looks shiny) if the transition is poor.
|
|
346
|
+
vec3 direction_to_probe = normalize(probe_position - position);
|
|
347
|
+
|
|
348
|
+
// The naive soft backface weight would ignore a probe when
|
|
349
|
+
// it is behind the surface. That's good for walls. But for small details inside of a
|
|
350
|
+
// room, the normals on the details might rule out all of the probes that have mutual
|
|
351
|
+
// visibility to the point. So, we instead use a "wrap shading" test below inspired by
|
|
352
|
+
// NPR work.
|
|
353
|
+
// weight *= max(0.0001, dot(direction_to_probe, normal));
|
|
354
|
+
|
|
355
|
+
// The small offset at the end reduces the "going to zero" impact
|
|
356
|
+
// where this is really close to exactly opposite
|
|
357
|
+
float backface_term = max(0.0001, (dot(direction_to_probe, normal) + 1.0) * 0.5);
|
|
358
|
+
weight *= backface_term * backface_term + 0.2;
|
|
359
|
+
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// Moment visibility test (depth)
|
|
363
|
+
{
|
|
364
|
+
|
|
365
|
+
weight *= lpv_probe_getVisibilityMask(lookup_position, probe_index);
|
|
366
|
+
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
// A tiny bit of light is really visible due to log perception, so
|
|
371
|
+
// crush tiny weights but keep the curve continuous. This must be done
|
|
372
|
+
// before the trilinear weights, because those should be preserved.
|
|
373
|
+
const float crushThreshold = 0.2;
|
|
374
|
+
|
|
375
|
+
if (weight < crushThreshold) {
|
|
376
|
+
weight *= weight * weight * (1.0 / (crushThreshold * crushThreshold));
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// Avoid zero weight
|
|
380
|
+
weight = max(0.000001, weight);
|
|
381
|
+
|
|
382
|
+
weight *= barycentric[i];
|
|
383
|
+
|
|
384
|
+
weight_sum += weight;
|
|
385
|
+
|
|
386
|
+
visibility[i] = weight;
|
|
357
387
|
}
|
|
358
388
|
|
|
389
|
+
// normalize
|
|
390
|
+
visibility /= weight_sum;
|
|
391
|
+
|
|
359
392
|
return visibility;
|
|
360
393
|
}
|
|
361
394
|
|
|
@@ -420,8 +453,8 @@ vec4 lpv_renormalize_weights(in vec4 source) {
|
|
|
420
453
|
|
|
421
454
|
float sum = source.x + source.y + source.z + source.w;
|
|
422
455
|
|
|
423
|
-
if (sum <= 0.
|
|
424
|
-
return vec4(
|
|
456
|
+
if (sum <= 0.0001) {
|
|
457
|
+
return vec4(0.0);
|
|
425
458
|
}
|
|
426
459
|
|
|
427
460
|
return source / sum;
|
|
@@ -430,12 +463,6 @@ vec4 lpv_renormalize_weights(in vec4 source) {
|
|
|
430
463
|
|
|
431
464
|
|
|
432
465
|
|
|
433
|
-
/** Slightly bump the location of the shadow test point away from the shadow casting surface.
|
|
434
|
-
The shadow casting surface is the boundary for shadow, so the nearer an imprecise value is
|
|
435
|
-
to it the more the light leaks.
|
|
436
|
-
*/
|
|
437
|
-
#define LPV_NORMAL_BIAS 0.01f
|
|
438
|
-
|
|
439
466
|
vec3 lpv_sample_irradiance(vec3 position, vec3 normal, vec3 view_direction) {
|
|
440
467
|
|
|
441
468
|
// Bias the position at which visibility is computed; this
|
|
@@ -457,16 +484,11 @@ vec3 lpv_sample_irradiance(vec3 position, vec3 normal, vec3 view_direction) {
|
|
|
457
484
|
uint nearest_tet = lpv_guess_initial_tet(lookup_position);
|
|
458
485
|
|
|
459
486
|
uint tet;
|
|
460
|
-
vec4
|
|
461
|
-
lpv_walk_to_tetrahedron(lookup_position, nearest_tet, tet,
|
|
487
|
+
vec4 barycentric_coordinates;
|
|
488
|
+
lpv_walk_to_tetrahedron(lookup_position, nearest_tet, tet, barycentric_coordinates);
|
|
462
489
|
|
|
463
490
|
// apply visibility term
|
|
464
|
-
|
|
465
|
-
// weights = lvp_mask_weights_by_visibility_by_normal(lookup_position,normal, tet, weights);
|
|
466
|
-
weights *= lvp_mask_weights_by_visibility(lookup_position, normal, tet);
|
|
467
|
-
|
|
468
|
-
// re-normalize weights
|
|
469
|
-
weights = lpv_renormalize_weights(weights);
|
|
491
|
+
vec4 weights = lvp_mask_weights_by_visibility(lookup_position, normal, view_direction, tet, barycentric_coordinates);
|
|
470
492
|
|
|
471
493
|
if (tet == INVALID_TET) {
|
|
472
494
|
// do nothing
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LightProbeVolume.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/LightProbeVolume.js"],"names":[],"mappings":"AAUA;IAiCI,sBAEC;IAED,cAkBC;IAED;;;OAGG;IACH,4BAEC;IAED,uBAEC;IAED,0BAEC;IAED,mCAEC;IAED,sBAEC;IAMD,uBAEC;IAND,oBAEC;IAMD;;;;;OAKG;IACH,aAJW,MAAM,KACN,MAAM,KACN,MAAM,QAgBhB;IAED;;;;;OAKG;IACH,mBAJW,MAAM,UACN,MAAM,EAAE,iBACR,MAAM,QAIhB;IAED;;OAEG;IACH,mBAaC;IAGD;;;;;OAKG;IACH,mCAJW,MAAM,GAEJ,UAAU,CAsBtB;IAGD,yBAEC;;CAEJ;
|
|
1
|
+
{"version":3,"file":"LightProbeVolume.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/LightProbeVolume.js"],"names":[],"mappings":"AAUA;;;GAGG;AACH;IAiCI,sBAEC;IAED,cAkBC;IAED;;;OAGG;IACH,4BAEC;IAED,uBAEC;IAED,0BAEC;IAED,mCAEC;IAED,sBAEC;IAMD,uBAEC;IAND,oBAEC;IAMD;;;;;OAKG;IACH,aAJW,MAAM,KACN,MAAM,KACN,MAAM,QAgBhB;IAED;;;;;OAKG;IACH,mBAJW,MAAM,UACN,MAAM,EAAE,iBACR,MAAM,QAIhB;IAED;;OAEG;IACH,mBAaC;IAGD;;;;;OAKG;IACH,mCAJW,MAAM,GAEJ,UAAU,CAsBtB;IAGD,yBAEC;;CAEJ;gCAvL+B,wDAAwD;2BAC7D,mCAAmC"}
|
|
@@ -8,6 +8,10 @@ import { Transform } from "../../../ecs/transform/Transform.js";
|
|
|
8
8
|
import { sh3_make_shaded_geometry } from "../visualise_spherical_harmonic_sphere.js";
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Irradiance field representation
|
|
13
|
+
* @see "Irradiance Volumes" by G.Greger, 1998
|
|
14
|
+
*/
|
|
11
15
|
export class LightProbeVolume {
|
|
12
16
|
#version = 0;
|
|
13
17
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PathTracerProbeRenderer.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js"],"names":[],"mappings":"AAuBA;IACI,mBAA0B;IAC1B,yBAAqB;IACrB,
|
|
1
|
+
{"version":3,"file":"PathTracerProbeRenderer.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js"],"names":[],"mappings":"AAuBA;IACI,mBAA0B;IAC1B,yBAAqB;IACrB,qBAAoB;IACpB,qBAAyB;IAEzB,uBAA6B;IAE7B;;;;;;;;OAQG;IACH,kCAPW,MAAM,aACN,MAAM,YACN,MAAM,EAAE,mBACR,MAAM,UACN,MAAM,EAAE,iBACR,MAAM,QAahB;IAED,iFAuCC;IAKD,mBACC;IAED,4BAKC;CACJ;8BA5F6B,oBAAoB;2BAHvB,8BAA8B;gCADzB,mCAAmC"}
|
|
@@ -24,7 +24,7 @@ const sampled_irradiance = new Float32Array(3);
|
|
|
24
24
|
export class PathTracerProbeRenderer extends ProbeRenderer {
|
|
25
25
|
tracer = new PathTracer();
|
|
26
26
|
max_bounce_count = 7;
|
|
27
|
-
sample_count =
|
|
27
|
+
sample_count = 4096;
|
|
28
28
|
random = seededRandom(0);
|
|
29
29
|
|
|
30
30
|
scene = new PathTracedScene()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bake_octahedral_depth_map.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bake_octahedral_depth_map.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js"],"names":[],"mappings":"AAkBA;;;;;;;;;GASG;AACH,kDARW,MAAM,EAAE,iBACR,MAAM,oCAEN,MAAM,EAAE,UAAQ,mBAChB,MAAM,cACN,MAAM,aACN,MAAM,QAmFhB"}
|
|
@@ -3,9 +3,17 @@ import {
|
|
|
3
3
|
decode_octahedron_to_unit
|
|
4
4
|
} from "../../../../../../core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js";
|
|
5
5
|
import { Ray3 } from "../../../../../../core/geom/3d/Ray3.js";
|
|
6
|
+
import { v3_distance } from "../../../../../../core/geom/vec3/v3_distance.js";
|
|
7
|
+
import { v3_dot } from "../../../../../../core/geom/vec3/v3_dot.js";
|
|
8
|
+
import { clamp01 } from "../../../../../../core/math/clamp01.js";
|
|
9
|
+
import { PI_HALF } from "../../../../../../core/math/PI_HALF.js";
|
|
6
10
|
|
|
7
11
|
const scratch_ray = new Ray3();
|
|
8
12
|
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @type {number[]}
|
|
16
|
+
*/
|
|
9
17
|
const ray_hit = [];
|
|
10
18
|
|
|
11
19
|
/**
|
|
@@ -29,6 +37,20 @@ export function bake_octahedral_depth_map(
|
|
|
29
37
|
scratch_ray.tMax = max_depth;
|
|
30
38
|
array_copy(position, position_offset, scratch_ray, 0, 3);
|
|
31
39
|
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Resolution bias is to compensate for discontinuities between samples
|
|
43
|
+
* The lower the resolution - the higher the discontinuities
|
|
44
|
+
* This is heights of an arch on a unit sphere, where arch spans 1/resolution angle
|
|
45
|
+
* Half-PI is to get the height at midpoint of the arch
|
|
46
|
+
* x2 is to get error over the entire circle, as the previous term only gets us to semicircle
|
|
47
|
+
* xMath.SQRT2 is to allow for diagonals between pixels
|
|
48
|
+
* @type {number}
|
|
49
|
+
*/
|
|
50
|
+
const RESOLUTION_BIAS = Math.sin(PI_HALF / resolution) * 2 * Math.SQRT2;
|
|
51
|
+
|
|
52
|
+
const NORMAL_BIAS = max_depth * 0.01;
|
|
53
|
+
|
|
32
54
|
const ray_direction = scratch_ray.direction;
|
|
33
55
|
|
|
34
56
|
for (let oct_x = 0; oct_x < resolution; oct_x++) {
|
|
@@ -47,6 +69,36 @@ export function bake_octahedral_depth_map(
|
|
|
47
69
|
if (distance < 0) {
|
|
48
70
|
// no hit
|
|
49
71
|
distance = max_depth;
|
|
72
|
+
} else {
|
|
73
|
+
const surface_normal_x = ray_hit[3];
|
|
74
|
+
const surface_normal_y = ray_hit[4];
|
|
75
|
+
const surface_normal_z = ray_hit[5];
|
|
76
|
+
|
|
77
|
+
const surface_position_x = ray_hit[0];
|
|
78
|
+
const surface_position_y = ray_hit[1];
|
|
79
|
+
const surface_position_z = ray_hit[2];
|
|
80
|
+
|
|
81
|
+
// check for possible miss
|
|
82
|
+
const hit_angle_cos = -v3_dot(
|
|
83
|
+
surface_normal_x, surface_normal_y, surface_normal_z,
|
|
84
|
+
ray_direction[0], ray_direction[1], ray_direction[2]
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const resolution_bias_offset = distance * RESOLUTION_BIAS;
|
|
88
|
+
|
|
89
|
+
const hit_normal_bias = -clamp01(1 - hit_angle_cos) * NORMAL_BIAS;
|
|
90
|
+
|
|
91
|
+
// sink the contact into the surface along the hit normal
|
|
92
|
+
const biased_hit_x = surface_position_x + surface_normal_x * hit_normal_bias;
|
|
93
|
+
const biased_hit_y = surface_position_y + surface_normal_y * hit_normal_bias;
|
|
94
|
+
const biased_hit_z = surface_position_z + surface_normal_z * hit_normal_bias;
|
|
95
|
+
|
|
96
|
+
distance = v3_distance(
|
|
97
|
+
scratch_ray[0], scratch_ray[1], scratch_ray[2],
|
|
98
|
+
biased_hit_x, biased_hit_y, biased_hit_z
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
distance += resolution_bias_offset;
|
|
50
102
|
}
|
|
51
103
|
|
|
52
104
|
const pixel_index = oct_y * resolution + oct_x;
|
|
@@ -243,7 +243,7 @@ async function getVolume({
|
|
|
243
243
|
engine,
|
|
244
244
|
ecd,
|
|
245
245
|
bounds: mesh_bounds,
|
|
246
|
-
density:
|
|
246
|
+
density: 5000
|
|
247
247
|
});
|
|
248
248
|
|
|
249
249
|
const buffer = new BinaryBuffer();
|
|
@@ -327,6 +327,7 @@ async function main(engine) {
|
|
|
327
327
|
|
|
328
328
|
await EngineHarness.buildBasics({
|
|
329
329
|
engine,
|
|
330
|
+
showFps: false,
|
|
330
331
|
enableWater: false,
|
|
331
332
|
enableTerrain: false,
|
|
332
333
|
enableLights: false,
|
|
@@ -380,8 +381,8 @@ async function main(engine) {
|
|
|
380
381
|
// const path = 'data/models/LowPolyTownshipSet/Town_Hall/model.gltf';
|
|
381
382
|
// const path = 'data/models/sibenik/3-window-less/model.gltf';
|
|
382
383
|
// const path = 'data/models/samples/gi_box_01/model.glb';
|
|
383
|
-
|
|
384
|
-
const path = 'data/models/pica_pica/pica_pica.gltf';
|
|
384
|
+
const path = 'data/models/sponza-pbr/gltf/sponza.glb';
|
|
385
|
+
// const path = 'data/models/pica_pica/pica_pica.gltf';
|
|
385
386
|
|
|
386
387
|
const mesh_asset = await engine.assetManager.promise(path, 'model/gltf+json');
|
|
387
388
|
const gltf = mesh_asset.gltf;
|
|
@@ -409,8 +410,7 @@ async function main(engine) {
|
|
|
409
410
|
const sg = n.entity.getComponent(ShadedGeometry);
|
|
410
411
|
|
|
411
412
|
if (sg !== null) {
|
|
412
|
-
sg.writeFlag(ShadedGeometryFlags.CastShadow, true);
|
|
413
|
-
sg.writeFlag(ShadedGeometryFlags.ReceiveShadow, true);
|
|
413
|
+
sg.writeFlag(ShadedGeometryFlags.CastShadow | ShadedGeometryFlags.ReceiveShadow, true);
|
|
414
414
|
}
|
|
415
415
|
});
|
|
416
416
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DataType.d.ts","sourceRoot":"","sources":["../../../../../src/core/model/node-graph/DataType.js"],"names":[],"mappings":"AAEA;IAyDI;;;;OAIG;IACH,yBAFa,QAAQ,CAQpB;IAGD;;;;;OAKG;IACH,gBAJW,MAAM,QACN,MAAM,GACJ,QAAQ,CAQpB;IAjFD;;;OAGG;IACH,IAFU,MAAM,CAET;IAEP;;;OAGG;IACH,MAFU,MAAM,CAEN;IAEV,mBAEC;IAED;;;OAGG;IACH,QAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,cAHW,QAAQ,GACN,OAAO,CAKnB;IAED;;;;OAIG;IACH,QAHW,MAAM,QACN,MAAM,QAQhB;IAED,eAEC;IAED;;;aAEC;IAgCL;;;OAGG;IACH,qBAFU,OAAO,CAEY;CAP5B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DataType.spec.d.ts","sourceRoot":"","sources":["../../../../../src/core/model/node-graph/DataType.spec.js"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ParametricDataType.d.ts","sourceRoot":"","sources":["../../../../../src/core/model/node-graph/ParametricDataType.js"],"names":[],"mappings":"AAGA;;;GAGG;AACH;IAyCI;;;;OAIG;IACH,gBAJW,MAAM,QACN,MAAM,eACN,QAAQ,EAAE,sBAUpB;IArDD;;;OAGG;IACH,YAFU,QAAQ,EAAE,CAEJ;IAGhB;;;;;OAKG;IACH,QAJW,MAAM,QACN,MAAM,eACN,QAAQ,EAAE,QAMpB;IAED;;;;OAIG;IACH,cAHW,kBAAkB,GAChB,OAAO,CAQnB;IAED,eAEC;IAED,uBAEC;CAgBJ;yBA7DwB,eAAe"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|