@luma.gl/effects 9.2.0-alpha.3 → 9.2.0-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.
@@ -33,8 +33,8 @@ export declare const tiltShift: {
33
33
  readonly source: "fn random(scale: vec3f, seed: float) -> f32 {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n";
34
34
  readonly fs: "float random(vec3 scale, float seed) {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n";
35
35
  }];
36
- readonly source: "uniform tiltShiftUniforms {\n blurRadius: f32,\n gradientRadius: f32,\n start: vec2f,\n end: vec2f,\n invert: u32,\n};\n\n@group(0) @binding(1) var<uniform> tiltShift: tiltShiftUniforms;\n\nfn tiltShift_getDelta(vec2 texSize) -> vec2f {\n vec2 vector = normalize((tiltShift.end - tiltShift.start) * texSize);\n return tiltShift.invert ? vec2(-vector.y, vector.x) : vector;\n}\n\nfn tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {\n vec4 color = vec4(0.0);\n float total = 0.0;\n\n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n vec2 normal = normalize(vec2((tiltShift.start.y - tiltShift.end.y) * texSize.y, (tiltShift.end.x - tiltShift.start.x) * texSize.x));\n float radius = smoothstep(0.0, 1.0,\n abs(dot(texCoord * texSize - tiltShift.start * texSize, normal)) / tiltShift.gradientRadius) * tiltShift.blurRadius;\n\n for (float t = -30.0; t <= 30.0; t++) {\n float percent = (t + offset - 0.5) / 30.0;\n float weight = 1.0 - abs(percent);\n vec4 offsetColor = texture(source, texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius);\n\n /* switch to pre-multiplied alpha to correctly blur transparent images */\n offsetColor.rgb *= offsetColor.a;\n\n color += offsetColor * weight;\n total += weight;\n }\n\n color = color / total;\n\n /* switch back from pre-multiplied alpha */\n color.rgb /= color.a + 0.00001;\n\n return color;\n}\n";
37
- readonly fs: "uniform tiltShiftUniforms {\n float blurRadius;\n float gradientRadius;\n vec2 start;\n vec2 end;\n bool invert;\n} tiltShift;\n\nvec2 tiltShift_getDelta(vec2 texSize) {\n vec2 vector = normalize((tiltShift.end - tiltShift.start) * texSize);\n return tiltShift.invert ? vec2(-vector.y, vector.x) : vector;\n}\n\nvec4 tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec4 color = vec4(0.0);\n float total = 0.0;\n\n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n vec2 normal = normalize(vec2((tiltShift.start.y - tiltShift.end.y) * texSize.y, (tiltShift.end.x - tiltShift.start.x) * texSize.x));\n float radius = smoothstep(0.0, 1.0,\n abs(dot(texCoord * texSize - tiltShift.start * texSize, normal)) / tiltShift.gradientRadius) * tiltShift.blurRadius;\n\n for (float t = -30.0; t <= 30.0; t++) {\n float percent = (t + offset - 0.5) / 30.0;\n float weight = 1.0 - abs(percent);\n vec4 offsetColor = texture(source, texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius);\n\n /* switch to pre-multiplied alpha to correctly blur transparent images */\n offsetColor.rgb *= offsetColor.a;\n\n color += offsetColor * weight;\n total += weight;\n }\n\n color = color / total;\n\n /* switch back from pre-multiplied alpha */\n color.rgb /= color.a + 0.00001;\n\n return color;\n}\n";
36
+ readonly source: "uniform tiltShiftUniforms {\n blurRadius: f32,\n gradientRadius: f32,\n start: vec2f,\n end: vec2f,\n invert: u32,\n};\n\n@group(0) @binding(1) var<uniform> tiltShift: tiltShiftUniforms;\n\nfn tiltShift_getDelta(vec2 texSize) -> vec2f {\n vec2 vector = normalize((tiltShift.end - tiltShift.start) * texSize);\n return tiltShift.invert ? vec2(-vector.y, vector.x) : vector;\n}\n\nfn tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {\n vec4 color = vec4(0.0);\n float total = 0.0;\n\n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n vec2 normal = normalize(vec2((tiltShift.start.y - tiltShift.end.y) * texSize.y, (tiltShift.end.x - tiltShift.start.x) * texSize.x));\n float radius = smoothstep(0.0, 1.0,\n abs(dot(texCoord * texSize - tiltShift.start * texSize, normal)) / tiltShift.gradientRadius) * tiltShift.blurRadius;\n\n for (float t = -30.0; t <= 30.0; t++) {\n float percent = (t + offset - 0.5) / 30.0;\n float weight = 1.0 - abs(percent);\n vec4 offsetColor = texture(source, texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius);\n\n color += offsetColor * weight;\n total += weight;\n }\n\n color = color / total;\n return color;\n}\n";
37
+ readonly fs: "uniform tiltShiftUniforms {\n float blurRadius;\n float gradientRadius;\n vec2 start;\n vec2 end;\n bool invert;\n} tiltShift;\n\nvec2 tiltShift_getDelta(vec2 texSize) {\n vec2 vector = normalize((tiltShift.end - tiltShift.start) * texSize);\n return tiltShift.invert ? vec2(-vector.y, vector.x) : vector;\n}\n\nvec4 tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec4 color = vec4(0.0);\n float total = 0.0;\n\n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n vec2 normal = normalize(vec2((tiltShift.start.y - tiltShift.end.y) * texSize.y, (tiltShift.end.x - tiltShift.start.x) * texSize.x));\n float radius = smoothstep(0.0, 1.0,\n abs(dot(texCoord * texSize - tiltShift.start * texSize, normal)) / tiltShift.gradientRadius) * tiltShift.blurRadius;\n\n for (float t = -30.0; t <= 30.0; t++) {\n float percent = (t + offset - 0.5) / 30.0;\n float weight = 1.0 - abs(percent);\n vec4 offsetColor = texture(source, texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius);\n color += offsetColor * weight;\n total += weight;\n }\n\n color = color / total;\n return color;\n}\n";
38
38
  readonly props: TiltShiftProps;
