@woosh/meep-engine 2.119.69 → 2.119.71
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/package.json +1 -1
- package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts +10 -1
- package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/gi/material/MaterialTransformer.js +33 -12
- package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.d.ts.map +1 -1
- package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.js +10 -9
- 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/prototypeSH3Probe.js +2 -2
package/package.json
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where should probes be resolved?
|
|
3
|
+
*/
|
|
4
|
+
export type ProbeResolutionStage = number;
|
|
5
|
+
export namespace ProbeResolutionStage {
|
|
6
|
+
let Vertex: number;
|
|
7
|
+
let Fragment: number;
|
|
8
|
+
}
|
|
1
9
|
export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
2
10
|
/**
|
|
3
11
|
*
|
|
4
12
|
* @param {LightProbeVolume} volume
|
|
13
|
+
* @param {number|ProbeResolutionStage} stage either "vertex" or "fragment". Vertex sampling is faster but less accurate, fragment is more expensive and precise
|
|
5
14
|
*/
|
|
6
|
-
constructor({ volume }: LightProbeVolume);
|
|
15
|
+
constructor({ volume, stage, }: LightProbeVolume);
|
|
7
16
|
/**
|
|
8
17
|
*
|
|
9
18
|
* @param {number} v
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaterialTransformer.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/gi/material/MaterialTransformer.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MaterialTransformer.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/gi/material/MaterialTransformer.js"],"names":[],"mappings":";;;mCAqBU,MAAM;;;;;AAchB;IA+II;;;;OAIG;IACH,kDAaC;IA3BD;;;OAGG;IACH,2BAEC;IAdD;;;OAGG;IACH,wBAEC;IA+BD,sBAIC;IAED,sBAiDC;IAED,eAgDC;IAED,4BA2BC;;CACJ;4CAtU2C,0DAA0D"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Vector3 } from "three";
|
|
2
|
+
import { assert } from "../../../../../core/assert.js";
|
|
2
3
|
import { BinaryDataType } from "../../../../../core/binary/type/BinaryDataType.js";
|
|
3
4
|
import { AABB3 } from "../../../../../core/geom/3d/aabb/AABB3.js";
|
|
4
5
|
import { aabb3_from_v3_array } from "../../../../../core/geom/3d/aabb/aabb3_from_v3_array.js";
|
|
@@ -20,7 +21,7 @@ const PROPERTY_TRANSFORMER_MARKER = '@light-probe-volume-material-transformer';
|
|
|
20
21
|
* Where should probes be resolved?
|
|
21
22
|
* @enum {number}
|
|
22
23
|
*/
|
|
23
|
-
const
|
|
24
|
+
export const ProbeResolutionStage = {
|
|
24
25
|
/**
|
|
25
26
|
* Cheaper, but less precise
|
|
26
27
|
*/
|
|
@@ -31,6 +32,7 @@ const ProbeResolutionSpace = {
|
|
|
31
32
|
Fragment: 1
|
|
32
33
|
};
|
|
33
34
|
|
|
35
|
+
|
|
34
36
|
export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
35
37
|
|
|
36
38
|
/**
|
|
@@ -44,9 +46,9 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
|
44
46
|
|
|
45
47
|
/**
|
|
46
48
|
*
|
|
47
|
-
* @type {
|
|
49
|
+
* @type {ProbeResolutionStage|number}
|
|
48
50
|
*/
|
|
49
|
-
#
|
|
51
|
+
#sampling_stage = ProbeResolutionStage.Fragment
|
|
50
52
|
|
|
51
53
|
#textures = {
|
|
52
54
|
vertex: new AttributeDataTexture(
|
|
@@ -130,6 +132,10 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
|
130
132
|
}
|
|
131
133
|
};
|
|
132
134
|
|
|
135
|
+
/**
|
|
136
|
+
*
|
|
137
|
+
* @type {number}
|
|
138
|
+
*/
|
|
133
139
|
#uniform_version = -1;
|
|
134
140
|
|
|
135
141
|
/**
|
|
@@ -139,15 +145,15 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
|
139
145
|
#onBeforeCompile = (shader) => {
|
|
140
146
|
Object.assign(shader.uniforms, this.#uniforms);
|
|
141
147
|
|
|
142
|
-
switch (this.#
|
|
143
|
-
case
|
|
148
|
+
switch (this.#sampling_stage) {
|
|
149
|
+
case ProbeResolutionStage.Vertex:
|
|
144
150
|
space_vertex_transform_shader(shader);
|
|
145
151
|
break;
|
|
146
|
-
case
|
|
152
|
+
case ProbeResolutionStage.Fragment:
|
|
147
153
|
space_fragment_transform_shader(shader);
|
|
148
154
|
break;
|
|
149
155
|
default:
|
|
150
|
-
throw new Error(`Unsupported resolution space ${this.#
|
|
156
|
+
throw new Error(`Unsupported resolution space ${this.#sampling_stage}`);
|
|
151
157
|
}
|
|
152
158
|
};
|
|
153
159
|
|
|
@@ -169,16 +175,24 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
|
169
175
|
this.#uniforms.lpv_f_intensity.value = v;
|
|
170
176
|
}
|
|
171
177
|
|
|
178
|
+
|
|
172
179
|
/**
|
|
173
180
|
*
|
|
174
181
|
* @param {LightProbeVolume} volume
|
|
182
|
+
* @param {number|ProbeResolutionStage} stage either "vertex" or "fragment". Vertex sampling is faster but less accurate, fragment is more expensive and precise
|
|
175
183
|
*/
|
|
176
184
|
constructor({
|
|
177
|
-
volume
|
|
185
|
+
volume,
|
|
186
|
+
stage = ProbeResolutionStage.Vertex,
|
|
178
187
|
}) {
|
|
188
|
+
|
|
179
189
|
super();
|
|
180
190
|
|
|
191
|
+
assert.defined(volume, 'volume');
|
|
192
|
+
assert.enum(stage, ProbeResolutionStage, 'stage');
|
|
193
|
+
|
|
181
194
|
this.#volume = volume;
|
|
195
|
+
this.#sampling_stage = stage;
|
|
182
196
|
|
|
183
197
|
}
|
|
184
198
|
|
|
@@ -193,6 +207,10 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
|
193
207
|
|
|
194
208
|
const bounds = this.#mesh_bounds;
|
|
195
209
|
|
|
210
|
+
const ex = bounds.getExtentsX();
|
|
211
|
+
const ey = bounds.getExtentsY();
|
|
212
|
+
const ez = bounds.getExtentsZ();
|
|
213
|
+
|
|
196
214
|
const lookup = this.#mesh_lookup;
|
|
197
215
|
|
|
198
216
|
const image = lookup.image;
|
|
@@ -202,6 +220,8 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
|
202
220
|
const res_x = image.width;
|
|
203
221
|
|
|
204
222
|
const volume = this.#volume;
|
|
223
|
+
const points = volume.points;
|
|
224
|
+
const mesh = volume.mesh;
|
|
205
225
|
|
|
206
226
|
let last_tet = 0;
|
|
207
227
|
|
|
@@ -214,11 +234,11 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
|
214
234
|
const n_y = (y + 0.5) / res_y
|
|
215
235
|
const n_z = (z + 0.5) / res_z
|
|
216
236
|
|
|
217
|
-
const w_x = n_x *
|
|
218
|
-
const w_y = n_y *
|
|
219
|
-
const w_z = n_z *
|
|
237
|
+
const w_x = n_x * ex + bounds.x0;
|
|
238
|
+
const w_y = n_y * ey + bounds.y0;
|
|
239
|
+
const w_z = n_z * ez + bounds.z0;
|
|
220
240
|
|
|
221
|
-
const tet =
|
|
241
|
+
const tet = mesh.walkToTetraContainingPoint(w_x, w_y, w_z, points, last_tet);
|
|
222
242
|
|
|
223
243
|
if (tet !== -1) {
|
|
224
244
|
last_tet = tet;
|
|
@@ -241,6 +261,7 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
|
241
261
|
}
|
|
242
262
|
|
|
243
263
|
if (this.#uniform_version === lpv.version) {
|
|
264
|
+
// up to date
|
|
244
265
|
return;
|
|
245
266
|
}
|
|
246
267
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_vertex_shader.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build_vertex_shader.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.js"],"names":[],"mappings":"AA8CA;;;GAGG;AACH,4CAFW,MAAM,UAchB"}
|
|
@@ -3,6 +3,7 @@ import PREAMBLE_COMMON from "../common.js";
|
|
|
3
3
|
|
|
4
4
|
import PREAMBLE from "./preable.vert.js";
|
|
5
5
|
|
|
6
|
+
//language=GLSL
|
|
6
7
|
const SHADER_CHUNK_ACCUMULATION = `
|
|
7
8
|
{
|
|
8
9
|
// lookup nearby tet
|
|
@@ -11,12 +12,15 @@ const SHADER_CHUNK_ACCUMULATION = `
|
|
|
11
12
|
vec3 lookup_coordinates = (worldPosition.xyz - lpv_mesh_bounds_min) / (lpv_mesh_bounds_max - lpv_mesh_bounds_min) ;
|
|
12
13
|
|
|
13
14
|
uint nearest_tet = lpv_guess_initial_tet( worldPosition.xyz );
|
|
14
|
-
|
|
15
|
+
|
|
15
16
|
uint tet;
|
|
16
|
-
vec4
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
vec4 barycentric_coordinates;
|
|
18
|
+
lpv_walk_to_tetrahedron(position, nearest_tet, tet, barycentric_coordinates);
|
|
19
|
+
|
|
20
|
+
vec3 worldNormal = normalize(inverseTransformDirection( normalize(normal), viewMatrix ));
|
|
21
|
+
vec3 view_direction = vec3(0.0); // TODO build an actual view direction vector
|
|
22
|
+
|
|
23
|
+
vec4 weights = lvp_mask_weights_by_visibility(worldPosition.xyz, worldNormal, view_direction, tet, barycentric_coordinates);
|
|
20
24
|
|
|
21
25
|
if(tet == INVALID_TET){
|
|
22
26
|
lpv_values = vec3[](
|
|
@@ -34,10 +38,7 @@ const SHADER_CHUNK_ACCUMULATION = `
|
|
|
34
38
|
);
|
|
35
39
|
}else{
|
|
36
40
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
//weights = lpv_bias_weight_by_normal(worldPosition.xyz, normal, tet, weights);
|
|
40
|
-
|
|
41
|
+
|
|
41
42
|
lpv_values = lpv_interpolate_probes(weights, tet);
|
|
42
43
|
}
|
|
43
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LightProbeVolume.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/LightProbeVolume.js"],"names":[],"mappings":"AAWA;;;GAGG;AACH;IAiCI,sBAEC;IAED,cAkBC;IAED;;;OAGG;IACH,4BAEC;IAED,uBAEC;IAED,0BAEC;IAMD;;;OAGG;IACH,sCAIC;IAZD,mCAEC;IAYD,sBAEC;IAMD,uBAGC;IAPD,oBAEC;IAsCD;;;;;;OAMG;IACH,aALW,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,CAqBlB;IAMD;;;OAGG;IACH,oBAFW,MAAM,QAYhB;IAED;;;;OAIG;IACH,sCAFW,UAAQ;QAAC,CAAC,EAAC,MAAM,CAAC;QAAC,CAAC,EAAC,MAAM,CAAC;QAAC,CAAC,EAAC,MAAM,CAAA;KAAC,QAOhD;IAED;;OAEG;IACH,mBAcC;IAGD,yBAEC;;CAEJ;
|
|
1
|
+
{"version":3,"file":"LightProbeVolume.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/LightProbeVolume.js"],"names":[],"mappings":"AAWA;;;GAGG;AACH;IAiCI;;;OAGG;IACH,sBAEC;IAED,cAkBC;IAED;;;OAGG;IACH,4BAEC;IAED,uBAEC;IAED,0BAEC;IAMD;;;OAGG;IACH,sCAIC;IAZD,mCAEC;IAYD,sBAEC;IAMD,uBAGC;IAPD,oBAEC;IAsCD;;;;;;OAMG;IACH,aALW,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,CAqBlB;IAMD;;;OAGG;IACH,oBAFW,MAAM,QAYhB;IAED;;;;OAIG;IACH,sCAFW,UAAQ;QAAC,CAAC,EAAC,MAAM,CAAC;QAAC,CAAC,EAAC,MAAM,CAAC;QAAC,CAAC,EAAC,MAAM,CAAA;KAAC,QAOhD;IAED;;OAEG;IACH,mBAcC;IAGD,yBAEC;;CAEJ;gCAlO+B,wDAAwD"}
|
|
@@ -317,7 +317,7 @@ async function main(engine) {
|
|
|
317
317
|
// const path = 'data/models/samples/just_a_girl/scene.gltf';
|
|
318
318
|
// const path = 'data/models/samples/slum_house/scene.gltf';
|
|
319
319
|
// const path = 'data/models/samples/jack_trigger/scene.gltf';
|
|
320
|
-
const path = 'data/models/samples/cornell_box/scene.gltf';
|
|
320
|
+
// const path = 'data/models/samples/cornell_box/scene.gltf';
|
|
321
321
|
// const path = 'data/models/Slaughter Mech/Slaugter Mech.gltf';
|
|
322
322
|
// const path = 'data/models/samples/gi_box_01/model-thick-1.glb';
|
|
323
323
|
// const path = 'data/models/samples/ancient_bath_house_-_modular_set/scene.gltf';
|
|
@@ -333,7 +333,7 @@ async function main(engine) {
|
|
|
333
333
|
// const path = 'data/models/samples/teapot.gltf';
|
|
334
334
|
// const path = 'data/models/samples/salle_de_bain/model.glb';
|
|
335
335
|
// const path = 'data/models/samples/conference/model-no-curtains.glb';
|
|
336
|
-
|
|
336
|
+
const path = 'data/models/pica_pica/pica_pica.gltf';
|
|
337
337
|
// const path = 'data/models/samples/gi_box_01/model.glb';
|
|
338
338
|
// const path = 'data/models/samples/low_poly_classroom/no-glass/model.gltf';
|
|
339
339
|
// const path = 'customer_data/halon_scene.glb';
|