@woosh/meep-engine 2.110.4 → 2.110.6
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 +117 -111
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +118 -109
- package/package.json +1 -1
- package/src/core/events/signal/Signal.d.ts.map +1 -1
- package/src/core/events/signal/Signal.js +3 -98
- package/src/core/events/signal/dispatchViaProxy.d.ts +7 -0
- package/src/core/events/signal/dispatchViaProxy.d.ts.map +1 -0
- package/src/core/events/signal/dispatchViaProxy.js +60 -0
- package/src/core/events/signal/findSignalHandlerIndexByHandle.d.ts +9 -0
- package/src/core/events/signal/findSignalHandlerIndexByHandle.d.ts.map +1 -0
- package/src/core/events/signal/findSignalHandlerIndexByHandle.js +26 -0
- package/src/core/events/signal/findSignalHandlerIndexByHandleAndContext.d.ts +9 -0
- package/src/core/events/signal/findSignalHandlerIndexByHandleAndContext.d.ts.map +1 -0
- package/src/core/events/signal/findSignalHandlerIndexByHandleAndContext.js +21 -0
- package/src/core/fsm/simple/SimpleStateMachine.d.ts.map +1 -1
- package/src/core/fsm/simple/SimpleStateMachine.js +2 -1
- package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.d.ts +2 -2
- package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.d.ts.map +1 -1
- package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.js +1 -1
- package/src/core/geom/3d/sphere/sphere_fibonacci_point.d.ts +18 -0
- package/src/core/geom/3d/sphere/sphere_fibonacci_point.d.ts.map +1 -0
- package/src/core/geom/3d/sphere/sphere_fibonacci_point.js +51 -0
- package/src/engine/animation/clip/AnimationClip.d.ts.map +1 -1
- package/src/engine/animation/clip/AnimationClip.js +4 -0
- package/src/engine/animation/clip/AnimationInterpolationKind.d.ts +7 -0
- package/src/engine/animation/clip/AnimationInterpolationKind.d.ts.map +1 -0
- package/src/engine/animation/clip/AnimationInterpolationKind.js +9 -0
- package/src/engine/animation/clip/AnimationTrack.d.ts +12 -0
- package/src/engine/animation/clip/AnimationTrack.d.ts.map +1 -1
- package/src/engine/animation/clip/AnimationTrack.js +20 -1
- package/src/engine/animation/clip/AnimationTrackBinding.d.ts.map +1 -1
- package/src/engine/animation/clip/AnimationTrackBinding.js +12 -0
- package/src/engine/animation/clip/bind_property_writer.d.ts +9 -0
- package/src/engine/animation/clip/bind_property_writer.d.ts.map +1 -0
- package/src/engine/animation/clip/bind_property_writer.js +118 -0
- package/src/engine/animation/clip/curve_from_track_data.d.ts +12 -0
- package/src/engine/animation/clip/curve_from_track_data.d.ts.map +1 -0
- package/src/engine/animation/clip/curve_from_track_data.js +27 -0
- package/src/engine/animation/clip/curve_from_track_data_cubic_tangents.d.ts +10 -0
- package/src/engine/animation/clip/curve_from_track_data_cubic_tangents.d.ts.map +1 -0
- package/src/engine/animation/clip/curve_from_track_data_cubic_tangents.js +33 -0
- package/src/engine/animation/clip/curve_from_track_data_discrete.d.ts +10 -0
- package/src/engine/animation/clip/curve_from_track_data_discrete.d.ts.map +1 -0
- package/src/engine/animation/clip/curve_from_track_data_discrete.js +30 -0
- package/src/engine/animation/clip/curve_from_track_data_linear.d.ts +10 -0
- package/src/engine/animation/clip/curve_from_track_data_linear.d.ts.map +1 -0
- package/src/engine/animation/clip/curve_from_track_data_linear.js +25 -0
- package/src/engine/animation/clip/ecd_bind_animation_curve.d.ts.map +1 -1
- package/src/engine/animation/clip/ecd_bind_animation_curve.js +14 -239
- package/src/engine/animation/curve/AnimationCurve.d.ts +17 -17
- package/src/engine/animation/curve/AnimationCurve.d.ts.map +1 -1
- package/src/engine/animation/curve/AnimationCurve.js +30 -20
- package/src/engine/animation/curve/Keyframe.d.ts +5 -0
- package/src/engine/animation/curve/Keyframe.d.ts.map +1 -1
- package/src/engine/animation/curve/Keyframe.js +6 -0
- package/src/engine/animation/curve/binding/BoundValueWriter.d.ts +7 -0
- package/src/engine/animation/curve/binding/BoundValueWriter.d.ts.map +1 -1
- package/src/engine/animation/curve/binding/BoundValueWriter.js +9 -1
- package/src/engine/animation/curve/compute_curve_aabb.d.ts +1 -1
- package/src/engine/animation/curve/compute_curve_aabb.js +1 -1
- package/src/engine/ecs/EntityComponentDataset.d.ts.map +1 -1
- package/src/engine/ecs/EntityComponentDataset.js +9 -7
- package/src/engine/ecs/components/Tag.d.ts +2 -0
- package/src/engine/ecs/parent/EntityNode.d.ts.map +1 -1
- package/src/engine/ecs/parent/EntityNode.js +2 -1
- package/src/engine/graphics/geometry/buffered/makeGeometryIndexed.d.ts +2 -1
- package/src/engine/graphics/geometry/buffered/makeGeometryIndexed.d.ts.map +1 -1
- package/src/engine/graphics/geometry/buffered/makeGeometryIndexed.js +4 -1
- package/src/engine/graphics/sh3/gi/material/common.glsl +3 -3
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +4 -3
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts +2 -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 +6 -30
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map_fibonacci.d.ts +13 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map_fibonacci.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map_fibonacci.js +163 -0
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +2 -2
- package/src/engine/graphics/trail/x/RibbonXMaterialSpec.d.ts.map +1 -1
- package/src/engine/graphics/trail/x/RibbonXMaterialSpec.js +10 -2
- package/src/engine/graphics/trail/x/RibbonXPlugin.d.ts.map +1 -1
- package/src/engine/graphics/trail/x/RibbonXPlugin.js +7 -5
|
@@ -412,7 +412,8 @@ export class EntityNode {
|
|
|
412
412
|
// destroy children first
|
|
413
413
|
const children = this.__children;
|
|
414
414
|
const child_count = children.length;
|
|
415
|
-
|
|
415
|
+
|
|
416
|
+
for (let i = child_count - 1; i >= 0; i--) {
|
|
416
417
|
const child = children[i];
|
|
417
418
|
|
|
418
419
|
child.destroy();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
3
|
* @param {THREE.BufferGeometry} geometry
|
|
4
|
+
* @return {THREE.BufferGeometry}
|
|
4
5
|
*/
|
|
5
|
-
export function makeGeometryIndexed(geometry: THREE.BufferGeometry):
|
|
6
|
+
export function makeGeometryIndexed(geometry: THREE.BufferGeometry): THREE.BufferGeometry;
|
|
6
7
|
//# sourceMappingURL=makeGeometryIndexed.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeGeometryIndexed.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/buffered/makeGeometryIndexed.js"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"makeGeometryIndexed.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/buffered/makeGeometryIndexed.js"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,8CAHW,MAAM,cAAc,GACnB,MAAM,cAAc,CAwB/B"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { UintArrayForCount } from "../../../../core/collection/array/typed/uint_array_for_count.js";
|
|
2
1
|
import { BufferAttribute } from "three";
|
|
2
|
+
import { UintArrayForCount } from "../../../../core/collection/array/typed/uint_array_for_count.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
6
|
* @param {THREE.BufferGeometry} geometry
|
|
7
|
+
* @return {THREE.BufferGeometry}
|
|
7
8
|
*/
|
|
8
9
|
export function makeGeometryIndexed(geometry) {
|
|
9
10
|
let index_attribute = geometry.getIndex();
|
|
@@ -25,4 +26,6 @@ export function makeGeometryIndexed(geometry) {
|
|
|
25
26
|
|
|
26
27
|
geometry.setIndex(index_attribute);
|
|
27
28
|
}
|
|
29
|
+
|
|
30
|
+
return geometry;
|
|
28
31
|
}
|
|
@@ -447,12 +447,12 @@ vec4 lvp_mask_weights_by_visibility(in vec3 position, in vec3 normal, in vec3 vi
|
|
|
447
447
|
// room, the normals on the details might rule out all of the probes that have mutual
|
|
448
448
|
// visibility to the point. So, we instead use a "wrap shading" test below inspired by
|
|
449
449
|
// NPR work.
|
|
450
|
-
|
|
450
|
+
weight *= max(0.0001, dot(direction_to_probe, normal));
|
|
451
451
|
|
|
452
452
|
// The small offset at the end reduces the "going to zero" impact
|
|
453
453
|
// where this is really close to exactly opposite
|
|
454
|
-
float backface_term = max(0.0001, (dot(direction_to_probe, normal) + 1.0) * 0.5);
|
|
455
|
-
weight *= backface_term * backface_term + 0.05;
|
|
454
|
+
// float backface_term = max(0.0001, (dot(direction_to_probe, normal) + 1.0) * 0.5);
|
|
455
|
+
// weight *= backface_term * backface_term + 0.05;
|
|
456
456
|
|
|
457
457
|
}
|
|
458
458
|
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"PathTracerProbeRenderer.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js"],"names":[],"mappings":"AAuBA;IACI,mBAA0B;IAC1B,yBAAqB;IACrB,qBAAmB;IAEnB,qBAAyB;IAEzB,uBAA6B;IAE7B;;;;;;;;OAQG;IACH,kCAPW,MAAM,aACN,MAAM,YACN,MAAM,EAAE,mBACR,MAAM,UACN,MAAM,EAAE,iBACR,MAAM,QAchB;IAED,iFAuCC;IAKD,mBACC;IAED,4BAKC;CACJ;8BA9F6B,oBAAoB;2BAHvB,8BAA8B;gCADzB,mCAAmC"}
|
|
@@ -24,8 +24,8 @@ const sampled_irradiance = new Float32Array(3);
|
|
|
24
24
|
export class PathTracerProbeRenderer extends ProbeRenderer {
|
|
25
25
|
tracer = new PathTracer();
|
|
26
26
|
max_bounce_count = 5;
|
|
27
|
-
|
|
28
|
-
sample_count =
|
|
27
|
+
sample_count = 190;
|
|
28
|
+
// sample_count = 40960;
|
|
29
29
|
random = seededRandom(0);
|
|
30
30
|
|
|
31
31
|
scene = new PathTracedScene()
|
|
@@ -48,7 +48,8 @@ export class PathTracerProbeRenderer extends ProbeRenderer {
|
|
|
48
48
|
output, output_offset,
|
|
49
49
|
this.scene,
|
|
50
50
|
position, position_offset,
|
|
51
|
-
resolution, max_depth
|
|
51
|
+
resolution, max_depth,
|
|
52
|
+
16
|
|
52
53
|
);
|
|
53
54
|
}
|
|
54
55
|
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @param {number} position_offset
|
|
8
8
|
* @param {number} resolution
|
|
9
9
|
* @param {number} max_depth
|
|
10
|
+
* @param {number} [sub_sample_count]
|
|
10
11
|
*/
|
|
11
|
-
export function bake_octahedral_depth_map(result: number[], result_offset: number, scene: PathTracedScene, position: number[] | Vector3, position_offset: number, resolution: number, max_depth: number): void;
|
|
12
|
+
export function bake_octahedral_depth_map(result: number[], result_offset: number, scene: PathTracedScene, position: number[] | Vector3, position_offset: number, resolution: number, max_depth: number, sub_sample_count?: number): void;
|
|
12
13
|
//# sourceMappingURL=bake_octahedral_depth_map.d.ts.map
|
|
@@ -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":"AA2BA;;;;;;;;;;GAUG;AACH,kDATW,MAAM,EAAE,iBACR,MAAM,oCAEN,MAAM,EAAE,UAAQ,mBAChB,MAAM,cACN,MAAM,aACN,MAAM,qBACN,MAAM,QA+GhB"}
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
import { Ray3 } from "../../../../../../core/geom/3d/Ray3.js";
|
|
8
8
|
import { v3_distance } from "../../../../../../core/geom/vec3/v3_distance.js";
|
|
9
9
|
import { v3_dot_array_array } from "../../../../../../core/geom/vec3/v3_dot_array_array.js";
|
|
10
|
-
import { clamp } from "../../../../../../core/math/clamp.js";
|
|
11
10
|
import { max2 } from "../../../../../../core/math/max2.js";
|
|
12
11
|
import { generate_hammersley_jitter } from "../../../../../../core/math/statistics/generate_hammersley_jitter.js";
|
|
13
12
|
|
|
@@ -25,12 +24,6 @@ const scratch_ray = new Ray3();
|
|
|
25
24
|
*/
|
|
26
25
|
const ray_hit = [];
|
|
27
26
|
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
* @type {number}
|
|
31
|
-
*/
|
|
32
|
-
const SUB_SAMPLE_COUNT = 16;
|
|
33
|
-
|
|
34
27
|
|
|
35
28
|
/**
|
|
36
29
|
*
|
|
@@ -41,13 +34,14 @@ const SUB_SAMPLE_COUNT = 16;
|
|
|
41
34
|
* @param {number} position_offset
|
|
42
35
|
* @param {number} resolution
|
|
43
36
|
* @param {number} max_depth
|
|
37
|
+
* @param {number} [sub_sample_count]
|
|
44
38
|
*/
|
|
45
39
|
export function bake_octahedral_depth_map(
|
|
46
40
|
result, result_offset,
|
|
47
41
|
scene,
|
|
48
42
|
position, position_offset,
|
|
49
43
|
resolution,
|
|
50
|
-
max_depth
|
|
44
|
+
max_depth, sub_sample_count=4
|
|
51
45
|
) {
|
|
52
46
|
|
|
53
47
|
assert.lessThan(result_offset + resolution * resolution, UINT32_MAX, 'Result overflow');
|
|
@@ -55,26 +49,7 @@ export function bake_octahedral_depth_map(
|
|
|
55
49
|
scratch_ray.tMax = max_depth;
|
|
56
50
|
array_copy(position, position_offset, scratch_ray, 0, 3);
|
|
57
51
|
|
|
58
|
-
/**
|
|
59
|
-
* In radians, how wide of an arc does a single texel cover
|
|
60
|
-
* @type {number}
|
|
61
|
-
*/
|
|
62
|
-
const texel_angular_coverage = (Math.PI) / resolution;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Resolution bias is to compensate for discontinuities between samples
|
|
66
|
-
* The lower the resolution - the higher the discontinuities
|
|
67
|
-
* This is heights of an arch on a unit sphere, where arch spans 1/resolution angle
|
|
68
|
-
* Half-PI is to get the height at midpoint of the arch
|
|
69
|
-
* x2 is to get error over the entire circle, as the previous term only gets us to semicircle (we can skip this to get half the max rise, or mean)
|
|
70
|
-
* xMath.SQRT2 is to allow for diagonals between pixels
|
|
71
|
-
* @type {number}
|
|
72
|
-
*/
|
|
73
|
-
const RESOLUTION_BIAS = Math.sin(texel_angular_coverage) * Math.SQRT2 * 2;
|
|
74
|
-
|
|
75
|
-
// const NORMAL_BIAS = max2(1e-6, max_depth * 0.01);
|
|
76
52
|
const NORMAL_BIAS = 1e-6;
|
|
77
|
-
// const NORMAL_BIAS = clamp(max_depth * Math.sin(texel_angular_coverage),1e-6, max_depth*0.1);
|
|
78
53
|
|
|
79
54
|
const ray_direction = scratch_ray.direction;
|
|
80
55
|
|
|
@@ -82,7 +57,7 @@ export function bake_octahedral_depth_map(
|
|
|
82
57
|
|
|
83
58
|
const texel_uv_scale = 0.5 / (resolution);
|
|
84
59
|
|
|
85
|
-
const jittered_sub_samples = generate_hammersley_jitter(
|
|
60
|
+
const jittered_sub_samples = generate_hammersley_jitter(sub_sample_count);
|
|
86
61
|
|
|
87
62
|
|
|
88
63
|
for (let oct_x = 0; oct_x < resolution; oct_x++) {
|
|
@@ -101,7 +76,7 @@ export function bake_octahedral_depth_map(
|
|
|
101
76
|
u * 2 - 1, v * 2 - 1
|
|
102
77
|
);
|
|
103
78
|
|
|
104
|
-
for (let sub_sample_index = 0; sub_sample_index <
|
|
79
|
+
for (let sub_sample_index = 0; sub_sample_index < sub_sample_count; sub_sample_index++) {
|
|
105
80
|
|
|
106
81
|
const sample_index2 = sub_sample_index * 2;
|
|
107
82
|
|
|
@@ -170,4 +145,5 @@ export function bake_octahedral_depth_map(
|
|
|
170
145
|
}
|
|
171
146
|
}
|
|
172
147
|
|
|
173
|
-
}
|
|
148
|
+
}
|
|
149
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {number[]} result
|
|
4
|
+
* @param {number} result_offset
|
|
5
|
+
* @param {PathTracedScene} scene
|
|
6
|
+
* @param {number[]|Vector3} position
|
|
7
|
+
* @param {number} position_offset
|
|
8
|
+
* @param {number} resolution
|
|
9
|
+
* @param {number} max_depth
|
|
10
|
+
* @param {number} [density]
|
|
11
|
+
*/
|
|
12
|
+
export function bake_octahedral_depth_map_fibonacci(result: number[], result_offset: number, scene: PathTracedScene, position: number[] | Vector3, position_offset: number, resolution: number, max_depth: number, density?: number): void;
|
|
13
|
+
//# sourceMappingURL=bake_octahedral_depth_map_fibonacci.d.ts.map
|
package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map_fibonacci.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bake_octahedral_depth_map_fibonacci.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map_fibonacci.js"],"names":[],"mappings":"AA6BA;;;;;;;;;;GAUG;AACH,4DATW,MAAM,EAAE,iBACR,MAAM,oCAEN,MAAM,EAAE,UAAQ,mBAChB,MAAM,cACN,MAAM,aACN,MAAM,YACN,MAAM,QA4HhB"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { assert } from "../../../../../../core/assert.js";
|
|
2
|
+
import { UINT32_MAX } from "../../../../../../core/binary/UINT32_MAX.js";
|
|
3
|
+
import { array_copy } from "../../../../../../core/collection/array/array_copy.js";
|
|
4
|
+
import {
|
|
5
|
+
decode_octahedron_to_unit
|
|
6
|
+
} from "../../../../../../core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js";
|
|
7
|
+
import {
|
|
8
|
+
encode_unit_to_octahedron
|
|
9
|
+
} from "../../../../../../core/geom/3d/normal/octahedron/encode_unit_to_octahedron.js";
|
|
10
|
+
import { Ray3 } from "../../../../../../core/geom/3d/Ray3.js";
|
|
11
|
+
import { sphere_fibonacci_point } from "../../../../../../core/geom/3d/sphere/sphere_fibonacci_point.js";
|
|
12
|
+
import { v3_distance } from "../../../../../../core/geom/vec3/v3_distance.js";
|
|
13
|
+
import { v3_dot_array_array } from "../../../../../../core/geom/vec3/v3_dot_array_array.js";
|
|
14
|
+
import { max2 } from "../../../../../../core/math/max2.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Weights of rays that are aligned with the probe direction get exponentially weighted by this exponent
|
|
18
|
+
* @type {number}
|
|
19
|
+
*/
|
|
20
|
+
const DEPTH_SHARPNESS = 3;
|
|
21
|
+
|
|
22
|
+
const scratch_ray = new Ray3();
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @type {number[]}
|
|
27
|
+
*/
|
|
28
|
+
const ray_hit = [];
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param {number[]} result
|
|
33
|
+
* @param {number} result_offset
|
|
34
|
+
* @param {PathTracedScene} scene
|
|
35
|
+
* @param {number[]|Vector3} position
|
|
36
|
+
* @param {number} position_offset
|
|
37
|
+
* @param {number} resolution
|
|
38
|
+
* @param {number} max_depth
|
|
39
|
+
* @param {number} [density]
|
|
40
|
+
*/
|
|
41
|
+
export function bake_octahedral_depth_map_fibonacci(
|
|
42
|
+
result, result_offset,
|
|
43
|
+
scene,
|
|
44
|
+
position, position_offset,
|
|
45
|
+
resolution,
|
|
46
|
+
max_depth, density = 4
|
|
47
|
+
) {
|
|
48
|
+
|
|
49
|
+
const pixel_count = resolution * resolution;
|
|
50
|
+
|
|
51
|
+
assert.lessThan(result_offset + pixel_count, UINT32_MAX, 'Result overflow');
|
|
52
|
+
|
|
53
|
+
scratch_ray.tMax = max_depth;
|
|
54
|
+
array_copy(position, position_offset, scratch_ray, 0, 3);
|
|
55
|
+
|
|
56
|
+
const NORMAL_BIAS = 1e-6;
|
|
57
|
+
|
|
58
|
+
const ray_direction = scratch_ray.direction;
|
|
59
|
+
|
|
60
|
+
const probe_direction = new Float32Array(3);
|
|
61
|
+
|
|
62
|
+
const direction_sample_count = pixel_count * density;
|
|
63
|
+
|
|
64
|
+
const octahedral_uv = new Float32Array(2);
|
|
65
|
+
|
|
66
|
+
const weights = new Float32Array(pixel_count);
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
// clear result data
|
|
70
|
+
for (let i = 0; i < pixel_count; i++) {
|
|
71
|
+
|
|
72
|
+
const address = result_offset + i * 2;
|
|
73
|
+
|
|
74
|
+
result[address] = 0;
|
|
75
|
+
result[address + 1] = 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
for (let sample_index = 0; sample_index < direction_sample_count; sample_index++) {
|
|
79
|
+
sphere_fibonacci_point(ray_direction, 0, sample_index, direction_sample_count);
|
|
80
|
+
|
|
81
|
+
encode_unit_to_octahedron(octahedral_uv, 0, ray_direction[0], ray_direction[1], ray_direction[2]);
|
|
82
|
+
|
|
83
|
+
const sample_u = octahedral_uv[0] * 0.5 + 0.5;
|
|
84
|
+
const sample_v = octahedral_uv[1] * 0.5 + 0.5;
|
|
85
|
+
|
|
86
|
+
const oct_x = (sample_u * resolution) >>> 0;
|
|
87
|
+
const oct_y = (sample_v * resolution) >>> 0;
|
|
88
|
+
|
|
89
|
+
// offset position by half a pixel, as we are storing values for pixel centers
|
|
90
|
+
const u = (oct_x + 0.5) / (resolution);
|
|
91
|
+
const v = (oct_y + 0.5) / (resolution);
|
|
92
|
+
|
|
93
|
+
decode_octahedron_to_unit(
|
|
94
|
+
probe_direction, 0,
|
|
95
|
+
u * 2 - 1, v * 2 - 1
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
let distance = scene.trace(ray_hit, scratch_ray);
|
|
100
|
+
|
|
101
|
+
if (distance < 0) {
|
|
102
|
+
// no hit
|
|
103
|
+
distance = max_depth;
|
|
104
|
+
} else {
|
|
105
|
+
const surface_normal_x = ray_hit[3];
|
|
106
|
+
const surface_normal_y = ray_hit[4];
|
|
107
|
+
const surface_normal_z = ray_hit[5];
|
|
108
|
+
|
|
109
|
+
const surface_position_x = ray_hit[0];
|
|
110
|
+
const surface_position_y = ray_hit[1];
|
|
111
|
+
const surface_position_z = ray_hit[2];
|
|
112
|
+
|
|
113
|
+
const hit_normal_bias = NORMAL_BIAS;
|
|
114
|
+
|
|
115
|
+
// sink the contact into the surface along the hit normal
|
|
116
|
+
const biased_hit_x = surface_position_x + surface_normal_x * hit_normal_bias;
|
|
117
|
+
const biased_hit_y = surface_position_y + surface_normal_y * hit_normal_bias;
|
|
118
|
+
const biased_hit_z = surface_position_z + surface_normal_z * hit_normal_bias;
|
|
119
|
+
|
|
120
|
+
distance = v3_distance(
|
|
121
|
+
scratch_ray[0], scratch_ray[1], scratch_ray[2],
|
|
122
|
+
biased_hit_x, biased_hit_y, biased_hit_z
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const direction_dot_product = v3_dot_array_array(
|
|
128
|
+
ray_direction, 0,
|
|
129
|
+
probe_direction, 0
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
const weight = Math.pow(
|
|
133
|
+
max2(
|
|
134
|
+
0,
|
|
135
|
+
direction_dot_product
|
|
136
|
+
),
|
|
137
|
+
DEPTH_SHARPNESS
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
const mean = distance * weight;
|
|
141
|
+
const mean2 = distance * distance * weight;
|
|
142
|
+
|
|
143
|
+
const pixel_index = oct_y * resolution + oct_x;
|
|
144
|
+
|
|
145
|
+
const address = result_offset + pixel_index * 2;
|
|
146
|
+
|
|
147
|
+
weights[pixel_index] += weight;
|
|
148
|
+
|
|
149
|
+
result[address] += mean;
|
|
150
|
+
result[address + 1] += mean2;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
for (let i = 0; i < pixel_count; i++) {
|
|
154
|
+
|
|
155
|
+
const weight_sum = weights[i];
|
|
156
|
+
|
|
157
|
+
const address = result_offset + i * 2;
|
|
158
|
+
|
|
159
|
+
result[address] /= weight_sum;
|
|
160
|
+
result[address + 1] /= weight_sum;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
}
|
|
@@ -382,14 +382,14 @@ async function main(engine) {
|
|
|
382
382
|
// const path = 'data/models/LowPolyTownshipSet/Small_house/Small_house.gltf';
|
|
383
383
|
// const path = 'data/models/samples/cyberpunk_bike/scene.gltf';
|
|
384
384
|
// const path = 'data/models/LowPolyTownshipSet/Town_Hall/model.gltf';
|
|
385
|
-
const path = 'data/models/sibenik/3-window-less/model.gltf';
|
|
385
|
+
// const path = 'data/models/sibenik/3-window-less/model.gltf';
|
|
386
386
|
// const path = 'data/models/sponza-pbr/gltf/sponza.glb';
|
|
387
387
|
// const path = 'data/models/samples/susanne.glb';
|
|
388
388
|
// const path = 'data/models/samples/teapot.gltf';
|
|
389
389
|
// const path = 'data/models/samples/salle_de_bain/model.glb';
|
|
390
390
|
// const path = 'data/models/samples/conference/model-no-curtains.glb';
|
|
391
391
|
// const path = 'data/models/pica_pica/pica_pica.gltf';
|
|
392
|
-
|
|
392
|
+
const path = 'data/models/samples/gi_box_01/model.glb';
|
|
393
393
|
// const path = 'data/models/samples/low_poly_classroom/no-glass/model.gltf';
|
|
394
394
|
|
|
395
395
|
const mesh_asset = await engine.assetManager.promise(path, 'model/gltf+json');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RibbonXMaterialSpec.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/trail/x/RibbonXMaterialSpec.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RibbonXMaterialSpec.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/trail/x/RibbonXMaterialSpec.js"],"names":[],"mappings":"AAGA;IAEQ;;;OAGG;IACH,SAFU,SAAO,IAAI,CAEF;IAGvB,4BAEC;IAED,eAEC;IAED;;aASC;CACJ"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assert } from "../../../../core/assert.js";
|
|
1
2
|
import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
|
|
2
3
|
|
|
3
4
|
export class RibbonXMaterialSpec {
|
|
@@ -17,7 +18,14 @@ export class RibbonXMaterialSpec {
|
|
|
17
18
|
return computeStringHash(this.diffuse);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
fromJSON({diffuse}) {
|
|
21
|
-
|
|
21
|
+
fromJSON({ diffuse }) {
|
|
22
|
+
|
|
23
|
+
if (diffuse !== undefined) {
|
|
24
|
+
assert.isString(diffuse, "diffuse");
|
|
25
|
+
|
|
26
|
+
this.diffuse = diffuse;
|
|
27
|
+
} else {
|
|
28
|
+
this.diffuse = null;
|
|
29
|
+
}
|
|
22
30
|
}
|
|
23
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RibbonXPlugin.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/trail/x/RibbonXPlugin.js"],"names":[],"mappings":"AASA;IACI,8BA6BC;IA1BG,WAA2B;IAE3B;;;;OAIG;IACH,+BAKE;IAEF;;;;MAIC;IAED;;;;OAIG;IACH,oBAAwC;IAG5C,sCAIC;IAED,wBAMC;IAED,yBAKC;IAED;;;;OAIG;IACH,0EAIC;IAED;;;;OAIG;IACH,8CAFa,eAAe,CAe3B;IAGD;;;;;OAKG;IACH,
|
|
1
|
+
{"version":3,"file":"RibbonXPlugin.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/trail/x/RibbonXPlugin.js"],"names":[],"mappings":"AASA;IACI,8BA6BC;IA1BG,WAA2B;IAE3B;;;;OAIG;IACH,+BAKE;IAEF;;;;MAIC;IAED;;;;OAIG;IACH,oBAAwC;IAG5C,sCAIC;IAED,wBAMC;IAED,yBAKC;IAED;;;;OAIG;IACH,0EAIC;IAED;;;;OAIG;IACH,8CAFa,eAAe,CAe3B;IAGD;;;;;OAKG;IACH,yBA8BC;CACJ;6BA9H4B,iCAAiC;wBAL1B,OAAO;gCAOX,sBAAsB"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { EnginePlugin } from "../../../plugin/EnginePlugin.js";
|
|
2
|
-
import { RibbonMaterialX } from "./RibbonMaterialX.js";
|
|
3
1
|
import { DoubleSide, Vector2 } from "three";
|
|
4
|
-
import { GameAssetType } from "../../../asset/GameAssetType.js";
|
|
5
2
|
import { Cache } from "../../../../core/cache/Cache.js";
|
|
6
3
|
import { invokeObjectEquals } from "../../../../core/model/object/invokeObjectEquals.js";
|
|
7
4
|
import { invokeObjectHash } from "../../../../core/model/object/invokeObjectHash.js";
|
|
5
|
+
import { GameAssetType } from "../../../asset/GameAssetType.js";
|
|
6
|
+
import { EnginePlugin } from "../../../plugin/EnginePlugin.js";
|
|
8
7
|
import { MaterialManager } from "../../material/manager/MaterialManager.js";
|
|
8
|
+
import { RibbonMaterialX } from "./RibbonMaterialX.js";
|
|
9
9
|
|
|
10
10
|
export class RibbonXPlugin extends EnginePlugin {
|
|
11
11
|
initialize(engine) {
|
|
@@ -112,11 +112,13 @@ export class RibbonXPlugin extends EnginePlugin {
|
|
|
112
112
|
|
|
113
113
|
material.uniforms.resolution = this.__shared_uniforms.resolution;
|
|
114
114
|
|
|
115
|
-
if (spec.diffuse
|
|
115
|
+
if (typeof spec.diffuse === "string") {
|
|
116
116
|
const am = this.engine.assetManager;
|
|
117
117
|
|
|
118
118
|
am.get({
|
|
119
|
-
path: spec.diffuse,
|
|
119
|
+
path: spec.diffuse,
|
|
120
|
+
type: GameAssetType.Texture,
|
|
121
|
+
callback: (asset) => {
|
|
120
122
|
material.uniforms.uDiffuse.value = asset.create();
|
|
121
123
|
}, failure: console.warn
|
|
122
124
|
});
|