39
39
  readonly uniforms: TiltShiftUniforms;
40
40
  readonly uniformTypes: {
@@ -1 +1 @@
1
- {"version":3,"file":"tiltshift.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-blur-filters/tiltshift.ts"],"names":[],"mappings":"AAqGA;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,2DAA2D;IAC3D,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzB,0DAA0D;IAC1D,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvB,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAE/C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS;;;;;;;;;oBAMP,cAAc;uBACX,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoB4B,CAAC"}
1
+ {"version":3,"file":"tiltshift.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-blur-filters/tiltshift.ts"],"names":[],"mappings":"AAsFA;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,2DAA2D;IAC3D,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzB,0DAA0D;IAC1D,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvB,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAE/C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS;;;;;;;;;oBAMP,cAAc;uBACX,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoB4B,CAAC"}
@@ -34,18 +34,11 @@ fn tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f
34
34
  float weight = 1.0 - abs(percent);
35
35
  vec4 offsetColor = texture(source, texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius);
36
36
 
37
- /* switch to pre-multiplied alpha to correctly blur transparent images */
38
- offsetColor.rgb *= offsetColor.a;
39
-
40
37
  color += offsetColor * weight;
41
38
  total += weight;
42
39
  }
43
40
 
44
41
  color = color / total;
45
-
46
- /* switch back from pre-multiplied alpha */
47
- color.rgb /= color.a + 0.00001;
48
-
49
42
  return color;
50
43
  }
51
44
  `;
@@ -78,19 +71,11 @@ vec4 tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
78
71
  float percent = (t + offset - 0.5) / 30.0;
79
72
  float weight = 1.0 - abs(percent);
80
73
  vec4 offsetColor = texture(source, texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius);
81
-
82
- /* switch to pre-multiplied alpha to correctly blur transparent images */
83
- offsetColor.rgb *= offsetColor.a;
84
-
85
74
  color += offsetColor * weight;
86
75
  total += weight;
87
76
  }
88
77
 
89
78
  color = color / total;
90
-
91
- /* switch back from pre-multiplied alpha */
92
- color.rgb /= color.a + 0.00001;
93
-
94
79
  return color;
95
80
  }
96
81
  `;
@@ -1 +1 @@
1
- {"version":3,"file":"tiltshift.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-blur-filters/tiltshift.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AAE5C,MAAM,MAAM,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EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAC,MAAM,EAAE,CAAC,EAAC,EAAC;KACvC;CAC4D,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;EAwBE"}
@@ -19,8 +19,8 @@ export declare const zoomBlur: {
19
19
  readonly source: "fn random(scale: vec3f, seed: float) -> f32 {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n";
20
20
  readonly fs: "float random(vec3 scale, float seed) {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n";
21
21
  }];
