@woosh/meep-engine 2.109.10 → 2.109.12
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/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/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 +3 -2
- 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 +171 -95
- 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/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 +4 -4
- 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
|
-
|
|
117
|
-
|
|
118
|
-
// |x| + |y| + |z| = 1
|
|
119
|
-
float sum = dot(direction, octant);
|
|
120
|
-
vec3 octahedron = direction / sum;
|
|
109
|
+
float l1norm = abs(v.x) + abs(v.y) + abs(v.z);
|
|
121
110
|
|
|
122
|
-
|
|
123
|
-
{
|
|
124
|
-
vec3 absolute = abs(octahedron);
|
|
111
|
+
vec2 result = v.xz / l1norm;
|
|
125
112
|
|
|
126
|
-
|
|
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) {
|
|
@@ -138,7 +126,7 @@ float SampleBlended(sampler2D tex, vec2 uv0, vec2 uv1, vec2 uv2, vec4 weights) {
|
|
|
138
126
|
return samp0 * weights.x + samp1 * weights.y + samp2 * weights.z;
|
|
139
127
|
}
|
|
140
128
|
|
|
141
|
-
vec2
|
|
129
|
+
vec2 lpv_probe_getDepthTriangular(uint probe_index, vec3 direction) {
|
|
142
130
|
// get offset
|
|
143
131
|
uint depth_tile_resolution = lpv_u_probe_depth_resolution;
|
|
144
132
|
uvec2 atlas_size = uvec2(4096u);
|
|
@@ -176,12 +164,70 @@ 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
|
}
|
|
184
176
|
|
|
177
|
+
float lpv_bilinear_lerp(float v00, float v01, float v10, float v11, vec2 fraction) {
|
|
178
|
+
|
|
179
|
+
float x0 = mix(v00, v01, fraction.x);
|
|
180
|
+
float x1 = mix(v10, v11, fraction.x);
|
|
181
|
+
|
|
182
|
+
return mix(x0, x1, fraction.y);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
vec2 lpv_sample_bilinear(sampler2D tex, ivec2 texel_position, vec2 fraction) {
|
|
186
|
+
|
|
187
|
+
float texel_00 = texelFetch(tex, texel_position, 0).r;
|
|
188
|
+
float texel_01 = texelFetch(tex, texel_position + ivec2(1, 0), 0).r;
|
|
189
|
+
float texel_10 = texelFetch(tex, texel_position + ivec2(0, 1), 0).r;
|
|
190
|
+
float texel_11 = texelFetch(tex, texel_position + ivec2(1, 1), 0).r;
|
|
191
|
+
|
|
192
|
+
return vec2(
|
|
193
|
+
lpv_bilinear_lerp(
|
|
194
|
+
texel_00, texel_01,
|
|
195
|
+
texel_10, texel_11,
|
|
196
|
+
fraction
|
|
197
|
+
),
|
|
198
|
+
lpv_bilinear_lerp(
|
|
199
|
+
texel_00*texel_00, texel_01*texel_01,
|
|
200
|
+
texel_10*texel_10, texel_11*texel_11,
|
|
201
|
+
fraction
|
|
202
|
+
)
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
vec2 lpv_probe_getDepthBilinear(uint probe_index, vec3 direction) {
|
|
207
|
+
// get offset
|
|
208
|
+
uint depth_tile_resolution = lpv_u_probe_depth_resolution;
|
|
209
|
+
uvec2 atlas_size = uvec2(4096u);
|
|
210
|
+
|
|
211
|
+
uint tiles_per_row = atlas_size.x / depth_tile_resolution;
|
|
212
|
+
|
|
213
|
+
uint tile_x = probe_index % tiles_per_row;
|
|
214
|
+
uint tile_y = probe_index / tiles_per_row;
|
|
215
|
+
|
|
216
|
+
vec2 tile_offset = vec2(
|
|
217
|
+
tile_x * depth_tile_resolution,
|
|
218
|
+
tile_y * depth_tile_resolution
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
// convert direction to UV
|
|
222
|
+
vec2 octahedral_uv = clamp(VecToSphereOct(direction) * 0.5 + 0.5, 0.0, 1.0);
|
|
223
|
+
vec2 grid = octahedral_uv * vec2(depth_tile_resolution - 1u);
|
|
224
|
+
|
|
225
|
+
vec2 gridFrac = fract(grid);
|
|
226
|
+
vec2 gridFloor = floor(grid);
|
|
227
|
+
|
|
228
|
+
return lpv_sample_bilinear(lpv_t_probe_depth, ivec2(gridFloor+tile_offset),gridFrac);
|
|
229
|
+
}
|
|
230
|
+
|
|
185
231
|
vec3 lpv_probe_getPosition(uint probe_index) {
|
|
186
232
|
return texelFetch(lpv_t_probe_positions, lpv_index_to_256_coordinate(probe_index), 0).rgb;
|
|
187
233
|
}
|
|
@@ -219,15 +265,15 @@ in uint tet_guess,
|
|
|
219
265
|
out uint tet_index,
|
|
220
266
|
out vec4 weights
|
|
221
267
|
) {
|
|
222
|
-
uint came_from = 0u;
|
|
223
|
-
|
|
224
268
|
tet_index = tet_guess;
|
|
225
269
|
|
|
226
270
|
for (uint i = 0u; i < SEARCH_STEP_LIMIT; i++) {
|
|
227
271
|
|
|
228
272
|
weights = lpv_mesh_getBarycentricCoordinates(tet_index, position);
|
|
229
273
|
|
|
274
|
+
// Check if we're in the current "best guess" tetrahedron
|
|
230
275
|
if (weights.x >= 0.0 && weights.y >= 0.0 && weights.z >= 0.0 && weights.w >= 0.0) {
|
|
276
|
+
// success
|
|
231
277
|
return;
|
|
232
278
|
}
|
|
233
279
|
|
|
@@ -246,12 +292,6 @@ out vec4 weights
|
|
|
246
292
|
next_tet = neighbors[3];
|
|
247
293
|
}
|
|
248
294
|
|
|
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
295
|
tet_index = next_tet;
|
|
256
296
|
}
|
|
257
297
|
|
|
@@ -262,13 +302,13 @@ float lpv_probe_getVisibilityMask(vec3 position, uint probe_index) {
|
|
|
262
302
|
|
|
263
303
|
vec3 probe_position = lpv_probe_getPosition(probe_index);
|
|
264
304
|
|
|
265
|
-
vec3 local_probe_offset =
|
|
305
|
+
vec3 local_probe_offset = position - probe_position;
|
|
266
306
|
|
|
267
307
|
float distToProbe = length(local_probe_offset);
|
|
268
308
|
|
|
269
|
-
vec3 direction =
|
|
309
|
+
vec3 direction = local_probe_offset / distToProbe;
|
|
270
310
|
|
|
271
|
-
vec2 temp =
|
|
311
|
+
vec2 temp = lpv_probe_getDepthBilinear(probe_index, direction);
|
|
272
312
|
|
|
273
313
|
float mean = temp.x;
|
|
274
314
|
float variance = abs(mean * mean - temp.y);
|
|
@@ -280,7 +320,7 @@ float lpv_probe_getVisibilityMask(vec3 position, uint probe_index) {
|
|
|
280
320
|
float chebyshevWeight = variance / (variance + distance_delta * distance_delta);
|
|
281
321
|
|
|
282
322
|
// Increase contrast in the weight
|
|
283
|
-
|
|
323
|
+
chebyshevWeight = max(chebyshevWeight * chebyshevWeight * chebyshevWeight, 0.0);
|
|
284
324
|
|
|
285
325
|
return (distToProbe <= mean) ? 1.0 : chebyshevWeight;
|
|
286
326
|
}
|
|
@@ -299,35 +339,6 @@ vec4 lvp_mask_weights_by_visibility_by_depth(vec3 position, uint tet_index, vec4
|
|
|
299
339
|
return visibility * weights;
|
|
300
340
|
}
|
|
301
341
|
|
|
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
342
|
|
|
332
343
|
vec4 lvp_mask_weights_by_visibility_by_normal(vec3 position, vec3 normal, uint tet_index, vec4 weights) {
|
|
333
344
|
|
|
@@ -346,16 +357,92 @@ vec4 lvp_mask_weights_by_visibility_by_normal(vec3 position, vec3 normal, uint t
|
|
|
346
357
|
return visibility * weights;
|
|
347
358
|
}
|
|
348
359
|
|
|
349
|
-
|
|
360
|
+
|
|
361
|
+
/** Slightly bump the location of the shadow test point away from the shadow casting surface.
|
|
362
|
+
The shadow casting surface is the boundary for shadow, so the nearer an imprecise value is
|
|
363
|
+
to it the more the light leaks.
|
|
364
|
+
*/
|
|
365
|
+
#define LPV_NORMAL_BIAS 0.01f
|
|
366
|
+
|
|
367
|
+
vec4 lvp_mask_weights_by_visibility(in vec3 position, in vec3 normal, in vec3 view_direction, in uint tet_index, in vec4 barycentric) {
|
|
350
368
|
|
|
351
369
|
uvec4 vertices = lpv_mesh_getVertices(tet_index);
|
|
352
370
|
|
|
353
371
|
vec4 visibility;
|
|
354
372
|
|
|
355
|
-
|
|
356
|
-
|
|
373
|
+
// Bias the position at which visibility is computed; this
|
|
374
|
+
// avoids performing a shadow test *at* a surface, which is a
|
|
375
|
+
// dangerous location because that is exactly the line between
|
|
376
|
+
// shadowed and unshadowed. If the normal bias is too small,
|
|
377
|
+
// there will be light and dark leaks. If it is too large,
|
|
378
|
+
// then samples can pass through thin occluders to the other
|
|
379
|
+
// side (this can only happen if there are MULTIPLE occluders
|
|
380
|
+
// near each other, a wall surface won't pass through itself.)
|
|
381
|
+
vec3 lookup_position = position + (normal - view_direction * 3.0) * LPV_NORMAL_BIAS;
|
|
382
|
+
|
|
383
|
+
float weight_sum = 0.0;
|
|
384
|
+
|
|
385
|
+
for (uint i = 0u; i < 4u; i++) {
|
|
386
|
+
|
|
387
|
+
float weight = 1.0;
|
|
388
|
+
|
|
389
|
+
uint probe_index = vertices[i];
|
|
390
|
+
|
|
391
|
+
vec3 probe_position = lpv_probe_getPosition(probe_index);
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
// Smooth backface test
|
|
395
|
+
{
|
|
396
|
+
|
|
397
|
+
// Computed without the biasing applied to the "dir" variable.
|
|
398
|
+
// This test can cause reflection-map looking errors in the image
|
|
399
|
+
// (stuff looks shiny) if the transition is poor.
|
|
400
|
+
vec3 direction_to_probe = normalize(probe_position - position);
|
|
401
|
+
|
|
402
|
+
// The naive soft backface weight would ignore a probe when
|
|
403
|
+
// it is behind the surface. That's good for walls. But for small details inside of a
|
|
404
|
+
// room, the normals on the details might rule out all of the probes that have mutual
|
|
405
|
+
// visibility to the point. So, we instead use a "wrap shading" test below inspired by
|
|
406
|
+
// NPR work.
|
|
407
|
+
// weight *= max(0.0001, dot(direction_to_probe, normal));
|
|
408
|
+
|
|
409
|
+
// The small offset at the end reduces the "going to zero" impact
|
|
410
|
+
// where this is really close to exactly opposite
|
|
411
|
+
float backface_term = max(0.0001, (dot(direction_to_probe, normal) + 1.0) * 0.5);
|
|
412
|
+
weight *= backface_term * backface_term + 0.2;
|
|
413
|
+
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// Moment visibility test (depth)
|
|
417
|
+
{
|
|
418
|
+
|
|
419
|
+
weight *= lpv_probe_getVisibilityMask(lookup_position, probe_index);
|
|
420
|
+
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
// A tiny bit of light is really visible due to log perception, so
|
|
425
|
+
// crush tiny weights but keep the curve continuous. This must be done
|
|
426
|
+
// before the trilinear weights, because those should be preserved.
|
|
427
|
+
const float crushThreshold = 0.2;
|
|
428
|
+
|
|
429
|
+
if (weight < crushThreshold) {
|
|
430
|
+
weight *= weight * weight * (1.0 / (crushThreshold * crushThreshold));
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// Avoid zero weight
|
|
434
|
+
weight = max(0.000001, weight);
|
|
435
|
+
|
|
436
|
+
weight *= barycentric[i];
|
|
437
|
+
|
|
438
|
+
weight_sum += weight;
|
|
439
|
+
|
|
440
|
+
visibility[i] = weight;
|
|
357
441
|
}
|
|
358
442
|
|
|
443
|
+
// normalize
|
|
444
|
+
visibility /= weight_sum;
|
|
445
|
+
|
|
359
446
|
return visibility;
|
|
360
447
|
}
|
|
361
448
|
|
|
@@ -420,8 +507,8 @@ vec4 lpv_renormalize_weights(in vec4 source) {
|
|
|
420
507
|
|
|
421
508
|
float sum = source.x + source.y + source.z + source.w;
|
|
422
509
|
|
|
423
|
-
if (sum <= 0.
|
|
424
|
-
return vec4(
|
|
510
|
+
if (sum <= 0.0001) {
|
|
511
|
+
return vec4(0.0);
|
|
425
512
|
}
|
|
426
513
|
|
|
427
514
|
return source / sum;
|
|
@@ -430,12 +517,6 @@ vec4 lpv_renormalize_weights(in vec4 source) {
|
|
|
430
517
|
|
|
431
518
|
|
|
432
519
|
|
|
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
520
|
vec3 lpv_sample_irradiance(vec3 position, vec3 normal, vec3 view_direction) {
|
|
440
521
|
|
|
441
522
|
// Bias the position at which visibility is computed; this
|
|
@@ -457,16 +538,11 @@ vec3 lpv_sample_irradiance(vec3 position, vec3 normal, vec3 view_direction) {
|
|
|
457
538
|
uint nearest_tet = lpv_guess_initial_tet(lookup_position);
|
|
458
539
|
|
|
459
540
|
uint tet;
|
|
460
|
-
vec4
|
|
461
|
-
lpv_walk_to_tetrahedron(lookup_position, nearest_tet, tet,
|
|
541
|
+
vec4 barycentric_coordinates;
|
|
542
|
+
lpv_walk_to_tetrahedron(lookup_position, nearest_tet, tet, barycentric_coordinates);
|
|
462
543
|
|
|
463
544
|
// 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);
|
|
545
|
+
vec4 weights = lvp_mask_weights_by_visibility(lookup_position, normal, view_direction, tet, barycentric_coordinates);
|
|
470
546
|
|
|
471
547
|
if (tet == INVALID_TET) {
|
|
472
548
|
// 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":"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;
|
|
@@ -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
|