@woosh/meep-engine 2.33.34 → 2.33.38

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.
Files changed (67) hide show
  1. package/core/collection/HashMap.js +19 -12
  2. package/core/collection/table/RowFirstTable.js +13 -8
  3. package/core/collection/table/RowFirstTableSpec.js +6 -0
  4. package/core/color/Color.js +5 -9
  5. package/core/color/ColorUtils.js +4 -150
  6. package/core/color/YCbCr_to_rgb_uint24.js +20 -0
  7. package/core/color/hsv2rgb.js +54 -0
  8. package/core/color/int2rgb.js +12 -0
  9. package/core/color/parseHex.js +18 -0
  10. package/core/color/rgb2hex.js +16 -0
  11. package/core/color/rgb2hsv.js +47 -0
  12. package/core/color/rgb2uint24.js +17 -0
  13. package/core/color/rgb_to_YCbCr_uint24.js +18 -0
  14. package/core/geom/3d/aabb/compute_aabb_from_points.js +28 -0
  15. package/core/geom/3d/plane/orient3d_fast.js +51 -0
  16. package/core/geom/3d/plane/plane_computeConvex3PlaneIntersection.js +5 -0
  17. package/core/geom/3d/tetrahedra/GetDepthForTetrahedronProbe.glsl +43 -0
  18. package/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.js +177 -0
  19. package/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.spec.js +66 -0
  20. package/core/geom/3d/tetrahedra/compute_circumsphere.js +271 -0
  21. package/core/geom/3d/tetrahedra/compute_delaunay_tetrahedral_mesh.js +50 -0
  22. package/core/geom/3d/tetrahedra/compute_delaunay_tetrahedral_mesh.spec.js +14 -0
  23. package/core/geom/3d/tetrahedra/point_in_tetrahedron_circumsphere.js +77 -0
  24. package/core/geom/3d/tetrahedra/tetrahedra_collection.js +279 -0
  25. package/core/geom/3d/tetrahedra/tetrahedron_contains_point.js +25 -0
  26. package/core/geom/Quaternion.js +4 -0
  27. package/core/math/hash/murmur3_32.js +39 -0
  28. package/core/process/undo/ActionProcessor.d.ts +2 -0
  29. package/core/process/undo/ActionProcessor.js +15 -4
  30. package/editor/tools/FoliagePaintTool.js +1 -1
  31. package/editor/tools/GridPaintTool.js +1 -1
  32. package/engine/ecs/foliage/InstancedFoliage.js +45 -0
  33. package/engine/ecs/foliage/ecs/InstancedMeshLayer.js +4 -0
  34. package/engine/ecs/storage/BinaryBufferSerializer.js +48 -38
  35. package/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +1 -1
  36. package/engine/ecs/terrain/ecs/splat/SplatMapOptimizerDebugger.js +1 -1
  37. package/engine/ecs/terrain/tiles/TerrainTile.js +1 -1
  38. package/engine/graphics/GraphicsEngine.js +7 -0
  39. package/engine/graphics/ecs/mesh/Mesh.js +2 -2
  40. package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +13 -0
  41. package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +339 -314
  42. package/engine/graphics/micron/build/PatchRepresentation.js +1 -1
  43. package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +1 -1
  44. package/engine/graphics/micron/build/fill_patch_geometry_data.js +1 -1
  45. package/engine/graphics/micron/format/serialization/deserialize_patch.js +1 -1
  46. package/engine/graphics/micron/format/serialization/serialize_patch.js +1 -1
  47. package/engine/graphics/micron/prototypeVirtualGeometry.js +4 -1
  48. package/engine/graphics/micron/render/instanced/PatchDataTextures.js +3 -3
  49. package/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +1 -1
  50. package/engine/graphics/micron/render/instanced/shader/shader_rewrite_standard.js +1 -1
  51. package/engine/graphics/micron/render/makeThreeMeshFromVirtualGeometry.js +1 -1
  52. package/engine/graphics/micron/render/v1/MaterialContext.js +0 -24
  53. package/engine/graphics/micron/render/v1/MaterialVertexSpec.js +2 -2
  54. package/engine/graphics/micron/render/v1/ThreeVirtualGeometryAdapter.js +1 -1
  55. package/engine/graphics/micron/render/v1/VGThreeRenderer.js +7 -3
  56. package/engine/graphics/particles/node-based/rendering/billboard/ParticleBillboardShader.js +1 -1
  57. package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +100 -55
  58. package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +6 -1
  59. package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +1 -0
  60. package/engine/graphics/render/forward_plus/cluster/compute_light_data_hash_0.js +1 -1
  61. package/engine/graphics/render/forward_plus/materials/fp_build_fragment_shader.js +17 -4
  62. package/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +1 -1
  63. package/engine/graphics/render/visibility/VisibilityComputer.js +8 -7
  64. package/engine/graphics/shaders/TerrainShader.js +5 -5
  65. package/engine/graphics/shadows/testShadowMapRendering.js +192 -0
  66. package/package.json +3 -1
  67. package/view/elements/ColorPickerView.js +2 -1