22
- readonly source: "\nuniform zoomBlurUniforms {\n center: vec2f,\n strength: f32,\n};\n\n@group(0) @binding(1) var<uniform> zoomBlur : zoomBlurUniforms;\n\n\nfn zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {\n vec4 color = vec4(0.0);\n float total = 0.0;\n vec2 toCenter = zoomBlur.center * texSize - texCoord * texSize;\n\n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n for (float t = 0.0; t <= 40.0; t++) {\n float percent = (t + offset) / 40.0;\n float weight = 4.0 * (percent - percent * percent);\n vec4 offsetColor = texture(source, texCoord + toCenter * percent * zoomBlur.strength / texSize);\n\n /* switch to pre-multiplied alpha to correctly blur transparent images */\n offsetColor.rgb *= offsetColor.a;\n\n color += offsetColor * weight;\n total += weight;\n }\n\n color = color / total;\n\n /* switch back from pre-multiplied alpha */\n color.rgb /= color.a + 0.00001;\n\n return color;\n}\n";
23
- readonly fs: "\nuniform zoomBlurUniforms {\n vec2 center;\n float strength;\n} zoomBlur;\n\nvec4 zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec4 color = vec4(0.0);\n float total = 0.0;\n vec2 toCenter = zoomBlur.center * texSize - texCoord * texSize;\n\n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n for (float t = 0.0; t <= 40.0; t++) {\n float percent = (t + offset) / 40.0;\n float weight = 4.0 * (percent - percent * percent);\n vec4 offsetColor = texture(source, texCoord + toCenter * percent * zoomBlur.strength / texSize);\n\n /* switch to pre-multiplied alpha to correctly blur transparent images */\n offsetColor.rgb *= offsetColor.a;\n\n color += offsetColor * weight;\n total += weight;\n }\n\n color = color / total;\n\n /* switch back from pre-multiplied alpha */\n color.rgb /= color.a + 0.00001;\n\n return color;\n}\n";
22
+ readonly source: "\nuniform zoomBlurUniforms {\n center: vec2f,\n strength: f32,\n};\n\n@group(0) @binding(1) var<uniform> zoomBlur : zoomBlurUniforms;\n\n\nfn zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {\n vec4 color = vec4(0.0);\n float total = 0.0;\n vec2 toCenter = zoomBlur.center * texSize - texCoord * texSize;\n\n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n for (float t = 0.0; t <= 40.0; t++) {\n float percent = (t + offset) / 40.0;\n float weight = 4.0 * (percent - percent * percent);\n vec4 offsetColor = texture(source, texCoord + toCenter * percent * zoomBlur.strength / texSize);\n color += offsetColor * weight;\n total += weight;\n }\n\n color = color / total;\n return color;\n}\n";
23
+ readonly fs: "\nuniform zoomBlurUniforms {\n vec2 center;\n float strength;\n} zoomBlur;\n\nvec4 zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec4 color = vec4(0.0);\n float total = 0.0;\n vec2 toCenter = zoomBlur.center * texSize - texCoord * texSize;\n\n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n for (float t = 0.0; t <= 40.0; t++) {\n float percent = (t + offset) / 40.0;\n float weight = 4.0 * (percent - percent * percent);\n vec4 offsetColor = texture(source, texCoord + toCenter * percent * zoomBlur.strength / texSize);\n color += offsetColor * weight;\n total += weight;\n }\n\n color = color / total;\n return color;\n}\n";
24
24
  readonly props: ZoomBlurProps;
25
25
  readonly uniforms: ZoomBlurUniforms;
26
26
  readonly uniformTypes: {
@@ -1 +1 @@
1
- {"version":3,"file":"zoomblur.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-blur-filters/zoomblur.ts"],"names":[],"mappings":"AAgFA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,gDAAgD;IAChD,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,4JAA4J;IAC5J,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;oBAMN,aAAa;uBACV,gBAAgB;;;;;;;;;;;;;;;;;;CAW2B,CAAC"}
1
+ {"version":3,"file":"zoomblur.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-blur-filters/zoomblur.ts"],"names":[],"mappings":"AAgEA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,gDAAgD;IAChD,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,4JAA4J;IAC5J,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;oBAMN,aAAa;uBACV,gBAAgB;;;;;;;;;;;;;;;;;;CAW2B,CAAC"}
@@ -23,19 +23,11 @@ fn zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f
23
23
  float percent = (t + offset) / 40.0;
