@luma.gl/effects 9.2.5 → 9.3.0-alpha.10
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/dist/dist.dev.js +2692 -645
- package/dist/dist.min.js +10 -9
- package/dist/index.cjs +753 -302
- package/dist/index.cjs.map +3 -3
- package/dist/passes/postprocessing/fxaa/fxaa.d.ts +1 -0
- package/dist/passes/postprocessing/fxaa/fxaa.d.ts.map +1 -1
- package/dist/passes/postprocessing/fxaa/fxaa.js +287 -0
- package/dist/passes/postprocessing/fxaa/fxaa.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.js +6 -7
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/denoise.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/denoise.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/denoise.js +32 -24
- package/dist/passes/postprocessing/image-adjust-filters/denoise.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.js +26 -33
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/noise.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/noise.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/noise.js +10 -9
- package/dist/passes/postprocessing/image-adjust-filters/noise.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/sepia.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/sepia.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/sepia.js +12 -11
- package/dist/passes/postprocessing/image-adjust-filters/sepia.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.js +10 -10
- package/dist/passes/postprocessing/image-adjust-filters/vignette.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/vignette.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/vignette.js +11 -15
- package/dist/passes/postprocessing/image-adjust-filters/vignette.js.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts +3 -3
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.js +36 -18
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.js.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts +3 -3
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.js +27 -18
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.js.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts +3 -3
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.js +22 -13
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts +2 -2
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.js +20 -18
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/dotscreen.d.ts +2 -2
- package/dist/passes/postprocessing/image-fun-filters/dotscreen.js +12 -12
- package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts +3 -3
- package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/edgework.js +85 -14
- package/dist/passes/postprocessing/image-fun-filters/edgework.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +2 -2
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.js +35 -23
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/ink.d.ts +2 -2
- package/dist/passes/postprocessing/image-fun-filters/ink.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/ink.js +26 -17
- package/dist/passes/postprocessing/image-fun-filters/ink.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts +2 -2
- package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/magnify.js +23 -13
- package/dist/passes/postprocessing/image-fun-filters/magnify.js.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts +3 -3
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.js +28 -14
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.js.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/swirl.d.ts +3 -3
- package/dist/passes/postprocessing/image-warp-filters/swirl.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/swirl.js +21 -16
- package/dist/passes/postprocessing/image-warp-filters/swirl.js.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/warp.d.ts +1 -1
- package/dist/passes/postprocessing/image-warp-filters/warp.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/warp.js +9 -4
- package/dist/passes/postprocessing/image-warp-filters/warp.js.map +1 -1
- package/package.json +4 -5
- package/src/passes/postprocessing/fxaa/fxaa.ts +288 -0
- package/src/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts +6 -7
- package/src/passes/postprocessing/image-adjust-filters/denoise.ts +34 -26
- package/src/passes/postprocessing/image-adjust-filters/huesaturation.ts +28 -35
- package/src/passes/postprocessing/image-adjust-filters/noise.ts +10 -9
- package/src/passes/postprocessing/image-adjust-filters/sepia.ts +12 -11
- package/src/passes/postprocessing/image-adjust-filters/vibrance.ts +10 -10
- package/src/passes/postprocessing/image-adjust-filters/vignette.ts +11 -15
- package/src/passes/postprocessing/image-blur-filters/tiltshift.ts +38 -20
- package/src/passes/postprocessing/image-blur-filters/triangleblur.ts +27 -18
- package/src/passes/postprocessing/image-blur-filters/zoomblur.ts +23 -14
- package/src/passes/postprocessing/image-fun-filters/colorhalftone.ts +20 -18
- package/src/passes/postprocessing/image-fun-filters/dotscreen.ts +12 -12
- package/src/passes/postprocessing/image-fun-filters/edgework.ts +86 -15
- package/src/passes/postprocessing/image-fun-filters/hexagonalpixelate.ts +39 -27
- package/src/passes/postprocessing/image-fun-filters/ink.ts +26 -17
- package/src/passes/postprocessing/image-fun-filters/magnify.ts +23 -13
- package/src/passes/postprocessing/image-warp-filters/bulgepinch.ts +28 -14
- package/src/passes/postprocessing/image-warp-filters/swirl.ts +21 -16
- package/src/passes/postprocessing/image-warp-filters/warp.ts +9 -4
package/dist/index.cjs
CHANGED
|
@@ -51,23 +51,22 @@ var source = (
|
|
|
51
51
|
contrast: f32
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
@group(0) @binding(1) var<uniform> brightnessContrast : brightnessContrastUniforms;
|
|
54
|
+
@group(0) @binding(auto) var<uniform> brightnessContrast : brightnessContrastUniforms;
|
|
56
55
|
|
|
57
56
|
fn brightnessContrast_filterColor_ext(color: vec4f, texSize: vec2<f32>, texCoords: vec2<f32>) -> vec4f {
|
|
58
|
-
color.rgb
|
|
57
|
+
var resultRgb = color.rgb + vec3f(brightnessContrast.brightness);
|
|
59
58
|
if (brightnessContrast.contrast > 0.0) {
|
|
60
|
-
|
|
59
|
+
resultRgb = (resultRgb - vec3f(0.5)) / (1.0 - brightnessContrast.contrast) + vec3f(0.5);
|
|
61
60
|
} else {
|
|
62
|
-
|
|
61
|
+
resultRgb = (resultRgb - vec3f(0.5)) * (1.0 + brightnessContrast.contrast) + vec3f(0.5);
|
|
63
62
|
}
|
|
64
|
-
return vec4f(
|
|
63
|
+
return vec4f(resultRgb, color.a);
|
|
65
64
|
}
|
|
66
65
|
`
|
|
67
66
|
);
|
|
68
67
|
var fs = (
|
|
69
68
|
/* glsl */
|
|
70
|
-
`uniform brightnessContrastUniforms {
|
|
69
|
+
`layout(std140) uniform brightnessContrastUniforms {
|
|
71
70
|
float brightness;
|
|
72
71
|
float contrast;
|
|
73
72
|
} brightnessContrast;
|
|
@@ -110,43 +109,51 @@ var brightnessContrast = {
|
|
|
110
109
|
// dist/passes/postprocessing/image-adjust-filters/denoise.js
|
|
111
110
|
var source2 = (
|
|
112
111
|
/* wgsl */
|
|
113
|
-
`
|
|
114
|
-
|
|
115
|
-
strength: f32
|
|
112
|
+
`struct denoiseUniforms {
|
|
113
|
+
strength: f32,
|
|
116
114
|
};
|
|
117
115
|
|
|
118
|
-
@group(0)
|
|
119
|
-
|
|
120
|
-
fn denoise_sampleColor(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
116
|
+
@group(0) @binding(auto) var<uniform> denoise: denoiseUniforms;
|
|
117
|
+
|
|
118
|
+
fn denoise_sampleColor(
|
|
119
|
+
sourceTexture: texture_2d<f32>,
|
|
120
|
+
sourceTextureSampler: sampler,
|
|
121
|
+
texSize: vec2f,
|
|
122
|
+
texCoord: vec2f
|
|
123
|
+
) -> vec4f {
|
|
124
|
+
let adjustedExponent = 3.0 + 200.0 * pow(1.0 - denoise.strength, 4.0);
|
|
125
|
+
let center = textureSample(sourceTexture, sourceTextureSampler, texCoord);
|
|
126
|
+
var color = vec4f(0.0);
|
|
127
|
+
var total = 0.0;
|
|
128
|
+
|
|
129
|
+
for (var x = -4.0; x <= 4.0; x += 1.0) {
|
|
130
|
+
for (var y = -4.0; y <= 4.0; y += 1.0) {
|
|
131
|
+
let offsetColor = textureSample(
|
|
132
|
+
sourceTexture,
|
|
133
|
+
sourceTextureSampler,
|
|
134
|
+
texCoord + vec2f(x, y) / texSize
|
|
135
|
+
);
|
|
136
|
+
let weight = pow(
|
|
137
|
+
1.0 - abs(dot(offsetColor.rgb - center.rgb, vec3f(0.25))),
|
|
138
|
+
adjustedExponent
|
|
139
|
+
);
|
|
140
|
+
color += offsetColor * weight;
|
|
141
|
+
total += weight;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
137
144
|
|
|
138
|
-
|
|
139
|
-
}
|
|
145
|
+
return color / total;
|
|
146
|
+
}
|
|
140
147
|
`
|
|
141
148
|
);
|
|
142
149
|
var fs2 = (
|
|
143
150
|
/* glsl */
|
|
144
|
-
`uniform
|
|
151
|
+
`layout(std140) uniform denoiseUniforms {
|
|
145
152
|
float strength;
|
|
146
153
|
} denoise;
|
|
147
154
|
|
|
148
|
-
vec4
|
|
149
|
-
float adjustedExponent = 3. + 200. * pow(1. -
|
|
155
|
+
vec4 denoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
156
|
+
float adjustedExponent = 3. + 200. * pow(1. - denoise.strength, 4.);
|
|
150
157
|
|
|
151
158
|
vec4 center = texture(source, texCoord);
|
|
152
159
|
vec4 color = vec4(0.0);
|
|
@@ -184,50 +191,43 @@ var denoise = {
|
|
|
184
191
|
// dist/passes/postprocessing/image-adjust-filters/huesaturation.js
|
|
185
192
|
var source3 = (
|
|
186
193
|
/* wgsl */
|
|
187
|
-
`
|
|
188
|
-
struct hueSaturationUniforms {
|
|
194
|
+
`struct hueSaturationUniforms {
|
|
189
195
|
hue: f32,
|
|
190
196
|
saturation: f32,
|
|
191
197
|
};
|
|
192
198
|
|
|
193
|
-
@group(0)
|
|
194
|
-
|
|
195
|
-
fn hueSaturation_filterColor(color: vec4<f32>) -> vec4<f32> {
|
|
196
|
-
let angle: f32 = hueSaturation.hue * 3.1415927;
|
|
197
|
-
let s: f32 = sin(angle);
|
|
198
|
-
let c: f32 = cos(angle);
|
|
199
|
-
let weights: vec3<f32> = (vec3<f32>(2. * c, -sqrt(3.) * s - c, sqrt(3.) * s - c) + 1.) / 3.;
|
|
200
|
-
let len: f32 = length(color.rgb);
|
|
201
|
-
var colorrgb = color.rgb;
|
|
202
|
-
colorrgb = vec3<f32>(dot(color.rgb, weights.xyz), dot(color.rgb, weights.zxy), dot(color.rgb, weights.yzx));
|
|
203
|
-
color.r = colorrgb.x;
|
|
204
|
-
color.g = colorrgb.y;
|
|
205
|
-
color.b = colorrgb.z;
|
|
206
|
-
let average: f32 = (color.r + color.g + color.b) / 3.;
|
|
207
|
-
if (hueSaturation.saturation > 0.) {
|
|
208
|
-
var colorrgb = color.rgb;
|
|
209
|
-
colorrgb = color.rgb + ((average - color.rgb) * (1. - 1. / (1.001 - hueSaturation.saturation)));
|
|
210
|
-
color.r = colorrgb.x;
|
|
211
|
-
color.g = colorrgb.y;
|
|
212
|
-
color.b = colorrgb.z;
|
|
213
|
-
} else {
|
|
214
|
-
var colorrgb = color.rgb;
|
|
215
|
-
colorrgb = color.rgb + ((average - color.rgb) * -hueSaturation.saturation);
|
|
216
|
-
color.r = colorrgb.x;
|
|
217
|
-
color.g = colorrgb.y;
|
|
218
|
-
color.b = colorrgb.z;
|
|
219
|
-
}
|
|
220
|
-
return color;
|
|
221
|
-
}
|
|
199
|
+
@group(0) @binding(auto) var<uniform> hueSaturation: hueSaturationUniforms;
|
|
222
200
|
|
|
223
|
-
fn
|
|
224
|
-
|
|
225
|
-
|
|
201
|
+
fn hueSaturation_filterColor(color: vec4f) -> vec4f {
|
|
202
|
+
let angle = hueSaturation.hue * 3.14159265;
|
|
203
|
+
let s = sin(angle);
|
|
204
|
+
let c = cos(angle);
|
|
205
|
+
let weights = (vec3f(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + vec3f(1.0)) / 3.0;
|
|
206
|
+
|
|
207
|
+
var resultRgb = vec3f(
|
|
208
|
+
dot(color.rgb, weights.xyz),
|
|
209
|
+
dot(color.rgb, weights.zxy),
|
|
210
|
+
dot(color.rgb, weights.yzx)
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
let average = (resultRgb.r + resultRgb.g + resultRgb.b) / 3.0;
|
|
214
|
+
if (hueSaturation.saturation > 0.0) {
|
|
215
|
+
resultRgb += (vec3f(average) - resultRgb) * (1.0 - 1.0 / (1.001 - hueSaturation.saturation));
|
|
216
|
+
} else {
|
|
217
|
+
resultRgb += (vec3f(average) - resultRgb) * (-hueSaturation.saturation);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return vec4f(resultRgb, color.a);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
fn hueSaturation_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
224
|
+
return hueSaturation_filterColor(color);
|
|
225
|
+
}
|
|
226
226
|
`
|
|
227
227
|
);
|
|
228
228
|
var fs3 = (
|
|
229
229
|
/* glsl */
|
|
230
|
-
`uniform hueSaturationUniforms {
|
|
230
|
+
`layout(std140) uniform hueSaturationUniforms {
|
|
231
231
|
float hue;
|
|
232
232
|
float saturation;
|
|
233
233
|
} hueSaturation;
|
|
@@ -280,27 +280,28 @@ var hueSaturation = {
|
|
|
280
280
|
var source4 = (
|
|
281
281
|
/* wgsl */
|
|
282
282
|
`struct noiseUniforms {
|
|
283
|
-
amount: f32
|
|
283
|
+
amount: f32,
|
|
284
284
|
};
|
|
285
285
|
|
|
286
|
-
@group(0) @binding(
|
|
286
|
+
@group(0) @binding(auto) var<uniform> noise: noiseUniforms;
|
|
287
287
|
|
|
288
288
|
fn rand(co: vec2f) -> f32 {
|
|
289
289
|
return fract(sin(dot(co.xy, vec2f(12.9898, 78.233))) * 43758.547);
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
fn noise_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
293
|
+
let diff = (rand(texCoord) - 0.5) * noise.amount;
|
|
294
|
+
var result = color;
|
|
295
|
+
result.r += diff;
|
|
296
|
+
result.g += diff;
|
|
297
|
+
result.b += diff;
|
|
298
|
+
return result;
|
|
299
|
+
}
|
|
299
300
|
`
|
|
300
301
|
);
|
|
301
302
|
var fs4 = (
|
|
302
303
|
/* glsl */
|
|
303
|
-
`uniform noiseUniforms {
|
|
304
|
+
`layout(std140) uniform noiseUniforms {
|
|
304
305
|
float amount;
|
|
305
306
|
} noise;
|
|
306
307
|
|
|
@@ -336,32 +337,33 @@ var noise = {
|
|
|
336
337
|
var source5 = (
|
|
337
338
|
/* wgsl */
|
|
338
339
|
`struct sepiaUniforms {
|
|
339
|
-
amount: f32
|
|
340
|
+
amount: f32,
|
|
340
341
|
};
|
|
341
342
|
|
|
342
|
-
@group(0) @binding(
|
|
343
|
+
@group(0) @binding(auto) var<uniform> sepia: sepiaUniforms;
|
|
343
344
|
|
|
344
345
|
fn sepia_filterColor(color: vec4f) -> vec4f {
|
|
345
|
-
let r
|
|
346
|
-
let g
|
|
347
|
-
let b
|
|
346
|
+
let r = color.r;
|
|
347
|
+
let g = color.g;
|
|
348
|
+
let b = color.b;
|
|
348
349
|
|
|
349
|
-
|
|
350
|
+
var result = color;
|
|
351
|
+
result.r =
|
|
350
352
|
min(1.0, (r * (1.0 - (0.607 * sepia.amount))) + (g * (0.769 * sepia.amount)) + (b * (0.189 * sepia.amount)));
|
|
351
|
-
|
|
352
|
-
|
|
353
|
+
result.g = min(1.0, (r * 0.349 * sepia.amount) + (g * (1.0 - (0.314 * sepia.amount))) + (b * 0.168 * sepia.amount));
|
|
354
|
+
result.b = min(1.0, (r * 0.272 * sepia.amount) + (g * 0.534 * sepia.amount) + (b * (1.0 - (0.869 * sepia.amount))));
|
|
353
355
|
|
|
354
|
-
return
|
|
356
|
+
return result;
|
|
355
357
|
}
|
|
356
358
|
|
|
357
|
-
|
|
359
|
+
fn sepia_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
358
360
|
return sepia_filterColor(color);
|
|
359
361
|
}
|
|
360
362
|
`
|
|
361
363
|
);
|
|
362
364
|
var fs5 = (
|
|
363
365
|
/* glsl */
|
|
364
|
-
`uniform sepiaUniforms {
|
|
366
|
+
`layout(std140) uniform sepiaUniforms {
|
|
365
367
|
float amount;
|
|
366
368
|
} sepia;
|
|
367
369
|
|
|
@@ -402,27 +404,27 @@ var sepia = {
|
|
|
402
404
|
var source6 = (
|
|
403
405
|
/* wgsl */
|
|
404
406
|
`struct vibranceUniforms {
|
|
405
|
-
amount: f32
|
|
407
|
+
amount: f32,
|
|
406
408
|
};
|
|
407
409
|
|
|
408
|
-
@group(0) @binding(
|
|
410
|
+
@group(0) @binding(auto) var<uniform> vibrance: vibranceUniforms;
|
|
409
411
|
|
|
410
|
-
fn vibrance_filterColor(vec4f
|
|
411
|
-
let average
|
|
412
|
-
let mx
|
|
413
|
-
let amt
|
|
414
|
-
|
|
415
|
-
return color;
|
|
412
|
+
fn vibrance_filterColor(color: vec4f) -> vec4f {
|
|
413
|
+
let average = (color.r + color.g + color.b) / 3.0;
|
|
414
|
+
let mx = max(color.r, max(color.g, color.b));
|
|
415
|
+
let amt = (mx - average) * (-vibrance.amount * 3.0);
|
|
416
|
+
let resultRgb = mix(color.rgb, vec3f(mx), amt);
|
|
417
|
+
return vec4f(resultRgb, color.a);
|
|
416
418
|
}
|
|
417
419
|
|
|
418
|
-
|
|
420
|
+
fn vibrance_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
419
421
|
return vibrance_filterColor(color);
|
|
420
422
|
}
|
|
421
423
|
`
|
|
422
424
|
);
|
|
423
425
|
var fs6 = (
|
|
424
426
|
/* glsl */
|
|
425
|
-
`uniform vibranceUniforms {
|
|
427
|
+
`layout(std140) uniform vibranceUniforms {
|
|
426
428
|
float amount;
|
|
427
429
|
} vibrance;
|
|
428
430
|
|
|
@@ -459,29 +461,25 @@ var source7 = (
|
|
|
459
461
|
/* wgsl */
|
|
460
462
|
`struct vignetteUniforms {
|
|
461
463
|
radius: f32,
|
|
462
|
-
amount: f32
|
|
464
|
+
amount: f32,
|
|
463
465
|
};
|
|
464
466
|
|
|
465
|
-
@group(0) @binding(
|
|
466
|
-
|
|
467
|
-
fn vibrance_filterColor(color: vec4f) -> vec4f {
|
|
468
|
-
let average: f32 = (color.r + color.g + color.b) / 3.0;
|
|
469
|
-
let mx: f32 = max(color.r, max(color.g, color.b));
|
|
470
|
-
let amt: f32 = (mx - average) * (-vibrance.amount * 3.0);
|
|
471
|
-
color.rgb = mix(color.rgb, vec3f(mx), amt);
|
|
472
|
-
return color;
|
|
473
|
-
}
|
|
467
|
+
@group(0) @binding(auto) var<uniform> vignette: vignetteUniforms;
|
|
474
468
|
|
|
475
|
-
fn vignette_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) ->vec4f {
|
|
476
|
-
let dist
|
|
477
|
-
let ratio
|
|
478
|
-
|
|
469
|
+
fn vignette_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
470
|
+
let dist = distance(texCoord, vec2f(0.5, 0.5));
|
|
471
|
+
let ratio = smoothstep(
|
|
472
|
+
0.8,
|
|
473
|
+
vignette.radius * 0.799,
|
|
474
|
+
dist * (vignette.amount + vignette.radius)
|
|
475
|
+
);
|
|
476
|
+
return color * ratio + vec4f(0.0, 0.0, 0.0, 1.0) * (1.0 - ratio);
|
|
479
477
|
}
|
|
480
478
|
`
|
|
481
479
|
);
|
|
482
480
|
var fs7 = (
|
|
483
481
|
/* glsl */
|
|
484
|
-
`uniform vignetteUniforms {
|
|
482
|
+
`layout(std140) uniform vignetteUniforms {
|
|
485
483
|
float radius;
|
|
486
484
|
float amount;
|
|
487
485
|
} vignette;
|
|
@@ -518,7 +516,7 @@ var vignette = {
|
|
|
518
516
|
var import_shadertools = require("@luma.gl/shadertools");
|
|
519
517
|
var source8 = (
|
|
520
518
|
/* wgsl */
|
|
521
|
-
`
|
|
519
|
+
`struct tiltShiftUniforms {
|
|
522
520
|
blurRadius: f32,
|
|
523
521
|
gradientRadius: f32,
|
|
524
522
|
start: vec2f,
|
|
@@ -526,41 +524,59 @@ var source8 = (
|
|
|
526
524
|
invert: u32,
|
|
527
525
|
};
|
|
528
526
|
|
|
529
|
-
@group(0) @binding(
|
|
527
|
+
@group(0) @binding(auto) var<uniform> tiltShift: tiltShiftUniforms;
|
|
530
528
|
|
|
531
|
-
fn tiltShift_getDelta(
|
|
532
|
-
|
|
533
|
-
return
|
|
529
|
+
fn tiltShift_getDelta(texSize: vec2f) -> vec2f {
|
|
530
|
+
let vector = normalize((tiltShift.end - tiltShift.start) * texSize);
|
|
531
|
+
return select(vector, vec2f(-vector.y, vector.x), tiltShift.invert != 0u);
|
|
534
532
|
}
|
|
535
533
|
|
|
536
|
-
fn tiltShift_sampleColor(
|
|
537
|
-
|
|
538
|
-
|
|
534
|
+
fn tiltShift_sampleColor(
|
|
535
|
+
sourceTexture: texture_2d<f32>,
|
|
536
|
+
sourceTextureSampler: sampler,
|
|
537
|
+
texSize: vec2f,
|
|
538
|
+
texCoord: vec2f
|
|
539
|
+
) -> vec4f {
|
|
540
|
+
var color = vec4f(0.0);
|
|
541
|
+
var total = 0.0;
|
|
539
542
|
|
|
540
543
|
/* randomize the lookup values to hide the fixed number of samples */
|
|
541
|
-
|
|
544
|
+
let offset = random(vec3f(12.9898, 78.233, 151.7182), 0.0);
|
|
542
545
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
546
|
+
let normal = normalize(
|
|
547
|
+
vec2f(
|
|
548
|
+
(tiltShift.start.y - tiltShift.end.y) * texSize.y,
|
|
549
|
+
(tiltShift.end.x - tiltShift.start.x) * texSize.x
|
|
550
|
+
)
|
|
551
|
+
);
|
|
552
|
+
let radius =
|
|
553
|
+
smoothstep(
|
|
554
|
+
0.0,
|
|
555
|
+
1.0,
|
|
556
|
+
abs(dot(texCoord * texSize - tiltShift.start * texSize, normal)) / tiltShift.gradientRadius
|
|
557
|
+
) * tiltShift.blurRadius;
|
|
558
|
+
|
|
559
|
+
for (var t = -30.0; t <= 30.0; t += 1.0) {
|
|
560
|
+
let percent = (t + offset - 0.5) / 30.0;
|
|
561
|
+
let weight = 1.0 - abs(percent);
|
|
562
|
+
let offsetColor = textureSample(
|
|
563
|
+
sourceTexture,
|
|
564
|
+
sourceTextureSampler,
|
|
565
|
+
texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius
|
|
566
|
+
);
|
|
551
567
|
|
|
552
568
|
color += offsetColor * weight;
|
|
553
569
|
total += weight;
|
|
554
570
|
}
|
|
555
571
|
|
|
556
|
-
color
|
|
572
|
+
color /= total;
|
|
557
573
|
return color;
|
|
558
574
|
}
|
|
559
575
|
`
|
|
560
576
|
);
|
|
561
577
|
var fs8 = (
|
|
562
578
|
/* glsl */
|
|
563
|
-
`uniform tiltShiftUniforms {
|
|
579
|
+
`layout(std140) uniform tiltShiftUniforms {
|
|
564
580
|
float blurRadius;
|
|
565
581
|
float gradientRadius;
|
|
566
582
|
vec2 start;
|
|
@@ -628,46 +644,55 @@ var tiltShift = {
|
|
|
628
644
|
var import_shadertools2 = require("@luma.gl/shadertools");
|
|
629
645
|
var source9 = (
|
|
630
646
|
/* wgsl */
|
|
631
|
-
`
|
|
647
|
+
`struct triangleBlurUniforms {
|
|
632
648
|
radius: f32,
|
|
633
649
|
delta: vec2f,
|
|
634
|
-
}
|
|
650
|
+
};
|
|
635
651
|
|
|
636
|
-
@group(0) @binding(
|
|
652
|
+
@group(0) @binding(auto) var<uniform> triangleBlur: triangleBlurUniforms;
|
|
637
653
|
|
|
638
|
-
|
|
639
|
-
|
|
654
|
+
fn triangleBlur_sampleColor(
|
|
655
|
+
sourceTexture: texture_2d<f32>,
|
|
656
|
+
sourceTextureSampler: sampler,
|
|
657
|
+
texSize: vec2f,
|
|
658
|
+
texCoord: vec2f
|
|
659
|
+
) -> vec4f {
|
|
660
|
+
let adjustedDelta = triangleBlur.delta * triangleBlur.radius / texSize;
|
|
640
661
|
|
|
641
|
-
|
|
642
|
-
|
|
662
|
+
var color = vec4f(0.0);
|
|
663
|
+
var total = 0.0;
|
|
643
664
|
|
|
644
665
|
/* randomize the lookup values to hide the fixed number of samples */
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
for (
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
666
|
+
let offset = random(vec3f(12.9898, 78.233, 151.7182), 0.0);
|
|
667
|
+
|
|
668
|
+
for (var t = -30.0; t <= 30.0; t += 1.0) {
|
|
669
|
+
let percent = (t + offset - 0.5) / 30.0;
|
|
670
|
+
let weight = 1.0 - abs(percent);
|
|
671
|
+
let offsetColor = textureSample(
|
|
672
|
+
sourceTexture,
|
|
673
|
+
sourceTextureSampler,
|
|
674
|
+
texCoord + adjustedDelta * percent
|
|
675
|
+
);
|
|
651
676
|
|
|
652
677
|
/* switch to pre-multiplied alpha to correctly blur transparent images */
|
|
653
|
-
offsetColor.rgb
|
|
678
|
+
let premultipliedOffsetColor = vec4f(offsetColor.rgb * vec3f(offsetColor.a), offsetColor.a);
|
|
654
679
|
|
|
655
|
-
color +=
|
|
680
|
+
color += premultipliedOffsetColor * weight;
|
|
656
681
|
total += weight;
|
|
657
682
|
}
|
|
658
683
|
|
|
659
|
-
color
|
|
684
|
+
color /= total;
|
|
660
685
|
|
|
661
686
|
/* switch back from pre-multiplied alpha */
|
|
662
|
-
color.rgb
|
|
687
|
+
let unpremultipliedRgb = color.rgb / vec3f(color.a + 0.00001);
|
|
663
688
|
|
|
664
|
-
return color;
|
|
689
|
+
return vec4f(unpremultipliedRgb, color.a);
|
|
665
690
|
}
|
|
666
691
|
`
|
|
667
692
|
);
|
|
668
693
|
var fs9 = (
|
|
669
694
|
/* glsl */
|
|
670
|
-
`uniform triangleBlurUniforms {
|
|
695
|
+
`layout(std140) uniform triangleBlurUniforms {
|
|
671
696
|
float radius;
|
|
672
697
|
vec2 delta;
|
|
673
698
|
} triangleBlur;
|
|
@@ -728,31 +753,40 @@ var import_shadertools3 = require("@luma.gl/shadertools");
|
|
|
728
753
|
var source10 = (
|
|
729
754
|
/* wgsl */
|
|
730
755
|
`
|
|
731
|
-
|
|
756
|
+
struct zoomBlurUniforms {
|
|
732
757
|
center: vec2f,
|
|
733
758
|
strength: f32,
|
|
734
759
|
};
|
|
735
760
|
|
|
736
|
-
@group(0) @binding(
|
|
761
|
+
@group(0) @binding(auto) var<uniform> zoomBlur : zoomBlurUniforms;
|
|
737
762
|
|
|
738
763
|
|
|
739
|
-
fn zoomBlur_sampleColor(
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
764
|
+
fn zoomBlur_sampleColor(
|
|
765
|
+
sourceTexture: texture_2d<f32>,
|
|
766
|
+
sourceTextureSampler: sampler,
|
|
767
|
+
texSize: vec2f,
|
|
768
|
+
texCoord: vec2f
|
|
769
|
+
) -> vec4f {
|
|
770
|
+
var color = vec4f(0.0);
|
|
771
|
+
var total = 0.0;
|
|
772
|
+
let toCenter = zoomBlur.center * texSize - texCoord * texSize;
|
|
743
773
|
|
|
744
774
|
/* randomize the lookup values to hide the fixed number of samples */
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
for (
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
775
|
+
let offset = random(vec3f(12.9898, 78.233, 151.7182), 0.0);
|
|
776
|
+
|
|
777
|
+
for (var t = 0.0; t <= 40.0; t += 1.0) {
|
|
778
|
+
let percent = (t + offset) / 40.0;
|
|
779
|
+
let weight = 4.0 * (percent - percent * percent);
|
|
780
|
+
let offsetColor = textureSample(
|
|
781
|
+
sourceTexture,
|
|
782
|
+
sourceTextureSampler,
|
|
783
|
+
texCoord + toCenter * percent * zoomBlur.strength / texSize
|
|
784
|
+
);
|
|
751
785
|
color += offsetColor * weight;
|
|
752
786
|
total += weight;
|
|
753
787
|
}
|
|
754
788
|
|
|
755
|
-
color
|
|
789
|
+
color /= total;
|
|
756
790
|
return color;
|
|
757
791
|
}
|
|
758
792
|
`
|
|
@@ -760,7 +794,7 @@ fn zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f
|
|
|
760
794
|
var fs10 = (
|
|
761
795
|
/* glsl */
|
|
762
796
|
`
|
|
763
|
-
uniform zoomBlurUniforms {
|
|
797
|
+
layout(std140) uniform zoomBlurUniforms {
|
|
764
798
|
vec2 center;
|
|
765
799
|
float strength;
|
|
766
800
|
} zoomBlur;
|
|
@@ -810,44 +844,46 @@ var source11 = (
|
|
|
810
844
|
`struct colorHalftoneUniforms {
|
|
811
845
|
center: vec2f,
|
|
812
846
|
angle: f32,
|
|
813
|
-
size: f32
|
|
847
|
+
size: f32,
|
|
814
848
|
};
|
|
815
849
|
|
|
816
|
-
@group(0) @binding(
|
|
850
|
+
@group(0) @binding(auto) var<uniform> colorHalftone: colorHalftoneUniforms;
|
|
817
851
|
|
|
818
852
|
fn pattern(angle: f32, scale: f32, texSize: vec2f, texCoord: vec2f) -> f32 {
|
|
819
|
-
let s
|
|
820
|
-
let
|
|
821
|
-
let
|
|
822
|
-
|
|
823
|
-
|
|
853
|
+
let s = sin(angle);
|
|
854
|
+
let c = cos(angle);
|
|
855
|
+
let tex = texCoord * texSize - colorHalftone.center * texSize;
|
|
856
|
+
let point = vec2f(
|
|
857
|
+
c * tex.x - s * tex.y,
|
|
858
|
+
s * tex.x + c * tex.y
|
|
824
859
|
) * scale;
|
|
825
860
|
return (sin(point.x) * sin(point.y)) * 4.0;
|
|
826
861
|
}
|
|
827
862
|
|
|
828
|
-
fn colorHalftone_filterColor_ext(vec4f
|
|
829
|
-
let scale
|
|
830
|
-
|
|
831
|
-
|
|
863
|
+
fn colorHalftone_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
864
|
+
let scale = 3.1514 / colorHalftone.size;
|
|
865
|
+
var cmy = vec3f(1.0) - color.rgb;
|
|
866
|
+
var k = min(cmy.x, min(cmy.y, cmy.z));
|
|
867
|
+
let safeDenominator = max(1.0 - k, 0.00001);
|
|
832
868
|
|
|
833
|
-
cmy = (cmy - k) /
|
|
869
|
+
cmy = (cmy - vec3f(k)) / safeDenominator;
|
|
834
870
|
cmy = clamp(
|
|
835
|
-
|
|
871
|
+
cmy * 10.0 - vec3f(3.0) + vec3f(
|
|
836
872
|
pattern(colorHalftone.angle + 0.26179, scale, texSize, texCoord),
|
|
837
|
-
|
|
873
|
+
pattern(colorHalftone.angle + 1.30899, scale, texSize, texCoord),
|
|
838
874
|
pattern(colorHalftone.angle, scale, texSize, texCoord)
|
|
839
875
|
),
|
|
840
|
-
|
|
841
|
-
|
|
876
|
+
vec3f(0.0),
|
|
877
|
+
vec3f(1.0)
|
|
842
878
|
);
|
|
843
879
|
k = clamp(k * 10.0 - 5.0 + pattern(colorHalftone.angle + 0.78539, scale, texSize, texCoord), 0.0, 1.0);
|
|
844
|
-
return
|
|
880
|
+
return vec4f(vec3f(1.0) - cmy - vec3f(k), color.a);
|
|
845
881
|
}
|
|
846
882
|
`
|
|
847
883
|
);
|
|
848
884
|
var fs11 = (
|
|
849
885
|
/* glsl */
|
|
850
|
-
`uniform colorHalftoneUniforms {
|
|
886
|
+
`layout(std140) uniform colorHalftoneUniforms {
|
|
851
887
|
vec2 center;
|
|
852
888
|
float angle;
|
|
853
889
|
float size;
|
|
@@ -905,35 +941,35 @@ var colorHalftone = {
|
|
|
905
941
|
// dist/passes/postprocessing/image-fun-filters/dotscreen.js
|
|
906
942
|
var source12 = (
|
|
907
943
|
/* wgsl */
|
|
908
|
-
`
|
|
944
|
+
`struct dotScreenUniforms {
|
|
909
945
|
center: vec2f,
|
|
910
946
|
angle: f32,
|
|
911
947
|
size: f32,
|
|
912
948
|
};
|
|
913
949
|
|
|
914
|
-
@group(0) @binding(
|
|
950
|
+
@group(0) @binding(auto) var<uniform> dotScreen: dotScreenUniforms;
|
|
915
951
|
|
|
916
952
|
fn pattern(texSize: vec2f, texCoord: vec2f) -> f32 {
|
|
917
|
-
let scale
|
|
918
|
-
|
|
919
|
-
let
|
|
920
|
-
tex
|
|
921
|
-
point = vec2f(
|
|
922
|
-
c
|
|
953
|
+
let scale = 3.1415 / dotScreen.size;
|
|
954
|
+
let s = sin(dotScreen.angle);
|
|
955
|
+
let c = cos(dotScreen.angle);
|
|
956
|
+
let tex = texCoord * texSize - dotScreen.center * texSize;
|
|
957
|
+
let point = vec2f(
|
|
958
|
+
c * tex.x - s * tex.y,
|
|
923
959
|
s * tex.x + c * tex.y
|
|
924
960
|
) * scale;
|
|
925
961
|
return (sin(point.x) * sin(point.y)) * 4.0;
|
|
926
962
|
}
|
|
927
963
|
|
|
928
|
-
fn dotScreen_filterColor_ext(
|
|
929
|
-
let average
|
|
930
|
-
return
|
|
964
|
+
fn dotScreen_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
965
|
+
let average = (color.r + color.g + color.b) / 3.0;
|
|
966
|
+
return vec4f(vec3f(average * 10.0 - 5.0 + pattern(texSize, texCoord)), color.a);
|
|
931
967
|
}
|
|
932
968
|
`
|
|
933
969
|
);
|
|
934
970
|
var fs12 = (
|
|
935
971
|
/* glsl */
|
|
936
|
-
`uniform dotScreenUniforms {
|
|
972
|
+
`layout(std140) uniform dotScreenUniforms {
|
|
937
973
|
vec2 center;
|
|
938
974
|
float angle;
|
|
939
975
|
float size;
|
|
@@ -982,25 +1018,35 @@ var source13 = (
|
|
|
982
1018
|
/* wgsl */
|
|
983
1019
|
`struct edgeWorkUniforms {
|
|
984
1020
|
radius: f32,
|
|
985
|
-
|
|
1021
|
+
mode: u32,
|
|
986
1022
|
};
|
|
987
1023
|
|
|
988
|
-
@group(0) @binding(
|
|
1024
|
+
@group(0) @binding(auto) var<uniform> edgeWork: edgeWorkUniforms;
|
|
989
1025
|
|
|
990
|
-
fn edgeWork_sampleColorRGB(
|
|
991
|
-
|
|
1026
|
+
fn edgeWork_sampleColorRGB(
|
|
1027
|
+
sourceTexture: texture_2d<f32>,
|
|
1028
|
+
sourceTextureSampler: sampler,
|
|
1029
|
+
texSize: vec2f,
|
|
1030
|
+
texCoord: vec2f,
|
|
1031
|
+
delta: vec2f
|
|
1032
|
+
) -> vec4f {
|
|
1033
|
+
let relativeDelta = edgeWork.radius * delta / texSize;
|
|
992
1034
|
|
|
993
|
-
|
|
994
|
-
|
|
1035
|
+
var color = vec2f(0.0);
|
|
1036
|
+
var total = vec2f(0.0);
|
|
995
1037
|
|
|
996
1038
|
/* randomize the lookup values to hide the fixed number of samples */
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
for (
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1039
|
+
let offset = random(vec3f(12.9898, 78.233, 151.7182), 0.0);
|
|
1040
|
+
|
|
1041
|
+
for (var t = -30.0; t <= 30.0; t += 1.0) {
|
|
1042
|
+
let percent = (t + offset - 0.5) / 30.0;
|
|
1043
|
+
var weight = 1.0 - abs(percent);
|
|
1044
|
+
let sampleColor = textureSample(
|
|
1045
|
+
sourceTexture,
|
|
1046
|
+
sourceTextureSampler,
|
|
1047
|
+
texCoord + relativeDelta * percent
|
|
1048
|
+
).rgb;
|
|
1049
|
+
let average = (sampleColor.r + sampleColor.g + sampleColor.b) / 3.0;
|
|
1004
1050
|
color.x += average * weight;
|
|
1005
1051
|
total.x += weight;
|
|
1006
1052
|
if (abs(t) < 15.0) {
|
|
@@ -1009,13 +1055,74 @@ fn edgeWork_sampleColorRGB(sampler2D source, vec2 texSize, vec2 texCoord, vec2 d
|
|
|
1009
1055
|
total.y += weight;
|
|
1010
1056
|
}
|
|
1011
1057
|
}
|
|
1012
|
-
return
|
|
1058
|
+
return vec4f(color / total, 0.0, 1.0);
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
fn edgeWork_sampleColorXY(
|
|
1062
|
+
sourceTexture: texture_2d<f32>,
|
|
1063
|
+
sourceTextureSampler: sampler,
|
|
1064
|
+
texSize: vec2f,
|
|
1065
|
+
texCoord: vec2f,
|
|
1066
|
+
delta: vec2f
|
|
1067
|
+
) -> vec4f {
|
|
1068
|
+
let relativeDelta = edgeWork.radius * delta / texSize;
|
|
1069
|
+
|
|
1070
|
+
var color = vec2f(0.0);
|
|
1071
|
+
var total = vec2f(0.0);
|
|
1072
|
+
|
|
1073
|
+
/* randomize the lookup values to hide the fixed number of samples */
|
|
1074
|
+
let offset = random(vec3f(12.9898, 78.233, 151.7182), 0.0);
|
|
1075
|
+
|
|
1076
|
+
for (var t = -30.0; t <= 30.0; t += 1.0) {
|
|
1077
|
+
let percent = (t + offset - 0.5) / 30.0;
|
|
1078
|
+
var weight = 1.0 - abs(percent);
|
|
1079
|
+
let sampleColor = textureSample(
|
|
1080
|
+
sourceTexture,
|
|
1081
|
+
sourceTextureSampler,
|
|
1082
|
+
texCoord + relativeDelta * percent
|
|
1083
|
+
).xy;
|
|
1084
|
+
color.x += sampleColor.x * weight;
|
|
1085
|
+
total.x += weight;
|
|
1086
|
+
if (abs(t) < 15.0) {
|
|
1087
|
+
weight = weight * 2.0 - 1.0;
|
|
1088
|
+
color.y += sampleColor.y * weight;
|
|
1089
|
+
total.y += weight;
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
let c = clamp(10000.0 * (color.y / total.y - color.x / total.x) + 0.5, 0.0, 1.0);
|
|
1094
|
+
return vec4f(c, c, c, 1.0);
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
fn edgeWork_sampleColor(
|
|
1098
|
+
sourceTexture: texture_2d<f32>,
|
|
1099
|
+
sourceTextureSampler: sampler,
|
|
1100
|
+
texSize: vec2f,
|
|
1101
|
+
texCoord: vec2f
|
|
1102
|
+
) -> vec4f {
|
|
1103
|
+
if (edgeWork.mode == 0u) {
|
|
1104
|
+
return edgeWork_sampleColorRGB(
|
|
1105
|
+
sourceTexture,
|
|
1106
|
+
sourceTextureSampler,
|
|
1107
|
+
texSize,
|
|
1108
|
+
texCoord,
|
|
1109
|
+
vec2f(1.0, 0.0)
|
|
1110
|
+
);
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
return edgeWork_sampleColorXY(
|
|
1114
|
+
sourceTexture,
|
|
1115
|
+
sourceTextureSampler,
|
|
1116
|
+
texSize,
|
|
1117
|
+
texCoord,
|
|
1118
|
+
vec2f(0.0, 1.0)
|
|
1119
|
+
);
|
|
1013
1120
|
}
|
|
1014
1121
|
`
|
|
1015
1122
|
);
|
|
1016
1123
|
var fs13 = (
|
|
1017
1124
|
/* glsl */
|
|
1018
|
-
`uniform edgeWorkUniforms {
|
|
1125
|
+
`layout(std140) uniform edgeWorkUniforms {
|
|
1019
1126
|
float radius;
|
|
1020
1127
|
int mode;
|
|
1021
1128
|
} edgeWork;
|
|
@@ -1116,50 +1223,62 @@ var source14 = (
|
|
|
1116
1223
|
scale: f32,
|
|
1117
1224
|
};
|
|
1118
1225
|
|
|
1119
|
-
@group(0) @binding(
|
|
1226
|
+
@group(0) @binding(auto) var<uniform> hexagonalPixelate: hexagonalPixelateUniforms;
|
|
1120
1227
|
|
|
1121
|
-
fn hexagonalPixelate_sampleColor(
|
|
1122
|
-
|
|
1228
|
+
fn hexagonalPixelate_sampleColor(
|
|
1229
|
+
sourceTexture: texture_2d<f32>,
|
|
1230
|
+
sourceTextureSampler: sampler,
|
|
1231
|
+
texSize: vec2f,
|
|
1232
|
+
texCoord: vec2f
|
|
1233
|
+
) -> vec4f {
|
|
1234
|
+
var tex = (texCoord * texSize - hexagonalPixelate.center * texSize) / hexagonalPixelate.scale;
|
|
1123
1235
|
tex.y /= 0.866025404;
|
|
1124
1236
|
tex.x -= tex.y * 0.5;
|
|
1125
1237
|
|
|
1126
|
-
|
|
1238
|
+
var a = vec2f(0.0);
|
|
1127
1239
|
if (tex.x + tex.y - floor(tex.x) - floor(tex.y) < 1.0) {
|
|
1128
|
-
a =
|
|
1240
|
+
a = vec2f(floor(tex.x), floor(tex.y));
|
|
1241
|
+
} else {
|
|
1242
|
+
a = vec2f(ceil(tex.x), ceil(tex.y));
|
|
1129
1243
|
}
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
else
|
|
1244
|
+
let b = vec2f(ceil(tex.x), floor(tex.y));
|
|
1245
|
+
let c = vec2f(floor(tex.x), ceil(tex.y));
|
|
1246
|
+
|
|
1247
|
+
let texBarycentric = vec3f(tex.x, tex.y, 1.0 - tex.x - tex.y);
|
|
1248
|
+
let aBarycentric = vec3f(a.x, a.y, 1.0 - a.x - a.y);
|
|
1249
|
+
let bBarycentric = vec3f(b.x, b.y, 1.0 - b.x - b.y);
|
|
1250
|
+
let cBarycentric = vec3f(c.x, c.y, 1.0 - c.x - c.y);
|
|
1251
|
+
|
|
1252
|
+
let aLength = length(texBarycentric - aBarycentric);
|
|
1253
|
+
let bLength = length(texBarycentric - bBarycentric);
|
|
1254
|
+
let cLength = length(texBarycentric - cBarycentric);
|
|
1255
|
+
|
|
1256
|
+
var choice = vec2f(0.0);
|
|
1257
|
+
if (aLength < bLength) {
|
|
1258
|
+
if (aLength < cLength) {
|
|
1259
|
+
choice = a;
|
|
1260
|
+
} else {
|
|
1261
|
+
choice = c;
|
|
1262
|
+
}
|
|
1147
1263
|
} else {
|
|
1148
|
-
if (
|
|
1149
|
-
|
|
1264
|
+
if (bLength < cLength) {
|
|
1265
|
+
choice = b;
|
|
1266
|
+
} else {
|
|
1267
|
+
choice = c;
|
|
1268
|
+
}
|
|
1150
1269
|
}
|
|
1151
1270
|
|
|
1152
1271
|
choice.x += choice.y * 0.5;
|
|
1153
1272
|
choice.y *= 0.866025404;
|
|
1154
1273
|
choice *= hexagonalPixelate.scale / texSize;
|
|
1155
1274
|
|
|
1156
|
-
return
|
|
1275
|
+
return textureSample(sourceTexture, sourceTextureSampler, choice + hexagonalPixelate.center);
|
|
1157
1276
|
}
|
|
1158
1277
|
`
|
|
1159
1278
|
);
|
|
1160
1279
|
var fs14 = (
|
|
1161
1280
|
/* glsl */
|
|
1162
|
-
`uniform hexagonalPixelateUniforms {
|
|
1281
|
+
`layout(std140) uniform hexagonalPixelateUniforms {
|
|
1163
1282
|
vec2 center;
|
|
1164
1283
|
float scale;
|
|
1165
1284
|
} hexagonalPixelate;
|
|
@@ -1223,23 +1342,32 @@ var hexagonalPixelate = {
|
|
|
1223
1342
|
// dist/passes/postprocessing/image-fun-filters/ink.js
|
|
1224
1343
|
var source15 = (
|
|
1225
1344
|
/* wgsl */
|
|
1226
|
-
`
|
|
1345
|
+
`struct inkUniforms {
|
|
1227
1346
|
strength: f32,
|
|
1228
1347
|
};
|
|
1229
1348
|
|
|
1230
|
-
@group(0) @binding(
|
|
1231
|
-
|
|
1232
|
-
fn ink_sampleColor(
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1349
|
+
@group(0) @binding(auto) var<uniform> ink: inkUniforms;
|
|
1350
|
+
|
|
1351
|
+
fn ink_sampleColor(
|
|
1352
|
+
sourceTexture: texture_2d<f32>,
|
|
1353
|
+
sourceTextureSampler: sampler,
|
|
1354
|
+
texSize: vec2f,
|
|
1355
|
+
texCoord: vec2f
|
|
1356
|
+
) -> vec4f {
|
|
1357
|
+
let dx = vec2f(1.0 / texSize.x, 0.0);
|
|
1358
|
+
let dy = vec2f(0.0, 1.0 / texSize.y);
|
|
1359
|
+
let color = textureSample(sourceTexture, sourceTextureSampler, texCoord);
|
|
1360
|
+
var bigTotal = 0.0;
|
|
1361
|
+
var smallTotal = 0.0;
|
|
1362
|
+
var bigAverage = vec3f(0.0);
|
|
1363
|
+
var smallAverage = vec3f(0.0);
|
|
1364
|
+
for (var x = -2.0; x <= 2.0; x += 1.0) {
|
|
1365
|
+
for (var y = -2.0; y <= 2.0; y += 1.0) {
|
|
1366
|
+
let offsetColor = textureSample(
|
|
1367
|
+
sourceTexture,
|
|
1368
|
+
sourceTextureSampler,
|
|
1369
|
+
texCoord + dx * x + dy * y
|
|
1370
|
+
).rgb;
|
|
1243
1371
|
bigAverage += offsetColor;
|
|
1244
1372
|
bigTotal += 1.0;
|
|
1245
1373
|
if (abs(x) + abs(y) < 2.0) {
|
|
@@ -1248,15 +1376,15 @@ fn ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {
|
|
|
1248
1376
|
}
|
|
1249
1377
|
}
|
|
1250
1378
|
}
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
return
|
|
1379
|
+
let edge = max(vec3f(0.0), bigAverage / bigTotal - smallAverage / smallTotal);
|
|
1380
|
+
let power = ink.strength * ink.strength * ink.strength * ink.strength * ink.strength;
|
|
1381
|
+
return vec4f(color.rgb - vec3f(dot(edge, edge) * power * 100000.0), color.a);
|
|
1254
1382
|
}
|
|
1255
1383
|
`
|
|
1256
1384
|
);
|
|
1257
1385
|
var fs15 = (
|
|
1258
1386
|
/* glsl */
|
|
1259
|
-
`uniform inkUniforms {
|
|
1387
|
+
`layout(std140) uniform inkUniforms {
|
|
1260
1388
|
float strength;
|
|
1261
1389
|
} ink;
|
|
1262
1390
|
|
|
@@ -1303,33 +1431,43 @@ var ink = {
|
|
|
1303
1431
|
// dist/passes/postprocessing/image-fun-filters/magnify.js
|
|
1304
1432
|
var source16 = (
|
|
1305
1433
|
/* wgsl */
|
|
1306
|
-
`
|
|
1307
|
-
screenXY: vec2f
|
|
1308
|
-
radiusPixels: f32
|
|
1309
|
-
zoom: f32
|
|
1310
|
-
borderWidthPixels: f32
|
|
1311
|
-
borderColor: vec4f
|
|
1434
|
+
`struct magnifyUniforms {
|
|
1435
|
+
screenXY: vec2f,
|
|
1436
|
+
radiusPixels: f32,
|
|
1437
|
+
zoom: f32,
|
|
1438
|
+
borderWidthPixels: f32,
|
|
1439
|
+
borderColor: vec4f,
|
|
1312
1440
|
};
|
|
1313
1441
|
|
|
1314
|
-
@group(0) @binding(
|
|
1442
|
+
@group(0) @binding(auto) var<uniform> magnify: magnifyUniforms;
|
|
1315
1443
|
|
|
1316
|
-
fn magnify_sampleColor(
|
|
1317
|
-
|
|
1318
|
-
|
|
1444
|
+
fn magnify_sampleColor(
|
|
1445
|
+
sourceTexture: texture_2d<f32>,
|
|
1446
|
+
sourceTextureSampler: sampler,
|
|
1447
|
+
texSize: vec2f,
|
|
1448
|
+
texCoord: vec2f
|
|
1449
|
+
) -> vec4f {
|
|
1450
|
+
let pos = vec2f(magnify.screenXY.x, 1.0 - magnify.screenXY.y);
|
|
1451
|
+
let dist = distance(texCoord * texSize, pos * texSize);
|
|
1319
1452
|
if (dist < magnify.radiusPixels) {
|
|
1320
|
-
return
|
|
1453
|
+
return textureSampleLevel(
|
|
1454
|
+
sourceTexture,
|
|
1455
|
+
sourceTextureSampler,
|
|
1456
|
+
(texCoord - pos) / magnify.zoom + pos,
|
|
1457
|
+
0.0
|
|
1458
|
+
);
|
|
1321
1459
|
}
|
|
1322
1460
|
|
|
1323
1461
|
if (dist <= magnify.radiusPixels + magnify.borderWidthPixels) {
|
|
1324
1462
|
return magnify.borderColor;
|
|
1325
1463
|
}
|
|
1326
|
-
return
|
|
1464
|
+
return textureSampleLevel(sourceTexture, sourceTextureSampler, texCoord, 0.0);
|
|
1327
1465
|
}
|
|
1328
1466
|
`
|
|
1329
1467
|
);
|
|
1330
1468
|
var fs16 = (
|
|
1331
1469
|
/* glsl */
|
|
1332
|
-
`uniform magnifyUniforms {
|
|
1470
|
+
`layout(std140) uniform magnifyUniforms {
|
|
1333
1471
|
vec2 screenXY;
|
|
1334
1472
|
float radiusPixels;
|
|
1335
1473
|
float zoom;
|
|
@@ -1376,10 +1514,15 @@ var magnify = {
|
|
|
1376
1514
|
// dist/passes/postprocessing/image-warp-filters/warp.js
|
|
1377
1515
|
var source17 = (
|
|
1378
1516
|
/* wgsl */
|
|
1379
|
-
`
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1517
|
+
`fn warp_sampleColor(
|
|
1518
|
+
sourceTexture: texture_2d<f32>,
|
|
1519
|
+
sourceTextureSampler: sampler,
|
|
1520
|
+
texSize: vec2f,
|
|
1521
|
+
coord: vec2f
|
|
1522
|
+
) -> vec4f {
|
|
1523
|
+
var color = textureSample(sourceTexture, sourceTextureSampler, coord / texSize);
|
|
1524
|
+
let clampedCoord = clamp(coord, vec2f(0.0), texSize);
|
|
1525
|
+
if (any(coord != clampedCoord)) {
|
|
1383
1526
|
/* fade to transparent if we are outside the image */
|
|
1384
1527
|
color.a *= max(0.0, 1.0 - length(coord - clampedCoord));
|
|
1385
1528
|
}
|
|
@@ -1410,42 +1553,56 @@ var warp = {
|
|
|
1410
1553
|
// dist/passes/postprocessing/image-warp-filters/bulgepinch.js
|
|
1411
1554
|
var source18 = (
|
|
1412
1555
|
/* wgsl */
|
|
1413
|
-
`
|
|
1556
|
+
`struct bulgePinchUniforms {
|
|
1557
|
+
center: vec2f,
|
|
1414
1558
|
radius: f32,
|
|
1415
1559
|
strength: f32,
|
|
1416
|
-
center: vec2f,
|
|
1417
1560
|
};
|
|
1418
1561
|
|
|
1419
|
-
@group(0) @binding(
|
|
1562
|
+
@group(0) @binding(auto) var<uniform> bulgePinch: bulgePinchUniforms;
|
|
1420
1563
|
|
|
1421
|
-
fn bulgePinch_warp(
|
|
1422
|
-
coord
|
|
1423
|
-
|
|
1564
|
+
fn bulgePinch_warp(coordIn: vec2f, texCenter: vec2f) -> vec2f {
|
|
1565
|
+
var coord = coordIn - texCenter;
|
|
1566
|
+
let distance = length(coord);
|
|
1424
1567
|
if (distance < bulgePinch.radius) {
|
|
1425
|
-
|
|
1568
|
+
let percent = distance / bulgePinch.radius;
|
|
1569
|
+
let safeDistance = max(distance, 0.00001);
|
|
1426
1570
|
if (bulgePinch.strength > 0.0) {
|
|
1427
|
-
coord *= mix(
|
|
1571
|
+
coord *= mix(
|
|
1572
|
+
1.0,
|
|
1573
|
+
smoothstep(0.0, bulgePinch.radius / safeDistance, percent),
|
|
1574
|
+
bulgePinch.strength * 0.75
|
|
1575
|
+
);
|
|
1428
1576
|
} else {
|
|
1429
|
-
coord *= mix(
|
|
1577
|
+
coord *= mix(
|
|
1578
|
+
1.0,
|
|
1579
|
+
pow(percent, 1.0 + bulgePinch.strength * 0.75) * bulgePinch.radius / safeDistance,
|
|
1580
|
+
1.0 - percent
|
|
1581
|
+
);
|
|
1430
1582
|
}
|
|
1431
1583
|
}
|
|
1432
1584
|
coord += texCenter;
|
|
1433
1585
|
return coord;
|
|
1434
1586
|
}
|
|
1435
1587
|
|
|
1436
|
-
fn bulgePinch_sampleColor(
|
|
1437
|
-
|
|
1588
|
+
fn bulgePinch_sampleColor(
|
|
1589
|
+
sourceTexture: texture_2d<f32>,
|
|
1590
|
+
sourceTextureSampler: sampler,
|
|
1591
|
+
texSize: vec2f,
|
|
1592
|
+
texCoord: vec2f
|
|
1593
|
+
) -> vec4f {
|
|
1594
|
+
var coord = texCoord * texSize;
|
|
1438
1595
|
coord = bulgePinch_warp(coord, bulgePinch.center * texSize);
|
|
1439
|
-
return warp_sampleColor(
|
|
1596
|
+
return warp_sampleColor(sourceTexture, sourceTextureSampler, texSize, coord);
|
|
1440
1597
|
}
|
|
1441
1598
|
`
|
|
1442
1599
|
);
|
|
1443
1600
|
var fs18 = (
|
|
1444
1601
|
/* glsl */
|
|
1445
|
-
`uniform bulgePinchUniforms {
|
|
1602
|
+
`layout(std140) uniform bulgePinchUniforms {
|
|
1603
|
+
vec2 center;
|
|
1446
1604
|
float radius;
|
|
1447
1605
|
float strength;
|
|
1448
|
-
vec2 center;
|
|
1449
1606
|
} bulgePinch;
|
|
1450
1607
|
|
|
1451
1608
|
vec2 bulgePinch_warp(vec2 coord, vec2 texCenter) {
|
|
@@ -1494,23 +1651,23 @@ var bulgePinch = {
|
|
|
1494
1651
|
// dist/passes/postprocessing/image-warp-filters/swirl.js
|
|
1495
1652
|
var source19 = (
|
|
1496
1653
|
/* wgsl */
|
|
1497
|
-
`
|
|
1654
|
+
`struct swirlUniforms {
|
|
1655
|
+
center: vec2f,
|
|
1498
1656
|
radius: f32,
|
|
1499
1657
|
angle: f32,
|
|
1500
|
-
center: vec2f,
|
|
1501
1658
|
};
|
|
1502
1659
|
|
|
1503
|
-
@group(0) @binding(
|
|
1660
|
+
@group(0) @binding(auto) var<uniform> swirl: swirlUniforms;
|
|
1504
1661
|
|
|
1505
|
-
fn swirl_warp(
|
|
1506
|
-
coord
|
|
1507
|
-
|
|
1662
|
+
fn swirl_warp(coordIn: vec2f, texCenter: vec2f) -> vec2f {
|
|
1663
|
+
var coord = coordIn - texCenter;
|
|
1664
|
+
let distance = length(coord);
|
|
1508
1665
|
if (distance < swirl.radius) {
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
coord =
|
|
1666
|
+
let percent = (swirl.radius - distance) / swirl.radius;
|
|
1667
|
+
let theta = percent * percent * swirl.angle;
|
|
1668
|
+
let s = sin(theta);
|
|
1669
|
+
let c = cos(theta);
|
|
1670
|
+
coord = vec2f(
|
|
1514
1671
|
coord.x * c - coord.y * s,
|
|
1515
1672
|
coord.x * s + coord.y * c
|
|
1516
1673
|
);
|
|
@@ -1519,19 +1676,24 @@ fn swirl_warp(vec2 coord, vec2 texCenter) -> vec2f {
|
|
|
1519
1676
|
return coord;
|
|
1520
1677
|
}
|
|
1521
1678
|
|
|
1522
|
-
fn swirl_sampleColor(
|
|
1523
|
-
|
|
1679
|
+
fn swirl_sampleColor(
|
|
1680
|
+
sourceTexture: texture_2d<f32>,
|
|
1681
|
+
sourceTextureSampler: sampler,
|
|
1682
|
+
texSize: vec2f,
|
|
1683
|
+
texCoord: vec2f
|
|
1684
|
+
) -> vec4f {
|
|
1685
|
+
var coord = texCoord * texSize;
|
|
1524
1686
|
coord = swirl_warp(coord, swirl.center * texSize);
|
|
1525
|
-
return warp_sampleColor(
|
|
1687
|
+
return warp_sampleColor(sourceTexture, sourceTextureSampler, texSize, coord);
|
|
1526
1688
|
}
|
|
1527
1689
|
`
|
|
1528
1690
|
);
|
|
1529
1691
|
var fs19 = (
|
|
1530
1692
|
/* glsl */
|
|
1531
|
-
`uniform swirlUniforms {
|
|
1693
|
+
`layout(std140) uniform swirlUniforms {
|
|
1694
|
+
vec2 center;
|
|
1532
1695
|
float radius;
|
|
1533
1696
|
float angle;
|
|
1534
|
-
vec2 center;
|
|
1535
1697
|
} swirl;
|
|
1536
1698
|
|
|
1537
1699
|
vec2 swirl_warp(vec2 coord, vec2 texCenter) {
|
|
@@ -1580,6 +1742,294 @@ var swirl = {
|
|
|
1580
1742
|
};
|
|
1581
1743
|
|
|
1582
1744
|
// dist/passes/postprocessing/fxaa/fxaa.js
|
|
1745
|
+
var source20 = (
|
|
1746
|
+
/* wgsl */
|
|
1747
|
+
`fn fxaaSat(value: f32) -> f32 {
|
|
1748
|
+
return clamp(value, 0.0, 1.0);
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
fn fxaaTexTop(
|
|
1752
|
+
sourceTexture: texture_2d<f32>,
|
|
1753
|
+
sourceTextureSampler: sampler,
|
|
1754
|
+
texCoord: vec2f
|
|
1755
|
+
) -> vec4f {
|
|
1756
|
+
return textureSampleLevel(sourceTexture, sourceTextureSampler, texCoord, 0.0);
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
fn fxaaTexOff(
|
|
1760
|
+
sourceTexture: texture_2d<f32>,
|
|
1761
|
+
sourceTextureSampler: sampler,
|
|
1762
|
+
texCoord: vec2f,
|
|
1763
|
+
offset: vec2f,
|
|
1764
|
+
reciprocalFrame: vec2f
|
|
1765
|
+
) -> vec4f {
|
|
1766
|
+
return textureSampleLevel(
|
|
1767
|
+
sourceTexture,
|
|
1768
|
+
sourceTextureSampler,
|
|
1769
|
+
texCoord + offset * reciprocalFrame,
|
|
1770
|
+
0.0
|
|
1771
|
+
);
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
fn fxaaLuma(color: vec4f) -> f32 {
|
|
1775
|
+
return dot(color.rgb, vec3f(0.2126, 0.7152, 0.0722));
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
fn fxaaGetQualityStep(stepIndex: u32) -> f32 {
|
|
1779
|
+
switch (stepIndex) {
|
|
1780
|
+
case 0u: {
|
|
1781
|
+
return 1.0;
|
|
1782
|
+
}
|
|
1783
|
+
case 1u: {
|
|
1784
|
+
return 1.5;
|
|
1785
|
+
}
|
|
1786
|
+
case 2u: {
|
|
1787
|
+
return 2.0;
|
|
1788
|
+
}
|
|
1789
|
+
case 3u: {
|
|
1790
|
+
return 2.0;
|
|
1791
|
+
}
|
|
1792
|
+
case 4u: {
|
|
1793
|
+
return 2.0;
|
|
1794
|
+
}
|
|
1795
|
+
case 5u: {
|
|
1796
|
+
return 2.0;
|
|
1797
|
+
}
|
|
1798
|
+
case 6u: {
|
|
1799
|
+
return 2.0;
|
|
1800
|
+
}
|
|
1801
|
+
case 7u: {
|
|
1802
|
+
return 2.0;
|
|
1803
|
+
}
|
|
1804
|
+
case 8u: {
|
|
1805
|
+
return 2.0;
|
|
1806
|
+
}
|
|
1807
|
+
case 9u: {
|
|
1808
|
+
return 2.0;
|
|
1809
|
+
}
|
|
1810
|
+
case 10u: {
|
|
1811
|
+
return 4.0;
|
|
1812
|
+
}
|
|
1813
|
+
default: {
|
|
1814
|
+
return 8.0;
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
fn fxaaPixelShader(
|
|
1820
|
+
texCoord: vec2f,
|
|
1821
|
+
sourceTexture: texture_2d<f32>,
|
|
1822
|
+
sourceTextureSampler: sampler,
|
|
1823
|
+
reciprocalFrame: vec2f,
|
|
1824
|
+
qualitySubpix: f32,
|
|
1825
|
+
qualityEdgeThreshold: f32,
|
|
1826
|
+
qualityEdgeThresholdMin: f32
|
|
1827
|
+
) -> vec4f {
|
|
1828
|
+
var posM = texCoord;
|
|
1829
|
+
let rgbyM = fxaaTexTop(sourceTexture, sourceTextureSampler, posM);
|
|
1830
|
+
let lumaM = rgbyM.g;
|
|
1831
|
+
var lumaS = fxaaLuma(
|
|
1832
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(0.0, 1.0), reciprocalFrame)
|
|
1833
|
+
);
|
|
1834
|
+
let lumaE = fxaaLuma(
|
|
1835
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(1.0, 0.0), reciprocalFrame)
|
|
1836
|
+
);
|
|
1837
|
+
var lumaN = fxaaLuma(
|
|
1838
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(0.0, -1.0), reciprocalFrame)
|
|
1839
|
+
);
|
|
1840
|
+
let lumaW = fxaaLuma(
|
|
1841
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(-1.0, 0.0), reciprocalFrame)
|
|
1842
|
+
);
|
|
1843
|
+
|
|
1844
|
+
let maxSM = max(lumaS, lumaM);
|
|
1845
|
+
let minSM = min(lumaS, lumaM);
|
|
1846
|
+
let maxESM = max(lumaE, maxSM);
|
|
1847
|
+
let minESM = min(lumaE, minSM);
|
|
1848
|
+
let maxWN = max(lumaN, lumaW);
|
|
1849
|
+
let minWN = min(lumaN, lumaW);
|
|
1850
|
+
let rangeMax = max(maxWN, maxESM);
|
|
1851
|
+
let rangeMin = min(minWN, minESM);
|
|
1852
|
+
let rangeMaxScaled = rangeMax * qualityEdgeThreshold;
|
|
1853
|
+
let range = rangeMax - rangeMin;
|
|
1854
|
+
let rangeMaxClamped = max(qualityEdgeThresholdMin, rangeMaxScaled);
|
|
1855
|
+
if (range < rangeMaxClamped) {
|
|
1856
|
+
return rgbyM;
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
let lumaNW = fxaaLuma(
|
|
1860
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(-1.0, -1.0), reciprocalFrame)
|
|
1861
|
+
);
|
|
1862
|
+
let lumaSE = fxaaLuma(
|
|
1863
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(1.0, 1.0), reciprocalFrame)
|
|
1864
|
+
);
|
|
1865
|
+
let lumaNE = fxaaLuma(
|
|
1866
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(1.0, -1.0), reciprocalFrame)
|
|
1867
|
+
);
|
|
1868
|
+
let lumaSW = fxaaLuma(
|
|
1869
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(-1.0, 1.0), reciprocalFrame)
|
|
1870
|
+
);
|
|
1871
|
+
|
|
1872
|
+
let lumaNS = lumaN + lumaS;
|
|
1873
|
+
let lumaWE = lumaW + lumaE;
|
|
1874
|
+
let subpixReciprocalRange = 1.0 / range;
|
|
1875
|
+
let subpixNSWE = lumaNS + lumaWE;
|
|
1876
|
+
let edgeHorizontal1 = -2.0 * lumaM + lumaNS;
|
|
1877
|
+
let edgeVertical1 = -2.0 * lumaM + lumaWE;
|
|
1878
|
+
|
|
1879
|
+
let lumaNESE = lumaNE + lumaSE;
|
|
1880
|
+
let lumaNWNE = lumaNW + lumaNE;
|
|
1881
|
+
let edgeHorizontal2 = -2.0 * lumaE + lumaNESE;
|
|
1882
|
+
let edgeVertical2 = -2.0 * lumaN + lumaNWNE;
|
|
1883
|
+
|
|
1884
|
+
let lumaNWSW = lumaNW + lumaSW;
|
|
1885
|
+
let lumaSWSE = lumaSW + lumaSE;
|
|
1886
|
+
let edgeHorizontal4 = abs(edgeHorizontal1) * 2.0 + abs(edgeHorizontal2);
|
|
1887
|
+
let edgeVertical4 = abs(edgeVertical1) * 2.0 + abs(edgeVertical2);
|
|
1888
|
+
let edgeHorizontal3 = -2.0 * lumaW + lumaNWSW;
|
|
1889
|
+
let edgeVertical3 = -2.0 * lumaS + lumaSWSE;
|
|
1890
|
+
let edgeHorizontal = abs(edgeHorizontal3) + edgeHorizontal4;
|
|
1891
|
+
let edgeVertical = abs(edgeVertical3) + edgeVertical4;
|
|
1892
|
+
|
|
1893
|
+
let subpixNWSWNESE = lumaNWSW + lumaNESE;
|
|
1894
|
+
let horizontalSpan = edgeHorizontal >= edgeVertical;
|
|
1895
|
+
var lengthSign = reciprocalFrame.x;
|
|
1896
|
+
let subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;
|
|
1897
|
+
if (!horizontalSpan) {
|
|
1898
|
+
lumaN = lumaW;
|
|
1899
|
+
lumaS = lumaE;
|
|
1900
|
+
}
|
|
1901
|
+
if (horizontalSpan) {
|
|
1902
|
+
lengthSign = reciprocalFrame.y;
|
|
1903
|
+
}
|
|
1904
|
+
let subpixB = subpixA * (1.0 / 12.0) - lumaM;
|
|
1905
|
+
|
|
1906
|
+
let gradientN = lumaN - lumaM;
|
|
1907
|
+
let gradientS = lumaS - lumaM;
|
|
1908
|
+
var lumaNN = lumaN + lumaM;
|
|
1909
|
+
let lumaSS = lumaS + lumaM;
|
|
1910
|
+
let pairN = abs(gradientN) >= abs(gradientS);
|
|
1911
|
+
let gradient = max(abs(gradientN), abs(gradientS));
|
|
1912
|
+
if (pairN) {
|
|
1913
|
+
lengthSign = -lengthSign;
|
|
1914
|
+
}
|
|
1915
|
+
let subpixC = fxaaSat(abs(subpixB) * subpixReciprocalRange);
|
|
1916
|
+
|
|
1917
|
+
var posB = posM;
|
|
1918
|
+
var offNP = vec2f(0.0);
|
|
1919
|
+
if (horizontalSpan) {
|
|
1920
|
+
offNP = vec2f(reciprocalFrame.x, 0.0);
|
|
1921
|
+
posB.y += lengthSign * 0.5;
|
|
1922
|
+
} else {
|
|
1923
|
+
offNP = vec2f(0.0, reciprocalFrame.y);
|
|
1924
|
+
posB.x += lengthSign * 0.5;
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
var posN = posB - offNP * fxaaGetQualityStep(0u);
|
|
1928
|
+
var posP = posB + offNP * fxaaGetQualityStep(0u);
|
|
1929
|
+
let subpixD = -2.0 * subpixC + 3.0;
|
|
1930
|
+
var lumaEndN = fxaaLuma(fxaaTexTop(sourceTexture, sourceTextureSampler, posN));
|
|
1931
|
+
let subpixE = subpixC * subpixC;
|
|
1932
|
+
var lumaEndP = fxaaLuma(fxaaTexTop(sourceTexture, sourceTextureSampler, posP));
|
|
1933
|
+
|
|
1934
|
+
if (!pairN) {
|
|
1935
|
+
lumaNN = lumaSS;
|
|
1936
|
+
}
|
|
1937
|
+
let gradientScaled = gradient * 0.25;
|
|
1938
|
+
let lumaMM = lumaM - lumaNN * 0.5;
|
|
1939
|
+
let subpixF = subpixD * subpixE;
|
|
1940
|
+
let lumaMoreThanZero = lumaMM < 0.0;
|
|
1941
|
+
|
|
1942
|
+
lumaEndN -= lumaNN * 0.5;
|
|
1943
|
+
lumaEndP -= lumaNN * 0.5;
|
|
1944
|
+
var doneN = abs(lumaEndN) >= gradientScaled;
|
|
1945
|
+
var doneP = abs(lumaEndP) >= gradientScaled;
|
|
1946
|
+
var doneNP = !doneN || !doneP;
|
|
1947
|
+
var qualityStepIndex = 1u;
|
|
1948
|
+
loop {
|
|
1949
|
+
if (!(doneNP && qualityStepIndex < 12u)) {
|
|
1950
|
+
break;
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
let qualityStep = fxaaGetQualityStep(qualityStepIndex);
|
|
1954
|
+
if (!doneN) {
|
|
1955
|
+
posN -= offNP * qualityStep;
|
|
1956
|
+
}
|
|
1957
|
+
if (!doneP) {
|
|
1958
|
+
posP += offNP * qualityStep;
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
qualityStepIndex += 1u;
|
|
1962
|
+
if (qualityStepIndex >= 12u) {
|
|
1963
|
+
break;
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
if (!doneN) {
|
|
1967
|
+
lumaEndN = fxaaLuma(fxaaTexTop(sourceTexture, sourceTextureSampler, posN));
|
|
1968
|
+
lumaEndN -= lumaNN * 0.5;
|
|
1969
|
+
doneN = abs(lumaEndN) >= gradientScaled;
|
|
1970
|
+
}
|
|
1971
|
+
if (!doneP) {
|
|
1972
|
+
lumaEndP = fxaaLuma(fxaaTexTop(sourceTexture, sourceTextureSampler, posP));
|
|
1973
|
+
lumaEndP -= lumaNN * 0.5;
|
|
1974
|
+
doneP = abs(lumaEndP) >= gradientScaled;
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
doneNP = !doneN || !doneP;
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
var dstN = posM.x - posN.x;
|
|
1981
|
+
var dstP = posP.x - posM.x;
|
|
1982
|
+
if (!horizontalSpan) {
|
|
1983
|
+
dstN = posM.y - posN.y;
|
|
1984
|
+
dstP = posP.y - posM.y;
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
let goodSpanN = (lumaEndN < 0.0) != lumaMoreThanZero;
|
|
1988
|
+
let spanLength = dstP + dstN;
|
|
1989
|
+
let goodSpanP = (lumaEndP < 0.0) != lumaMoreThanZero;
|
|
1990
|
+
let spanLengthReciprocal = 1.0 / spanLength;
|
|
1991
|
+
|
|
1992
|
+
let directionN = dstN < dstP;
|
|
1993
|
+
let dst = min(dstN, dstP);
|
|
1994
|
+
let goodSpan = select(goodSpanP, goodSpanN, directionN);
|
|
1995
|
+
let subpixG = subpixF * subpixF;
|
|
1996
|
+
let pixelOffset = dst * -spanLengthReciprocal + 0.5;
|
|
1997
|
+
let subpixH = subpixG * qualitySubpix;
|
|
1998
|
+
|
|
1999
|
+
let pixelOffsetGood = select(0.0, pixelOffset, goodSpan);
|
|
2000
|
+
let pixelOffsetSubpix = max(pixelOffsetGood, subpixH);
|
|
2001
|
+
if (!horizontalSpan) {
|
|
2002
|
+
posM.x += pixelOffsetSubpix * lengthSign;
|
|
2003
|
+
}
|
|
2004
|
+
if (horizontalSpan) {
|
|
2005
|
+
posM.y += pixelOffsetSubpix * lengthSign;
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
return fxaaTexTop(sourceTexture, sourceTextureSampler, posM);
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
fn fxaa_sampleColor(
|
|
2012
|
+
sourceTexture: texture_2d<f32>,
|
|
2013
|
+
sourceTextureSampler: sampler,
|
|
2014
|
+
texSize: vec2f,
|
|
2015
|
+
texCoord: vec2f
|
|
2016
|
+
) -> vec4f {
|
|
2017
|
+
let qualitySubpix = 0.5;
|
|
2018
|
+
let qualityEdgeThreshold = 0.125;
|
|
2019
|
+
let qualityEdgeThresholdMin = 0.0833;
|
|
2020
|
+
|
|
2021
|
+
return fxaaPixelShader(
|
|
2022
|
+
texCoord,
|
|
2023
|
+
sourceTexture,
|
|
2024
|
+
sourceTextureSampler,
|
|
2025
|
+
vec2f(1.0) / texSize,
|
|
2026
|
+
qualitySubpix,
|
|
2027
|
+
qualityEdgeThreshold,
|
|
2028
|
+
qualityEdgeThresholdMin
|
|
2029
|
+
);
|
|
2030
|
+
}
|
|
2031
|
+
`
|
|
2032
|
+
);
|
|
1583
2033
|
var fs20 = (
|
|
1584
2034
|
/* glsl */
|
|
1585
2035
|
`
|
|
@@ -2167,6 +2617,7 @@ vec4 fxaa_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
2167
2617
|
var fxaa = {
|
|
2168
2618
|
name: "fxaa",
|
|
2169
2619
|
propTypes: {},
|
|
2620
|
+
source: source20,
|
|
2170
2621
|
fs: fs20,
|
|
2171
2622
|
passes: [{ sampler: true }],
|
|
2172
2623
|
getUniforms: (props) => props
|