@@ -381,7 +381,7 @@ export class PatchRepresentation {
381
381
  *
382
382
  * @param {MicronGeometryPatch} result
383
383
  * @param {THREE.BufferGeometry} source_geometry
384
- * @param {MicronVertexDataSpec} vertex_data_spec
384
+ * @param {VertexDataSpec} vertex_data_spec
385
385
  */
386
386
  buildMicronGeometryPatch(result, source_geometry, vertex_data_spec) {
387
387
 
@@ -214,7 +214,7 @@ export async function buildMicronGeometryFromBufferGeometry(input) {
214
214
  *
215
215
  * @param {PatchRepresentation} node
216
216
  * @param {THREE.BufferGeometry} geometry
217
- * @param {MicronVertexDataSpec} vertex_spec
217
+ * @param {VertexDataSpec} vertex_spec
218
218
  * @returns {MicronGeometryPatch}
219
219
  */
220
220
  function compilePatchGraph(node, geometry, vertex_spec) {
@@ -134,7 +134,7 @@ function compute_attribute_data_converter(source, spec) {
134
134
  * @param {MicronGeometryPatch} result
135
135
  * @param {THREE.BufferGeometry} buffer_geometry
136
136
  * @param {TopoMesh} topo
137
- * @param {MicronVertexDataSpec} vertex_data_spec
137
+ * @param {VertexDataSpec} vertex_data_spec
138
138
  */
139
139
  export function fill_patch_geometry_data(result, buffer_geometry, topo, vertex_data_spec) {
140
140
  /**
@@ -6,7 +6,7 @@ import { DataType2TypedArrayConstructorMapping } from "../../../../../core/colle
6
6
  *
7
7
  * @param {BinaryBuffer} buffer
8
8
  * @param {MicronGeometryPatch} patch
9
- * @param {MicronVertexDataSpec} vertex_spec
9
+ * @param {VertexDataSpec} vertex_spec
10
10
  * @param {MicronGeometryPatch[]} patch_array
11
11
  */
12
12
  export function deserialize_patch(buffer, patch, vertex_spec, patch_array) {
@@ -4,7 +4,7 @@ import { DataTypeByteSizes } from "../../../../../core/collection/table/DataType
4
4
  *
5
5
  * @param {BinaryBuffer} buffer
6
6
  * @param {MicronGeometryPatch} patch
7
- * @param {MicronVertexDataSpec} vertex_spec
7
+ * @param {VertexDataSpec} vertex_spec
8
8
  * @param {MicronGeometryPatch[]} patch_array
9
9
  */
10
10
  export function serialize_patch(buffer, patch, vertex_spec, patch_array) {
@@ -456,7 +456,7 @@ function init() {
456
456
 
457
457
  // sample_gltf_sponza();
458
458
  // sample_gltf_rts_factory();
459
- sample_lucy();
459
+ // sample_lucy();
460
460
  // sample_gltf_hapro_2();
461
461
  // sample_gltf_hapro_1();
462
462
  // sample_gltf_broken_isiflow();
@@ -465,6 +465,9 @@ function init() {
465
465
  // gltf_sample('data/models/moicon/08-clickable-assets/model.gltf');
466
466
  // gltf_sample('data/models/moicon/05-ground-floor/model.gltf');
467
467
  // gltf_sample('data/models/moicon/isiflow_Oct_15_21/0/model.gltf');
468
+ // gltf_sample('moicon/29_Dec_2021_Nammo/1/model.gltf');
469
+ // gltf_sample('moicon/29_Dec_2021_Nammo/1-onematerial/model.gltf');
470
+ gltf_sample('moicon/29_Dec_2021_Nammo/2/model.gltf');
468
471
 
469
472
  document.addEventListener("mousemove", onDocumentMouseMove);
470
473
 
@@ -26,7 +26,7 @@ const MAX_TEXTURE_SIZE = 16384;
26
26
  export class PatchDataTextures {
27
27
  /**
28
28
  *
29
- * @param {MicronVertexDataSpec} spec
29
+ * @param {VertexDataSpec} spec
30
30
  * @param {number} [column_count]
31
31
  */
32
32
  constructor(spec, column_count = 2) {
@@ -35,7 +35,7 @@ export class PatchDataTextures {
35
35
 
36
36
  /**
37
37
  *
38
- * @type {MicronVertexDataSpec}
38
+ * @type {VertexDataSpec}
39
39
  * @private
40
40
  */
41
41
  this.__spec = spec;
@@ -77,7 +77,7 @@ export class PatchDataTextures {
77
77
 
78
78
  /**
79
79
  *
80
- * @returns {MicronVertexDataSpec}
80
+ * @returns {VertexDataSpec}
81
81
  */
82
82
  get spec() {
83
83
  return this.__spec;
@@ -14,7 +14,7 @@ import { shader_rewrite_standard } from "./shader/shader_rewrite_standard.js";
14
14
  export class ThreeInstancedAdapter {
15
15
  /**
16
16
  *
17
- * @param {MicronVertexDataSpec} spec
17
+ * @param {VertexDataSpec} spec
18
18
  */
19
19
  constructor(spec) {
20
20
  /**
@@ -9,7 +9,7 @@ const DEBUG_PATCHES = false;
9
9
  *
10
10
  * @param {{vertexShader,fragmentShader,uniforms:Object<IUniform>}} shader
11
11
  * @param {Object<IUniform>} uniforms
12
- * @param {MicronVertexDataSpec} spec
12
+ * @param {VertexDataSpec} spec
13
13
  * @param {number} column_count
14
14
  */
15
15
  export function shader_rewrite_standard(shader, uniforms, spec, column_count) {
@@ -3,7 +3,7 @@ import { Group, Mesh } from "three";
3
3
 
4
4
  /**
5
5
  *
6
- * @param {MicronVertexDataSpec} spec
6
+ * @param {VertexDataSpec} spec
7
7
  * @param {VirtualGeometry} virtual_geometry
8
8
  * @param {THREE.Material[]} materials
9
9
  * @returns {Mesh}
@@ -73,29 +73,6 @@ export class MaterialContext {
73
73
  return this.instances.has(occurrence.instance_id);
74
74
  }
75
75
 
76
- /**
77
- * Generate a new custom cache key for three.js internal shader compilation
78
- * @param {Material} material
79
- * @returns {function()}
80
- * @private
81
- */
82
- __make_custom_cache_key(material) {
83
- let existingKeyMaker = material.customProgramCacheKey;
84
-
85
- return () => {
86
- let v = '';
87
- const attributes = this.__vertex_spec.attributes;
88
- const attribute_count = attributes.length;
89
-
90
- for (let i = 0; i < attribute_count; i++) {
91
- const a = attributes[i];
92
- v += `${a.name}:${a.type}:${a.itemSize}:${a.normalized ? 1 : 0}`;
93
- }
94
-
95
- return existingKeyMaker.call(material) + v;
96
- }
97
- }
98
-
99
76
  init(gl) {
100
77
  this.adapter.__gl_context = gl;
101
78
 
@@ -105,7 +82,6 @@ export class MaterialContext {
105
82
 
106
83
  if (material[MATERIAL_FLAG] === undefined) {
107
84
  material.onBeforeCompile = composeCompile(this.material.onBeforeCompile, rewrite_material);
108
- material.customProgramCacheKey = this.__make_custom_cache_key(this.material);
109
85
 
110
86
  material[MATERIAL_FLAG] = true;
111
87
  material[MATERIAL_VERTEX_DISPLACED] = true;
@@ -2,7 +2,7 @@ export class MaterialVertexSpec {
2
2
  constructor() {
3
3
  /**
4
4
  *
5
- * @type {MicronVertexDataSpec|null}
5
+ * @type {VertexDataSpec|null}
6
6
  */
7
7
  this.spec = null;
8
8
  /**
@@ -34,7 +34,7 @@ export class MaterialVertexSpec {
34
34
  }
35
35
 
36
36
  /**
37
- * @param {MicronVertexDataSpec} spec
37
+ * @param {VertexDataSpec} spec
38
38
  * @param {Material} material
39
39
  */
40
40
  static from(spec, material) {
@@ -19,7 +19,7 @@ export class ThreeVirtualGeometryAdapter {
19
19
 
20
20
  /**
21
21
  *
22
- * @type {MicronVertexDataSpec}
22
+ * @type {VertexDataSpec}
23
23
  * @private
24
24
  */
25
25
  this.__vertex_spec = null;
@@ -68,7 +68,7 @@ export class VGThreeRenderer {
68
68
 
69
69
  /**
70
70
  *
71
- * @param {MicronVertexDataSpec} spec
71
+ * @param {VertexDataSpec} spec
72
72
  * @param {Material} m
73
73
  * @returns {MaterialContext}
74
74
  * @private
@@ -122,6 +122,7 @@ export class VGThreeRenderer {
122
122
  // clear contexts
123
123
  const contexts = this.__contexts_array;
124
124
  const context_count = contexts.length;
125
+
125
126
  for (let i = 0; i < context_count; i++) {
126
127
  const ctx = contexts[i];
127
128
 
@@ -142,8 +143,11 @@ export class VGThreeRenderer {
142
143
  }
143
144
  };
144
145
 
145
- for (let i = 0; i < this.__inputs.length; i++) {
146
- const input_object = this.__inputs[i];
146
+ const inputs = this.__inputs;
147
+ const input_count = inputs.length;
148
+
149
+ for (let i = 0; i < input_count; i++) {
150
+ const input_object = inputs[i];
147
151
 
148
152
  input_object.traverse(processObject);
149
153
  }
@@ -42,7 +42,7 @@ export const ParticleBillboardShader = {
42
42
 
43
43
  #ifdef DEPTH_SOFT_ENABLED
44
44
 
45
- vFadeDistance = 1.0 / radius;
45
+ vFadeDistance = 1.0 / radius;
46
46
 
47
47
  #endif
48
48
 
@@ -17,9 +17,9 @@ const CHUNK_LAMBERT_LIGHTING = `
17
17
  vec3 diffuse = vec3( 1.0 );
18
18
 
19
19
  GeometricContext geometry;
20
- geometry.position = mvPosition.xyz;
20
+ geometry.position = -vViewPosition;
21
21
  geometry.normal = normalize( transformedNormal );
22
- geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
22
+ geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -vViewPosition.xyz );
23
23
 
24
24
  GeometricContext backGeometry;
25
25
  backGeometry.position = geometry.position;
@@ -156,28 +156,11 @@ function make_vertex_shader() {
156
156
  varying vec2 vRotationMultiplier;
157
157
  varying float vBlending;
158
158
 
159
-
160
159
  #if defined(LIGHTS_ENABLED)
161
- #include <common>
162
- #include <bsdfs>
163
- #include <lights_pars_begin>
164
-
165
- struct LambertMaterial {
166
- vec3 diffuseColor;
167
- };
168
-
169
- void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
170
- vec3 irradiance = directLight.color;
171
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
172
- }
173
-
174
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
175
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
176
- }
177
-
178
- #define RE_Direct RE_Direct_Lambert
179
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert
160
+ varying vec3 vViewPosition;
180
161
  #endif
162
+
163
+
181
164
 
182
165
  void main() {
183
166
 
@@ -194,10 +177,11 @@ function make_vertex_shader() {
194
177
 
195
178
  #if defined(LIGHTS_ENABLED)
196
179
  vec4 mvPosition = modelViewMatrix * position4;
197
- vec3 vViewPosition = -mvPosition.xyz;
180
+ vViewPosition = -mvPosition.xyz;
198
181
 
199
182
  vec3 transformedNormal = vec3(0.0,0.0,1.0);
200
- #else
183
+
184
+ #include <worldpos_vertex>
201
185
  #endif
202
186
 
203
187
  gl_Position = modelViewProjectionMatrix * position4;
@@ -222,7 +206,6 @@ function make_vertex_shader() {
222
206
 
223
207
  }
224
208
  #endif
225
- //
226
209
 
227
210
  vRotationMultiplier = vec2( cos(rotationGlobal),sin(rotationGlobal) );
228
211
 
@@ -238,30 +221,6 @@ function make_vertex_shader() {
238
221
 
239
222
  gl_PointSize = projected_radius;
240
223
 
241
- #if defined(LIGHTS_ENABLED)
242
- vec3 vLightFront;
243
- vec3 vIndirectFront;
244
-
245
- #include <worldpos_vertex>
246
- ${CHUNK_LAMBERT_LIGHTING}
247
-
248
- LambertMaterial material = LambertMaterial(vColor.rgb);
249
-
250
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
251
- vec3 totalEmissiveRadiance = vec3(0.0);
252
-
253
- reflectedLight.indirectDiffuse += vIndirectFront;
254
- reflectedLight.indirectDiffuse *= BRDF_Lambert( vColor.rgb );
255
-
256
- reflectedLight.directDiffuse = vLightFront;
257
- reflectedLight.directDiffuse *= BRDF_Lambert( vColor.rgb ); // shadowmask goes here
258
-
259
- //@injection_point FORWARD_PLUS:accumulation
260
-
261
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
262
-
263
- vColor.rgb = outgoingLight;
264
- #endif
265
224
 
266
225
  }`;
267
226
  }
@@ -276,6 +235,10 @@ function make_fragment_shader() {
276
235
  uniform float cameraFar;
277
236
  uniform mat4 modelViewMatrix;
278
237
  uniform mat4 projectionMatrix;
238
+
239
+ uniform mat4 uProjectionInverse;
240
+ uniform mat4 uViewInverse;
241
+
279
242
  uniform vec2 resolution;
280
243
 
281
244
  varying float vFadeDistance;
@@ -285,7 +248,6 @@ function make_fragment_shader() {
285
248
  varying vec2 vRotationMultiplier;
286
249
  varying float vBlending;
287
250
 
288
-
289
251
  out highp vec4 pc_fragColor;
290
252
 
291
253
  float depthToLinear( float z ) {
@@ -334,6 +296,58 @@ function make_fragment_shader() {
334
296
  return zFade;
335
297
  }
336
298
 
299
+
300
+ #if defined(LIGHTS_ENABLED)
301
+
302
+ vec3 computeWorldPositionFromFragmentPosition(vec3 coord){
303
+ vec4 ndc = vec4(
304
+ (coord.x - 0.5) * 2.0,
305
+ (coord.y - 0.5) * 2.0,
306
+ (coord.z - 0.5) * 2.0,
307
+ 1.0);
308
+
309
+ vec4 clip = uProjectionInverse * ndc;
310
+ return (uViewInverse* (clip / clip.w) ).xyz;
311
+ }
312
+
313
+ vec3 construct_spherical_normal_from_point_coord(vec2 coord){
314
+ float x = coord.x * 2.0 - 1.0;
315
+ float y = coord.y * 2.0 - 1.0; // note we flip Y
316
+
317
+ float z = sqrt(1.0 - clamp(x*x + y*y, 0.0, 1.0));
318
+
319
+
320
+ vec3 position = vec3(x, -y, z);
321
+
322
+ vec3 normal = normalize(position);
323
+
324
+ return normal;
325
+ }
326
+
327
+ #include <common>
328
+ #include <bsdfs>
329
+ #include <lights_pars_begin>
330
+
331
+ struct LambertMaterial {
332
+ vec3 diffuseColor;
333
+ };
334
+
335
+ void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
336
+ float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
337
+ vec3 irradiance = dotNL * directLight.color;
338
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
339
+ }
340
+
341
+ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
342
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
343
+ }
344
+
345
+ #define RE_Direct RE_Direct_Lambert
346
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert
347
+
348
+ varying vec3 vViewPosition;
349
+ #endif
350
+
337
351
  void main() {
338
352
  float fragmentDepth = gl_FragCoord.z;
339
353
 
@@ -365,6 +379,37 @@ function make_fragment_shader() {
365
379
 
366
380
  vec4 texel = spriteColor * vColor;
367
381
 
382
+ #if defined(LIGHTS_ENABLED)
383
+ // compute world position
384
+ vec3 v_world_position = computeWorldPositionFromFragmentPosition(gl_FragCoord.xyz);
385
+
386
+
387
+ vec3 vLightFront;
388
+ vec3 vIndirectFront;
389
+
390
+ vec3 transformedNormal = construct_spherical_normal_from_point_coord(gl_PointCoord.xy);
391
+
392
+ ${CHUNK_LAMBERT_LIGHTING}
393
+
394
+ LambertMaterial material = LambertMaterial(texel.rgb);
395
+
396
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
397
+ vec3 totalEmissiveRadiance = vec3(0.0);
398
+
399
+ reflectedLight.indirectDiffuse += vIndirectFront;
400
+ reflectedLight.indirectDiffuse *= BRDF_Lambert( texel.rgb );
401
+
402
+ reflectedLight.directDiffuse = vLightFront;
403
+ reflectedLight.directDiffuse *= BRDF_Lambert( texel.rgb ); // shadowmask goes here
404
+
405
+ //@injection_point FORWARD_PLUS:accumulation
406
+
407
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
408
+
409
+ texel.rgb = outgoingLight;
410
+ #endif
411
+
412
+
368
413
  // premultiply alpha
369
414
  texel.xyz *= texel.a;
370
415
 
@@ -379,9 +424,8 @@ function make_fragment_shader() {
379
424
  texel *= zFade;
380
425
 
381
426
  #endif
382
-
383
- pc_fragColor = texel;
384
427
 
428
+ pc_fragColor = texel;
385
429
  }`;
386
430
  }
387
431
 
@@ -426,7 +470,9 @@ export function make_particle_billboard_shader({ lights = false } = {}) {
426
470
  resolution: {
427
471
  type: 'v2',
428
472
  value: new ThreeVector2()
429
- }
473
+ },
474
+ uViewInverse: { type: 'm4', value: new Matrix4() },
475
+ uProjectionInverse: { type: 'm4', value: new Matrix4() },
430
476
  };
431
477
 
432
478
  if (lights) {
@@ -439,8 +485,7 @@ export function make_particle_billboard_shader({ lights = false } = {}) {
439
485
  DEPTH_READ_ENABLED: true,
440
486
  DEPTH_SOFT_ENABLED: true,
441
487
  ALIGN_DIRECTION_ENABLED: false,
442
- LIGHTS_ENABLED: lights,
443
- LIGHTING_VERTEX_ONLY: true
488
+ LIGHTS_ENABLED: lights
444
489
  },
445
490
  uniforms: uniforms,
446
491
  vertexShader: make_vertex_shader(),
@@ -189,7 +189,9 @@ export class ShaderManager {
189
189
  },
190
190
  cameraFar: {
191
191
  value: 0
192
- }
192
+ },
193
+ uViewInverse: { type: 'm4', value: new Matrix4() },
194
+ uProjectionInverse: { type: 'm4', value: new Matrix4() },
193
195
  };
194
196
 
195
197
  // debugAtlas(this.spriteAtlas.atlas, { scale: new Vector2(1, 1) });
@@ -396,6 +398,9 @@ export class ShaderManager {
396
398
  uniforms.modelViewMatrix.value = modelViewMatrix;
397
399
  uniforms.cameraNear.value = cameraNear;
398
400
  uniforms.cameraFar.value = cameraFar;
401
+
402
+ uniforms.uProjectionInverse.value.copy(camera.projectionMatrixInverse);
403
+ uniforms.uViewInverse.value.copy(camera.matrixWorld);
399
404
  }
400
405
 
401
406
  /**
@@ -123,6 +123,7 @@ export class ParticleVolume {
123
123
  "softDepth": true,
124
124
  "depthSort": false,
125
125
  "velocityAlign": false,
126
+ "receiveLight": true,
126
127
  "blendingMode": 0,
127
128
  "layers": [
128
129
  {
@@ -13,5 +13,5 @@ export function compute_light_data_hash_0(nodes, count) {
13
13
  hash = hash * 31 + datum;
14
14
  }
15
15
 
16
- return hash & 0x7fffffff;
16
+ return hash >>> 0;
17
17
  }
@@ -15,10 +15,8 @@ const accumulation_pars = `
15
15
  const preamble = `
16
16
  ${FP_SHADER_CHUNK_PREAMBLE}
17
17
 
18
- varying vec3 v_world_position;
19
18
 
20
- out highp vec4 pc_fragColor;
21
- #define gl_FragColor pc_fragColor
19
+
22
20
  `;
23
21
 
24
22
  /**
@@ -27,7 +25,22 @@ const preamble = `
27
25
  * @returns {string}
28
26
  */
29
27
  export function fp_build_fragment_shader(base) {
30
- let result = preamble + base;
28
+ let result = preamble;
29
+
30
+ if (base.indexOf('v_world_position') === -1) {
31
+ result = result + `
32
+ varying vec3 v_world_position;
33
+ `;
34
+ }
35
+
36
+ if (base.indexOf('#define gl_FragColor') === -1 && base.indexOf('pc_fragColor') === -1) {
37
+ result = result + `
38
+ out highp vec4 pc_fragColor;
39
+ #define gl_FragColor pc_fragColor
40
+ `;
41
+ }
42
+
43
+ result = result + base
31
44
 
32
45
  result = insert_after(result, '#include <lights_pars_begin>', FP_SHADER_CHUNK_DECODE_PARS);
33
46
 
@@ -40,7 +40,7 @@ export class ForwardPlusRenderingPlugin extends EnginePlugin {
40
40
  async startup() {
41
41
  const lm = this.__light_manager;
42
42
 
43
- lm.setTileMapResolution(16, 8, 10);
43
+ lm.setTileMapResolution(16, 8, 8);
44
44
 
45
45
  const graphics = this.engine.graphics;
46
46
 
@@ -9,6 +9,12 @@ const frustum = new Frustum();
9
9
  */
10
10
  const objectFilters = [];
11
11
 
12
+ /**
13
+ *
14
+ * @type {function[]}
15
+ */
16
+ const objectFilterExecutors = [];
17
+
12
18
  export const SOURCE_RENDER_LAYER_PROPERTY = '@meep-render-layer';
13
19
 
14
20
  export class VisibilityComputer {
@@ -135,12 +141,6 @@ export class VisibilityComputer {
135
141
  // clear visible set
136
142
  // this.__output.initializeUpdate();
137
143
 
138
- /**
139
- *
140
- * @type {function[]}
141
- */
142
- const objectFilterExecutors = [];
143
-
144
144
  const filters = this.filters;
145
145
  const filterCount = filters.length;
146
146
 
@@ -151,7 +151,7 @@ export class VisibilityComputer {
151
151
 
152
152
  if (f.enabled && f.layerPredicate(layer)) {
153
153
  objectFilters[objectFilterCount] = f;
154
- objectFilterExecutors.push(f.objectPredicateExecute);
154
+ objectFilterExecutors[objectFilterCount] = f.objectPredicateExecute;
155
155
 
156
156
  objectFilterCount++;
157
157
  }
@@ -165,6 +165,7 @@ export class VisibilityComputer {
165
165
  f.objectPredicateInitialize(this.__view.camera);
166
166
  }
167
167
 
168
+ objectFilterExecutors.length = objectFilterCount;
168
169
 
169
170
  layer.buildVisibleSet(this.__frustums, objectFilterExecutors, this.__includeObject, this);
170
171
 
@@ -366,27 +366,27 @@ function fragment() {
366
366
  gl_FragColor = vec4( outgoingLight, diffuseColor.a );
367
367
 
368
368
  #if defined( TONE_MAPPING )
369
- gl_FragColor.rgb = toneMapping( pc_fragColor.rgb );
369
+ gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
370
370
  #endif
371
371
 
372
372
  //encode fragment
373
- pc_fragColor = linearToOutputTexel( pc_fragColor );
373
+ gl_FragColor = linearToOutputTexel( gl_FragColor );
374
374
  #ifdef USE_FOG
375
375
  #ifdef FOG_EXP2
376
376
  float fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );
377
377
  #else
378
378
  float fogFactor = smoothstep( fogNear, fogFar, fogDepth );
379
379
  #endif
380
- gl_FragColor.rgb = mix( pc_fragColor.rgb, fogColor, fogFactor );
380
+ gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
381
381
  #endif
382
382
 
383
383
  #ifdef PREMULTIPLIED_ALPHA
384
384
  // Get get normal blending with premultipled, use with CustomBlending, OneFactor, OneMinusSrcAlphaFactor, AddEquation.
385
- gl_FragColor.rgb *= pc_fragColor.a;
385
+ gl_FragColor.rgb *= gl_FragColor.a;
386
386
  #endif
387
387
 
388
388
  #ifdef DITHERING
389
- pc_fragColor.rgb = dithering( pc_fragColor.rgb );
389
+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );
390
390
  #endif
391
391
  }
392
392
  `;