24
24
  float weight = 4.0 * (percent - percent * percent);
25
25
  vec4 offsetColor = texture(source, texCoord + toCenter * percent * zoomBlur.strength / texSize);
26
-
27
- /* switch to pre-multiplied alpha to correctly blur transparent images */
28
- offsetColor.rgb *= offsetColor.a;
29
-
30
26
  color += offsetColor * weight;
31
27
  total += weight;
32
28
  }
33
29
 
34
30
  color = color / total;
35
-
36
- /* switch back from pre-multiplied alpha */
37
- color.rgb /= color.a + 0.00001;
38
-
39
31
  return color;
40
32
  }
41
33
  `;
@@ -57,19 +49,11 @@ vec4 zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
57
49
  float percent = (t + offset) / 40.0;
58
50
  float weight = 4.0 * (percent - percent * percent);
59
51
  vec4 offsetColor = texture(source, texCoord + toCenter * percent * zoomBlur.strength / texSize);
60
-
61
- /* switch to pre-multiplied alpha to correctly blur transparent images */
62
- offsetColor.rgb *= offsetColor.a;
63
-
64
52
  color += offsetColor * weight;
65
53
  total += weight;
66
54
  }
67
55
 
68
56
  color = color / total;
69
-
70
- /* switch back from pre-multiplied alpha */
71
- color.rgb /= color.a + 0.00001;
72
-
73
57
  return color;
74
58
  }
75
59
  `;
@@ -1 +1 @@
1
- {"version":3,"file":"zoomblur.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-blur-filters/zoomblur.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AAE5C,MAAM,MAAM,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCzB,CAAC;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCrB,CAAC;AAcF;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,UAAU;IAChB,YAAY,EAAE,CAAC,MAAM,CAAC;IACtB,MAAM;IACN,EAAE;IAEF,KAAK,EAAE,EAAmB;IAC1B,QAAQ,EAAE,EAAsB;IAChC,YAAY,EAAE;QACZ,MAAM,EAAE,WAAW;QACnB,QAAQ,EAAE,KAAK;KAChB;IACD,SAAS,EAAE;QACT,MAAM,EAAE,EAAC,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAC;QAC3B,QAAQ,EAAE,EAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAC;KAC3C;IAED,MAAM,EAAE,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;CACkC,CAAC"}
1
+ {"version":3,"file":"zoomblur.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-blur-filters/zoomblur.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AAE5C,MAAM,MAAM,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BzB,CAAC;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;CAyBrB,CAAC;AAcF;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,UAAU;IAChB,YAAY,EAAE,CAAC,MAAM,CAAC;IACtB,MAAM;IACN,EAAE;IAEF,KAAK,EAAE,EAAmB;IAC1B,QAAQ,EAAE,EAAsB;IAChC,YAAY,EAAE;QACZ,MAAM,EAAE,WAAW;QACnB,QAAQ,EAAE,KAAK;KAChB;IACD,SAAS,EAAE;QACT,MAAM,EAAE,EAAC,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAC;QAC3B,QAAQ,EAAE,EAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAC;KAC3C;IAED,MAAM,EAAE,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;CACkC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/effects",
3
- "version": "9.2.0-alpha.3",
3
+ "version": "9.2.0-alpha.6",
4
4
  "description": "Post-processing effects for luma.gl",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -53,5 +53,5 @@
53
53
  "@math.gl/types": "^4.1.0",
54
54
  "wgsl_reflect": "^1.0.1"
55
55
  },
56
- "gitHead": "16fcea2620b1fd45cb744de730c2622a724cc15b"
56
+ "gitHead": "63fe3fd0912c83f7c4a012016c57048a250b591f"
57
57
  }
@@ -4,7 +4,7 @@
4
4
 
5
5
  import type {ShaderPass} from '@luma.gl/shadertools';
6
6
 
7
- const fs = /* wgsl */ `\
7
+ const source = /* wgsl */ `\
8
8
  struct vignetteUniforms {
9
9
  radius: f32,
10
10
  amount: f32
@@ -27,6 +27,19 @@ fn vignette_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) ->vec
27
27
  }
