@takram/three-geospatial-effects 0.0.1-alpha.4 → 0.0.1-alpha.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/shared.js CHANGED
@@ -1,19 +1,16 @@
1
- var _ = Object.defineProperty;
2
- var E = (o, e, t) => e in o ? _(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var a = (o, e, t) => E(o, typeof e != "symbol" ? e + "" : e, t);
4
- import { BlendFunction as f, Effect as h, EffectAttribute as p, RenderPass as y, Resolution as d, ShaderPass as g, MipmapBlurPass as z, KawaseBlurPass as F, KernelSize as M } from "postprocessing";
5
- import { Uniform as i, ShaderLib as c, HalfFloatType as m, ShaderMaterial as U, Vector2 as T, NoBlending as S, WebGLRenderTarget as x, Matrix4 as w } from "three";
6
- import { depthShader as b, packingShader as B, transformShader as P } from "@takram/three-geospatial";
7
- var A = `uniform float near;
1
+ var D = Object.defineProperty;
2
+ var y = (r, e, t) => e in r ? D(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var u = (r, e, t) => y(r, typeof e != "symbol" ? e + "" : e, t);
4
+ import { BlendFunction as f, Effect as h, EffectAttribute as p, RenderPass as M, Resolution as d, ShaderPass as g, MipmapBlurPass as P, KawaseBlurPass as A, KernelSize as z } from "postprocessing";
5
+ import { Uniform as s, ShaderLib as c, HalfFloatType as m, ShaderMaterial as U, NoBlending as T, Vector2 as S, WebGLRenderTarget as w, Matrix4 as x } from "three";
6
+ import { resolveIncludes as b } from "@takram/three-geospatial";
7
+ import { depth as B, turbo as F, packing as C, transform as O } from "@takram/three-geospatial/shaders";
8
+ const N = `#include "core/depth"
9
+ #include "core/turbo"
10
+
11
+ uniform float near;
8
12
  uniform float far;
9
13
 
10
- vec3 turbo(const float x) {
11
- float r = 0.1357 + x * (4.5974 - x * (42.3277 - x * (130.5887 - x * (150.5666 - x * 58.1375))));
12
- float g = 0.0914 + x * (2.1856 + x * (4.8052 - x * (14.0195 - x * (4.2109 + x * 2.7747))));
13
- float b = 0.1067 + x * (12.5925 - x * (60.1097 - x * (109.0745 - x * (88.5066 - x * 26.8183))));
14
- return vec3(r, g, b);
15
- }
16
-
17
14
  void mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {
18
15
  float depth = readDepth(uv);
19
16
  depth = reverseLogDepth(depth, cameraNear, cameraFar);
@@ -21,40 +18,40 @@ void mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {
21
18
 
22
19
  #ifdef USE_TURBO
23
20
  vec3 color = turbo(1.0 - depth);
24
- #else
21
+ #else // USE_TURBO
25
22
  vec3 color = vec3(depth);
26
- #endif
23
+ #endif // USE_TURBO
27
24
 
28
25
  outputColor = vec4(color, inputColor.a);
29
- }`;
30
- const L = {
26
+ }
27
+ `, L = {
31
28
  blendFunction: f.SRC,
32
29
  useTurbo: !1,
33
30
  near: 1,
34
31
  far: 1e3
35
32
  };
36
- class re extends h {
33
+ class se extends h {
37
34
  constructor(e) {
38
- const { blendFunction: t, useTurbo: r, near: n, far: s } = {
35
+ const { blendFunction: t, useTurbo: n, near: o, far: i } = {
39
36
  ...L,
40
37
  ...e
41
38
  };
42
39
  super(
43
40
  "DepthEffect",
44
- /* glsl */
45
- `
46
- ${b}
47
- ${A}
48
- `,
41
+ b(N, {
42
+ core: { depth: B, turbo: F }
43
+ }),
49
44
  {
50
45
  blendFunction: t,
51
46
  attributes: p.DEPTH,
52
- uniforms: /* @__PURE__ */ new Map([
53
- ["near", new i(n)],
54
- ["far", new i(s)]
55
- ])
47
+ uniforms: new Map(
48
+ Object.entries({
49
+ near: new s(o),
50
+ far: new s(i)
51
+ })
52
+ )
56
53
  }
57
- ), this.useTurbo = r;
54
+ ), this.useTurbo = n;
58
55
  }
59
56
  get useTurbo() {
60
57
  return this.defines.has("USE_TURBO");
@@ -75,30 +72,30 @@ class re extends h {
75
72
  this.uniforms.get("far").value = e;
76
73
  }
77
74
  }
78
- var N = `#define DITHERING
75
+ const G = `#define DITHERING
79
76
 
80
77
  #include <dithering_pars_fragment>
81
78
 
82
79
  void mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {
83
- outputColor = vec4(dithering(inputColor.rgb), inputColor.a);
84
- }`;
85
- const O = {
80
+ outputColor = vec4(saturate(dithering(inputColor.rgb)), inputColor.a);
81
+ }
82
+ `, j = {
86
83
  blendFunction: f.NORMAL
87
84
  };
88
- class oe extends h {
85
+ class ae extends h {
89
86
  constructor(e) {
90
87
  const { blendFunction: t } = {
91
- ...O,
88
+ ...j,
92
89
  ...e
93
90
  };
94
- super("DitheringEffect", N, {
91
+ super("DitheringEffect", G, {
95
92
  blendFunction: t
96
93
  });
97
94
  }
98
95
  }
99
96
  const R = Symbol("SETUP");
100
- function G(o) {
101
- const e = o.vertexShader.replace(
97
+ function H(r) {
98
+ const e = r.vertexShader.replace(
102
99
  /* glsl */
103
100
  "#include <fog_pars_vertex>",
104
101
  /* glsl */
@@ -128,13 +125,13 @@ function G(o) {
128
125
  vViewPosition = - mvPosition.xyz;
129
126
  `
130
127
  );
131
- o.vertexShader = /* glsl */
128
+ r.vertexShader = /* glsl */
132
129
  `
133
130
  #undef FLAT_SHADED
134
131
  varying vec3 vViewPosition;
135
132
  ${e}
136
133
  `;
137
- const t = o.fragmentShader.replace(
134
+ const t = r.fragmentShader.replace(
138
135
  /#ifndef FLAT_SHADED\s+varying vec3 vNormal;\s+#endif/m,
139
136
  /* glsl */
140
137
  "#include <normal_pars_fragment>"
@@ -156,17 +153,17 @@ function G(o) {
156
153
  #include <normal_fragment_maps>
157
154
  `
158
155
  );
159
- return o.fragmentShader = /* glsl */
156
+ return r.fragmentShader = /* glsl */
160
157
  `
161
158
  #undef FLAT_SHADED
162
159
  varying vec3 vViewPosition;
163
160
  ${t}
164
- `, o;
161
+ `, r;
165
162
  }
166
- function v(o, { type: e } = {}) {
167
- if (o[R] === !0)
168
- return o;
169
- e === "basic" && G(o);
163
+ function v(r, { type: e } = {}) {
164
+ if (r[R] === !0)
165
+ return r;
166
+ e === "basic" && H(r);
170
167
  const t = e === "physical" ? (
171
168
  /* glsl */
172
169
  `
@@ -186,16 +183,16 @@ function v(o, { type: e } = {}) {
186
183
  );
187
184
  `
188
185
  );
189
- return o.fragmentShader = /* glsl */
186
+ return r.fragmentShader = /* glsl */
190
187
  `
191
188
  layout(location = 1) out vec4 outputBuffer1;
192
189
 
193
- #ifndef USE_ENVMAP
190
+ #if !defined(USE_ENVMAP)
194
191
  uniform float reflectivity;
195
- #endif
192
+ #endif // !defined(USE_ENVMAP)
196
193
 
197
- ${B}
198
- ${o.fragmentShader.replace(
194
+ ${C}
195
+ ${r.fragmentShader.replace(
199
196
  /}\s*$/m,
200
197
  // Assume the last curly brace is of main()
201
198
  /* glsl */
@@ -204,25 +201,25 @@ function v(o, { type: e } = {}) {
204
201
  }
205
202
  `
206
203
  )}
207
- `, o[R] = !0, o;
204
+ `, r[R] = !0, r;
208
205
  }
209
- function H() {
206
+ function I() {
210
207
  v(c.lambert), v(c.phong), v(c.basic, { type: "basic" }), v(c.standard, { type: "physical" }), v(c.physical, { type: "physical" });
211
208
  }
212
- class ie extends y {
213
- constructor(t, r, n, s) {
214
- super(r, n, s);
215
- a(this, "geometryTexture");
216
- this.geometryTexture = t.texture.clone(), this.geometryTexture.isRenderTargetTexture = !0, this.geometryTexture.type = m, H();
209
+ class ue extends M {
210
+ constructor(t, n, o, i) {
211
+ super(n, o, i);
212
+ u(this, "geometryTexture");
213
+ this.geometryTexture = t.texture.clone(), this.geometryTexture.isRenderTargetTexture = !0, this.geometryTexture.type = m, I();
217
214
  }
218
- render(t, r, n, s, u) {
219
- r != null && (r.textures[1] = this.geometryTexture), super.render(t, r, null), r != null && (r.textures.length = 1);
215
+ render(t, n, o, i, a) {
216
+ n != null && (n.textures[1] = this.geometryTexture), super.render(t, n, null), n != null && (n.textures.length = 1);
220
217
  }
221
- setSize(t, r) {
222
- this.geometryTexture.image.width = t, this.geometryTexture.image.height = r;
218
+ setSize(t, n) {
219
+ this.geometryTexture.image.width = t, this.geometryTexture.image.height = n;
223
220
  }
224
221
  }
225
- var j = `#include <common>
222
+ const V = `#include <common>
226
223
 
227
224
  uniform sampler2D inputBuffer;
228
225
 
@@ -247,8 +244,9 @@ float clampToBorder(const vec2 uv) {
247
244
  return float(uv.x >= 0.0 && uv.x <= 1.0 && uv.y >= 0.0 && uv.y <= 1.0);
248
245
  }
249
246
 
247
+ // Reference: https://learnopengl.com/Guest-Articles/2022/Phys.-Based-Bloom
250
248
  void main() {
251
- vec3 color = 0.125 * texture2D(inputBuffer, vec2(vRowUv5)).rgb;
249
+ vec3 color = 0.125 * texture(inputBuffer, vec2(vRowUv5)).rgb;
252
250
  vec4 weight =
253
251
  0.03125 *
254
252
  vec4(
@@ -257,10 +255,10 @@ void main() {
257
255
  clampToBorder(vRowUv7),
258
256
  clampToBorder(vRowUv9)
259
257
  );
260
- color += weight.x * texture2D(inputBuffer, vec2(vRowUv1)).rgb;
261
- color += weight.y * texture2D(inputBuffer, vec2(vRowUv3)).rgb;
262
- color += weight.z * texture2D(inputBuffer, vec2(vRowUv7)).rgb;
263
- color += weight.w * texture2D(inputBuffer, vec2(vRowUv9)).rgb;
258
+ color += weight.x * texture(inputBuffer, vec2(vRowUv1)).rgb;
259
+ color += weight.y * texture(inputBuffer, vec2(vRowUv3)).rgb;
260
+ color += weight.z * texture(inputBuffer, vec2(vRowUv7)).rgb;
261
+ color += weight.w * texture(inputBuffer, vec2(vRowUv9)).rgb;
264
262
 
265
263
  weight =
266
264
  0.0625 *
@@ -270,10 +268,10 @@ void main() {
270
268
  clampToBorder(vRowUv6),
271
269
  clampToBorder(vRowUv8)
272
270
  );
273
- color += weight.x * texture2D(inputBuffer, vec2(vRowUv2)).rgb;
274
- color += weight.y * texture2D(inputBuffer, vec2(vRowUv4)).rgb;
275
- color += weight.z * texture2D(inputBuffer, vec2(vRowUv6)).rgb;
276
- color += weight.w * texture2D(inputBuffer, vec2(vRowUv8)).rgb;
271
+ color += weight.x * texture(inputBuffer, vec2(vRowUv2)).rgb;
272
+ color += weight.y * texture(inputBuffer, vec2(vRowUv4)).rgb;
273
+ color += weight.z * texture(inputBuffer, vec2(vRowUv6)).rgb;
274
+ color += weight.w * texture(inputBuffer, vec2(vRowUv8)).rgb;
277
275
 
278
276
  weight =
279
277
  0.125 *
@@ -283,24 +281,23 @@ void main() {
283
281
  clampToBorder(vRowUv6),
284
282
  clampToBorder(vRowUv8)
285
283
  );
286
- color += weight.x * texture2D(inputBuffer, vec2(vCenterUv1)).rgb;
287
- color += weight.y * texture2D(inputBuffer, vec2(vCenterUv2)).rgb;
288
- color += weight.z * texture2D(inputBuffer, vec2(vCenterUv3)).rgb;
289
- color += weight.w * texture2D(inputBuffer, vec2(vCenterUv4)).rgb;
284
+ color += weight.x * texture(inputBuffer, vec2(vCenterUv1)).rgb;
285
+ color += weight.y * texture(inputBuffer, vec2(vCenterUv2)).rgb;
286
+ color += weight.z * texture(inputBuffer, vec2(vCenterUv3)).rgb;
287
+ color += weight.w * texture(inputBuffer, vec2(vCenterUv4)).rgb;
290
288
 
291
-
292
-
289
+ // WORKAROUND: Avoid screen flashes if the input buffer contains NaN texels.
290
+ // See: https://github.com/takram-design-engineering/three-geospatial/issues/7
293
291
  if (any(isnan(color))) {
294
292
  gl_FragColor = vec4(vec3(0.0), 1.0);
295
293
  return;
296
294
  }
297
295
 
298
296
  float l = luminance(color);
299
- float scale = saturate(
300
- smoothstep(thresholdLevel, thresholdLevel + thresholdRange, l)
301
- );
297
+ float scale = saturate(smoothstep(thresholdLevel, thresholdLevel + thresholdRange, l));
302
298
  gl_FragColor = vec4(color * scale, 1.0);
303
- }`, $ = `uniform vec2 texelSize;
299
+ }
300
+ `, k = `uniform vec2 texelSize;
304
301
 
305
302
  out vec2 vCenterUv1;
306
303
  out vec2 vCenterUv2;
@@ -333,37 +330,38 @@ void main() {
333
330
  vRowUv9 = uv + texelSize * vec2(2.0, -2.0);
334
331
 
335
332
  gl_Position = vec4(position.xy, 1.0, 1.0);
336
- }`;
337
- const I = {
333
+ }
334
+ `, $ = {
338
335
  thresholdLevel: 10,
339
336
  thresholdRange: 1
340
337
  };
341
- class V extends U {
338
+ class W extends U {
342
339
  constructor(e) {
343
340
  const {
344
341
  inputBuffer: t = null,
345
- thresholdLevel: r,
346
- thresholdRange: n,
347
- ...s
342
+ thresholdLevel: n,
343
+ thresholdRange: o,
344
+ ...i
348
345
  } = {
349
- ...I,
346
+ ...$,
350
347
  ...e
351
348
  };
352
349
  super({
353
350
  name: "DownsampleThresholdMaterial",
354
- fragmentShader: j,
355
- vertexShader: $,
356
- uniforms: {
357
- inputBuffer: new i(t),
358
- texelSize: new i(new T()),
359
- thresholdLevel: new i(r),
360
- thresholdRange: new i(n)
361
- },
362
- blending: S,
351
+ fragmentShader: V,
352
+ vertexShader: k,
353
+ blending: T,
363
354
  toneMapped: !1,
364
355
  depthWrite: !1,
365
356
  depthTest: !1,
366
- ...s
357
+ ...i,
358
+ uniforms: {
359
+ inputBuffer: new s(t),
360
+ texelSize: new s(new S()),
361
+ thresholdLevel: new s(n),
362
+ thresholdRange: new s(o),
363
+ ...i.uniforms
364
+ }
367
365
  });
368
366
  }
369
367
  setSize(e, t) {
@@ -388,7 +386,7 @@ class V extends U {
388
386
  this.uniforms.thresholdRange.value = e;
389
387
  }
390
388
  }
391
- var k = `#include <common>
389
+ const K = `#include <common>
392
390
 
393
391
  #define SQRT_2 (0.7071067811865476)
394
392
 
@@ -404,9 +402,9 @@ in vec2 vAspectRatio;
404
402
 
405
403
  vec3 sampleGhost(const vec2 direction, const vec3 color, const float offset) {
406
404
  vec2 suv = clamp(1.0 - vUv + direction * offset, 0.0, 1.0);
407
- vec3 result = texture2D(inputBuffer, suv).rgb * color;
405
+ vec3 result = texture(inputBuffer, suv).rgb * color;
408
406
 
409
-
407
+ // Falloff at the perimeter.
410
408
  float d = clamp(length(0.5 - suv) / (0.5 * SQRT_2), 0.0, 1.0);
411
409
  result *= pow(1.0 - d, 3.0);
412
410
  return result;
@@ -427,6 +425,7 @@ vec4 sampleGhosts(float amount) {
427
425
  return vec4(color * amount, 1.0);
428
426
  }
429
427
 
428
+ // Reference: https://john-chapman.github.io/2017/11/05/pseudo-lens-flare.html
430
429
  float cubicRingMask(const float x, const float radius, const float thickness) {
431
430
  float v = min(abs(x - radius) / thickness, 1.0);
432
431
  return 1.0 - v * v * (3.0 - 2.0 * v);
@@ -437,12 +436,12 @@ vec3 sampleHalo(const float radius) {
437
436
  vec3 offset = vec3(texelSize.x * chromaticAberration) * vec3(-1.0, 0.0, 1.0);
438
437
  vec2 suv = fract(1.0 - vUv + direction * radius);
439
438
  vec3 result = vec3(
440
- texture2D(inputBuffer, suv + direction * offset.r).r,
441
- texture2D(inputBuffer, suv + direction * offset.g).g,
442
- texture2D(inputBuffer, suv + direction * offset.b).b
439
+ texture(inputBuffer, suv + direction * offset.r).r,
440
+ texture(inputBuffer, suv + direction * offset.g).g,
441
+ texture(inputBuffer, suv + direction * offset.b).b
443
442
  );
444
443
 
445
-
444
+ // Falloff at the center and perimeter.
446
445
  vec2 wuv = (vUv - vec2(0.5, 0.0)) / vAspectRatio + vec2(0.5, 0.0);
447
446
  float d = saturate(distance(wuv, vec2(0.5)));
448
447
  result *= cubicRingMask(d, 0.45, 0.25);
@@ -458,7 +457,9 @@ vec4 sampleHalos(const float amount) {
458
457
  void main() {
459
458
  gl_FragColor += sampleGhosts(ghostAmount);
460
459
  gl_FragColor += sampleHalos(haloAmount);
461
- }`, W = `uniform vec2 texelSize;
460
+ }
461
+
462
+ `, Z = `uniform vec2 texelSize;
462
463
 
463
464
  out vec2 vUv;
464
465
  out vec2 vAspectRatio;
@@ -467,43 +468,44 @@ void main() {
467
468
  vUv = position.xy * 0.5 + 0.5;
468
469
  vAspectRatio = vec2(texelSize.x / texelSize.y, 1.0);
469
470
  gl_Position = vec4(position.xy, 1.0, 1.0);
470
- }`;
471
- const K = {
471
+ }
472
+ `, Q = {
472
473
  ghostAmount: 1e-3,
473
474
  haloAmount: 1e-3,
474
475
  chromaticAberration: 10
475
476
  };
476
- class Z extends U {
477
+ class X extends U {
477
478
  constructor(e) {
478
479
  const {
479
480
  inputBuffer: t = null,
480
- ghostAmount: r,
481
- haloAmount: n,
482
- chromaticAberration: s
481
+ ghostAmount: n,
482
+ haloAmount: o,
483
+ chromaticAberration: i,
484
+ ...a
483
485
  } = {
484
- ...K,
486
+ ...Q,
485
487
  ...e
486
488
  };
487
489
  super({
488
490
  name: "LensFlareFeaturesMaterial",
489
- fragmentShader: k,
490
- vertexShader: W,
491
- uniforms: {
492
- inputBuffer: new i(t),
493
- texelSize: new i(new T()),
494
- ghostAmount: new i(r),
495
- haloAmount: new i(n),
496
- chromaticAberration: new i(s)
497
- },
498
- blending: S,
491
+ fragmentShader: K,
492
+ vertexShader: Z,
493
+ blending: T,
499
494
  toneMapped: !1,
500
495
  depthWrite: !1,
501
- depthTest: !1
496
+ depthTest: !1,
497
+ uniforms: {
498
+ inputBuffer: new s(t),
499
+ texelSize: new s(new S()),
500
+ ghostAmount: new s(n),
501
+ haloAmount: new s(o),
502
+ chromaticAberration: new s(i),
503
+ ...a.uniforms
504
+ }
502
505
  });
503
506
  }
504
507
  setSize(e, t) {
505
- const r = this.uniforms.texelSize;
506
- r.value.x = 1 / e, r.value.y = 1 / t;
508
+ this.uniforms.texelSize.value.set(1 / e, 1 / t);
507
509
  }
508
510
  get inputBuffer() {
509
511
  return this.uniforms.inputBuffer.value;
@@ -530,89 +532,90 @@ class Z extends U {
530
532
  this.uniforms.chromaticAberration.value = e;
531
533
  }
532
534
  }
533
- var Q = `uniform sampler2D bloomBuffer;
535
+ const Y = `uniform sampler2D bloomBuffer;
534
536
  uniform sampler2D featuresBuffer;
535
537
  uniform float intensity;
536
538
 
537
539
  void mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {
538
- vec3 bloom = texture2D(bloomBuffer, uv).rgb;
539
- vec3 features = texture2D(featuresBuffer, uv).rgb;
540
- outputColor = vec4(
541
- inputColor.rgb + (bloom + features) * intensity,
542
- inputColor.a
543
- );
544
- }`;
545
- const X = {
540
+ vec3 bloom = texture(bloomBuffer, uv).rgb;
541
+ vec3 features = texture(featuresBuffer, uv).rgb;
542
+ outputColor = vec4(inputColor.rgb + (bloom + features) * intensity, inputColor.a);
543
+ }
544
+ `, q = {
546
545
  blendFunction: f.NORMAL,
547
546
  resolutionScale: 0.5,
548
547
  width: d.AUTO_SIZE,
549
548
  height: d.AUTO_SIZE,
550
549
  intensity: 5e-3
551
550
  };
552
- class se extends h {
551
+ class le extends h {
553
552
  constructor(t) {
554
553
  const {
555
- blendFunction: r,
556
- resolutionScale: n,
557
- width: s,
558
- height: u,
559
- resolutionX: l = s,
560
- resolutionY: D = u,
561
- intensity: C
554
+ blendFunction: n,
555
+ resolutionScale: o,
556
+ width: i,
557
+ height: a,
558
+ resolutionX: l = i,
559
+ resolutionY: E = a,
560
+ intensity: _
562
561
  } = {
563
- ...X,
562
+ ...q,
564
563
  ...t
565
564
  };
566
- super("LensFlareEffect", Q, {
567
- blendFunction: r,
565
+ super("LensFlareEffect", Y, {
566
+ blendFunction: n,
568
567
  attributes: p.CONVOLUTION,
569
- uniforms: /* @__PURE__ */ new Map([
570
- ["bloomBuffer", new i(null)],
571
- ["featuresBuffer", new i(null)],
572
- ["intensity", new i(1)]
573
- ])
568
+ uniforms: new Map(
569
+ Object.entries({
570
+ bloomBuffer: new s(null),
571
+ featuresBuffer: new s(null),
572
+ intensity: new s(1)
573
+ })
574
+ )
574
575
  });
575
- a(this, "resolution");
576
- a(this, "renderTarget1");
577
- a(this, "renderTarget2");
578
- a(this, "thresholdMaterial");
579
- a(this, "thresholdPass");
580
- a(this, "blurPass");
581
- a(this, "preBlurPass");
582
- a(this, "featuresMaterial");
583
- a(this, "featuresPass");
584
- a(this, "onResolutionChange", () => {
576
+ u(this, "resolution");
577
+ u(this, "renderTarget1");
578
+ u(this, "renderTarget2");
579
+ u(this, "thresholdMaterial");
580
+ u(this, "thresholdPass");
581
+ u(this, "blurPass");
582
+ u(this, "preBlurPass");
583
+ u(this, "featuresMaterial");
584
+ u(this, "featuresPass");
585
+ u(this, "onResolutionChange", () => {
585
586
  this.setSize(this.resolution.baseWidth, this.resolution.baseHeight);
586
587
  });
587
- this.renderTarget1 = new x(1, 1, {
588
+ this.renderTarget1 = new w(1, 1, {
588
589
  depthBuffer: !1,
589
590
  stencilBuffer: !1,
590
591
  type: m
591
- }), this.renderTarget1.texture.name = "LensFlare.Target1", this.renderTarget2 = new x(1, 1, {
592
+ }), this.renderTarget1.texture.name = "LensFlare.Target1", this.renderTarget2 = new w(1, 1, {
592
593
  depthBuffer: !1,
593
594
  stencilBuffer: !1,
594
595
  type: m
595
- }), this.renderTarget2.texture.name = "LensFlare.Target2", this.thresholdMaterial = new V(), this.thresholdPass = new g(this.thresholdMaterial), this.blurPass = new z(), this.blurPass.levels = 8, this.preBlurPass = new F({
596
- kernelSize: M.SMALL
597
- }), this.featuresMaterial = new Z(), this.featuresPass = new g(this.featuresMaterial), this.uniforms.get("bloomBuffer").value = this.blurPass.texture, this.uniforms.get("featuresBuffer").value = this.renderTarget1.texture, this.resolution = new d(
596
+ }), this.renderTarget2.texture.name = "LensFlare.Target2", this.thresholdMaterial = new W(), this.thresholdPass = new g(this.thresholdMaterial), this.blurPass = new P(), this.blurPass.levels = 8, this.preBlurPass = new A({
597
+ kernelSize: z.SMALL
598
+ }), this.featuresMaterial = new X(), this.featuresPass = new g(this.featuresMaterial), this.uniforms.get("bloomBuffer").value = this.blurPass.texture, this.uniforms.get("featuresBuffer").value = this.renderTarget1.texture, this.resolution = new d(
598
599
  this,
599
600
  l,
600
- D,
601
- n
601
+ E,
602
+ o
602
603
  ), this.resolution.addEventListener(
603
604
  "change",
604
605
  this.onResolutionChange
605
- ), this.intensity = C;
606
+ ), this.intensity = _;
606
607
  }
607
- initialize(t, r, n) {
608
- this.thresholdPass.initialize(t, r, n), this.blurPass.initialize(t, r, n), this.preBlurPass.initialize(t, r, n), this.featuresPass.initialize(t, r, n);
608
+ initialize(t, n, o) {
609
+ this.thresholdPass.initialize(t, n, o), this.blurPass.initialize(t, n, o), this.preBlurPass.initialize(t, n, o), this.featuresPass.initialize(t, n, o);
609
610
  }
610
- update(t, r, n) {
611
- this.thresholdPass.render(t, r, this.renderTarget1), this.blurPass.render(t, this.renderTarget1, null), this.preBlurPass.render(t, this.renderTarget1, this.renderTarget2), this.featuresPass.render(t, this.renderTarget2, this.renderTarget1);
611
+ update(t, n, o) {
612
+ this.thresholdPass.render(t, n, this.renderTarget1), this.blurPass.render(t, this.renderTarget1, null), this.preBlurPass.render(t, this.renderTarget1, this.renderTarget2), this.featuresPass.render(t, this.renderTarget2, this.renderTarget1);
612
613
  }
613
- setSize(t, r) {
614
- const n = this.resolution;
615
- n.setBaseSize(t, r), this.renderTarget1.setSize(n.width, n.height), this.renderTarget2.setSize(n.width, n.height), this.thresholdMaterial.setSize(n.width, n.height), this.blurPass.setSize(n.width, n.height), this.preBlurPass.setSize(n.width, n.height), this.featuresMaterial.setSize(n.width, n.height);
614
+ setSize(t, n) {
615
+ const o = this.resolution;
616
+ o.setBaseSize(t, n);
617
+ const { width: i, height: a } = o;
618
+ this.renderTarget1.setSize(i, a), this.renderTarget2.setSize(i, a), this.thresholdMaterial.setSize(i, a), this.blurPass.setSize(i, a), this.preBlurPass.setSize(i, a), this.featuresMaterial.setSize(i, a);
616
619
  }
617
620
  get intensity() {
618
621
  return this.uniforms.get("intensity").value;
@@ -633,7 +636,11 @@ class se extends h {
633
636
  this.thresholdMaterial.thresholdRange = t;
634
637
  }
635
638
  }
636
- var Y = `uniform highp sampler2D normalBuffer;
639
+ const J = `#include "core/depth"
640
+ #include "core/packing"
641
+ #include "core/transform"
642
+
643
+ uniform highp sampler2D normalBuffer;
637
644
 
638
645
  uniform mat4 projectionMatrix;
639
646
  uniform mat4 inverseProjectionMatrix;
@@ -655,56 +662,58 @@ vec3 reconstructNormal(const vec2 uv) {
655
662
 
656
663
  vec3 readNormal(const vec2 uv) {
657
664
  #ifdef OCT_ENCODED
658
- return unpackVec2ToNormal(texture2D(normalBuffer, uv).xy);
659
- #else
660
- return 2.0 * texture2D(normalBuffer, uv).xyz - 1.0;
661
- #endif
665
+ return unpackVec2ToNormal(texture(normalBuffer, uv).xy);
666
+ #else // OCT_ENCODED
667
+ return 2.0 * texture(normalBuffer, uv).xyz - 1.0;
668
+ #endif // OCT_ENCODED
662
669
  }
663
670
 
664
671
  void mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {
665
672
  #ifdef RECONSTRUCT_FROM_DEPTH
666
673
  vec3 normal = reconstructNormal(uv);
667
- #else
674
+ #else // RECONSTRUCT_FROM_DEPTH
668
675
  vec3 normal = readNormal(uv);
669
- #endif
676
+ #endif // RECONSTRUCT_FROM_DEPTH
670
677
 
671
678
  outputColor = vec4(normal * 0.5 + 0.5, inputColor.a);
672
- }`;
673
- const q = {
679
+ }
680
+ `, ee = {
674
681
  blendFunction: f.SRC,
675
682
  octEncoded: !1,
676
683
  reconstructFromDepth: !1
677
684
  };
678
- class ae extends h {
685
+ class ce extends h {
679
686
  constructor(e, t) {
680
687
  const {
681
- blendFunction: r,
682
- normalBuffer: n = null,
683
- octEncoded: s,
684
- reconstructFromDepth: u
688
+ blendFunction: n,
689
+ normalBuffer: o = null,
690
+ octEncoded: i,
691
+ reconstructFromDepth: a
685
692
  } = {
686
- ...q,
693
+ ...ee,
687
694
  ...t
688
695
  };
689
696
  super(
690
697
  "NormalEffect",
691
- /* glsl */
692
- `
693
- ${b}
694
- ${B}
695
- ${P}
696
- ${Y}
697
- `,
698
+ b(J, {
699
+ core: {
700
+ depth: B,
701
+ packing: C,
702
+ transform: O
703
+ }
704
+ }),
698
705
  {
699
- blendFunction: r,
706
+ blendFunction: n,
700
707
  attributes: p.DEPTH,
701
- uniforms: /* @__PURE__ */ new Map([
702
- ["normalBuffer", new i(n)],
703
- ["projectionMatrix", new i(new w())],
704
- ["inverseProjectionMatrix", new i(new w())]
705
- ])
708
+ uniforms: new Map(
709
+ Object.entries({
710
+ normalBuffer: new s(o),
711
+ projectionMatrix: new s(new x()),
712
+ inverseProjectionMatrix: new s(new x())
713
+ })
714
+ )
706
715
  }
707
- ), this.camera = e, e != null && (this.mainCamera = e), this.octEncoded = s, this.reconstructFromDepth = u;
716
+ ), this.camera = e, e != null && (this.mainCamera = e), this.octEncoded = i, this.reconstructFromDepth = a;
708
717
  }
709
718
  get mainCamera() {
710
719
  return this.camera;
@@ -712,9 +721,9 @@ class ae extends h {
712
721
  set mainCamera(e) {
713
722
  this.camera = e;
714
723
  }
715
- update(e, t, r) {
716
- const n = this.uniforms, s = n.get("projectionMatrix"), u = n.get("inverseProjectionMatrix"), l = this.camera;
717
- l != null && (s.value.copy(l.projectionMatrix), u.value.copy(l.projectionMatrixInverse));
724
+ update(e, t, n) {
725
+ const o = this.uniforms, i = o.get("projectionMatrix"), a = o.get("inverseProjectionMatrix"), l = this.camera;
726
+ l != null && (i.value.copy(l.projectionMatrix), a.value.copy(l.projectionMatrixInverse));
718
727
  }
719
728
  get normalBuffer() {
720
729
  return this.uniforms.get("normalBuffer").value;
@@ -736,15 +745,15 @@ class ae extends h {
736
745
  }
737
746
  }
738
747
  export {
739
- re as D,
740
- ie as G,
741
- se as L,
742
- ae as N,
743
- O as a,
744
- oe as b,
748
+ se as D,
749
+ ue as G,
750
+ le as L,
751
+ ce as N,
752
+ j as a,
753
+ ae as b,
745
754
  L as d,
746
- X as l,
747
- q as n,
748
- H as s
755
+ q as l,
756
+ ee as n,
757
+ I as s
749
758
  };
750
759
  //# sourceMappingURL=shared.js.map