28
28
  `;
29
29
 
30
+ const fs = /* glsl */ `\
31
+ uniform vignetteUniforms {
32
+ float radius;
33
+ float amount;
34
+ } vignette;
35
+
36
+ vec4 vignette_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
37
+ float dist = distance(texCoord, vec2(0.5, 0.5));
38
+ float ratio = smoothstep(0.8, vignette.radius * 0.799, dist * (vignette.amount + vignette.radius));
39
+ return color.rgba * ratio + (1.0 - ratio)*vec4(0.0, 0.0, 0.0, 1.0);
40
+ }
41
+ `;
42
+
30
43
  /**
31
44
  * Vignette - Adds a simulated lens edge darkening effect.
32
45
  */
@@ -48,6 +61,8 @@ export const vignette = {
48
61
  uniforms: {} as VignetteUniforms,
49
62
 
50
63
  name: 'vignette',
64
+ source,
65
+ fs,
51
66
 
52
67
  uniformTypes: {
53
68
  radius: 'f32',
@@ -62,7 +77,5 @@ export const vignette = {
62
77
  amount: {value: 0.5, min: 0, max: 1}
63
78
  },
64
79
 
65
- passes: [{filter: true}],
66
-
67
- fs
80
+ passes: [{filter: true}]
68
81
  } as const satisfies ShaderPass<VignetteProps, VignetteProps>;
@@ -37,18 +37,11 @@ fn tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f
37
37
  float weight = 1.0 - abs(percent);
38
38
  vec4 offsetColor = texture(source, texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius);
39
39
 
40
- /* switch to pre-multiplied alpha to correctly blur transparent images */
41
- offsetColor.rgb *= offsetColor.a;
42
-
43
40
  color += offsetColor * weight;
44
41
  total += weight;
45
42
  }
46
43
 
47
44
  color = color / total;
48
-
49
- /* switch back from pre-multiplied alpha */
50
- color.rgb /= color.a + 0.00001;
51
-
52
45
  return color;
53
46
  }
54
47
  `;
@@ -82,19 +75,11 @@ vec4 tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
82
75
  float percent = (t + offset - 0.5) / 30.0;
83
76
  float weight = 1.0 - abs(percent);
84
77
  vec4 offsetColor = texture(source, texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius);
85
-
86
- /* switch to pre-multiplied alpha to correctly blur transparent images */
87
- offsetColor.rgb *= offsetColor.a;
88
-
89
78
  color += offsetColor * weight;
90
79
  total += weight;
91
80
  }
92
81
 
93
82
  color = color / total;
94
-
95
- /* switch back from pre-multiplied alpha */
96
- color.rgb /= color.a + 0.00001;
97
-
98
83
  return color;
99
84
  }
100
85
  `;
@@ -26,19 +26,11 @@ fn zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f
26
26
  float percent = (t + offset) / 40.0;
27
27
  float weight = 4.0 * (percent - percent * percent);
28
28
  vec4 offsetColor = texture(source, texCoord + toCenter * percent * zoomBlur.strength / texSize);
29
-
30
- /* switch to pre-multiplied alpha to correctly blur transparent images */
31
- offsetColor.rgb *= offsetColor.a;
32
-
33
29
  color += offsetColor * weight;
34
30
  total += weight;
35
31
  }
36
32
 
37
33
  color = color / total;
38
-
39
- /* switch back from pre-multiplied alpha */
40
- color.rgb /= color.a + 0.00001;
41
-
42
34
  return color;
43
35
  }
44
36
  `;
@@ -61,19 +53,11 @@ vec4 zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
61
53
  float percent = (t + offset) / 40.0;
62
54
  float weight = 4.0 * (percent - percent * percent);
63
55
  vec4 offsetColor = texture(source, texCoord + toCenter * percent * zoomBlur.strength / texSize);
64
-
65
- /* switch to pre-multiplied alpha to correctly blur transparent images */
66
- offsetColor.rgb *= offsetColor.a;
67
-
68
56
  color += offsetColor * weight;
69
57
  total += weight;
70
58
  }
71
59
 
72
60
  color = color / total;
73
-
74
- /* switch back from pre-multiplied alpha */
75
- color.rgb /= color.a + 0.00001;
76
-
77
61
  return color;
78
62
  }
79
63
  `;