@luma.gl/effects 9.2.6 → 9.3.0-alpha.11
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 +2734 -644
- 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
|
@@ -97,6 +97,293 @@ import type {ShaderPass} from '@luma.gl/shadertools';
|
|
|
97
97
|
// _ = the highest digit is directly related to style
|
|
98
98
|
//
|
|
99
99
|
|
|
100
|
+
const source = /* wgsl */ `\
|
|
101
|
+
fn fxaaSat(value: f32) -> f32 {
|
|
102
|
+
return clamp(value, 0.0, 1.0);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
fn fxaaTexTop(
|
|
106
|
+
sourceTexture: texture_2d<f32>,
|
|
107
|
+
sourceTextureSampler: sampler,
|
|
108
|
+
texCoord: vec2f
|
|
109
|
+
) -> vec4f {
|
|
110
|
+
return textureSampleLevel(sourceTexture, sourceTextureSampler, texCoord, 0.0);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
fn fxaaTexOff(
|
|
114
|
+
sourceTexture: texture_2d<f32>,
|
|
115
|
+
sourceTextureSampler: sampler,
|
|
116
|
+
texCoord: vec2f,
|
|
117
|
+
offset: vec2f,
|
|
118
|
+
reciprocalFrame: vec2f
|
|
119
|
+
) -> vec4f {
|
|
120
|
+
return textureSampleLevel(
|
|
121
|
+
sourceTexture,
|
|
122
|
+
sourceTextureSampler,
|
|
123
|
+
texCoord + offset * reciprocalFrame,
|
|
124
|
+
0.0
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
fn fxaaLuma(color: vec4f) -> f32 {
|
|
129
|
+
return dot(color.rgb, vec3f(0.2126, 0.7152, 0.0722));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
fn fxaaGetQualityStep(stepIndex: u32) -> f32 {
|
|
133
|
+
switch (stepIndex) {
|
|
134
|
+
case 0u: {
|
|
135
|
+
return 1.0;
|
|
136
|
+
}
|
|
137
|
+
case 1u: {
|
|
138
|
+
return 1.5;
|
|
139
|
+
}
|
|
140
|
+
case 2u: {
|
|
141
|
+
return 2.0;
|
|
142
|
+
}
|
|
143
|
+
case 3u: {
|
|
144
|
+
return 2.0;
|
|
145
|
+
}
|
|
146
|
+
case 4u: {
|
|
147
|
+
return 2.0;
|
|
148
|
+
}
|
|
149
|
+
case 5u: {
|
|
150
|
+
return 2.0;
|
|
151
|
+
}
|
|
152
|
+
case 6u: {
|
|
153
|
+
return 2.0;
|
|
154
|
+
}
|
|
155
|
+
case 7u: {
|
|
156
|
+
return 2.0;
|
|
157
|
+
}
|
|
158
|
+
case 8u: {
|
|
159
|
+
return 2.0;
|
|
160
|
+
}
|
|
161
|
+
case 9u: {
|
|
162
|
+
return 2.0;
|
|
163
|
+
}
|
|
164
|
+
case 10u: {
|
|
165
|
+
return 4.0;
|
|
166
|
+
}
|
|
167
|
+
default: {
|
|
168
|
+
return 8.0;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
fn fxaaPixelShader(
|
|
174
|
+
texCoord: vec2f,
|
|
175
|
+
sourceTexture: texture_2d<f32>,
|
|
176
|
+
sourceTextureSampler: sampler,
|
|
177
|
+
reciprocalFrame: vec2f,
|
|
178
|
+
qualitySubpix: f32,
|
|
179
|
+
qualityEdgeThreshold: f32,
|
|
180
|
+
qualityEdgeThresholdMin: f32
|
|
181
|
+
) -> vec4f {
|
|
182
|
+
var posM = texCoord;
|
|
183
|
+
let rgbyM = fxaaTexTop(sourceTexture, sourceTextureSampler, posM);
|
|
184
|
+
let lumaM = rgbyM.g;
|
|
185
|
+
var lumaS = fxaaLuma(
|
|
186
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(0.0, 1.0), reciprocalFrame)
|
|
187
|
+
);
|
|
188
|
+
let lumaE = fxaaLuma(
|
|
189
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(1.0, 0.0), reciprocalFrame)
|
|
190
|
+
);
|
|
191
|
+
var lumaN = fxaaLuma(
|
|
192
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(0.0, -1.0), reciprocalFrame)
|
|
193
|
+
);
|
|
194
|
+
let lumaW = fxaaLuma(
|
|
195
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(-1.0, 0.0), reciprocalFrame)
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
let maxSM = max(lumaS, lumaM);
|
|
199
|
+
let minSM = min(lumaS, lumaM);
|
|
200
|
+
let maxESM = max(lumaE, maxSM);
|
|
201
|
+
let minESM = min(lumaE, minSM);
|
|
202
|
+
let maxWN = max(lumaN, lumaW);
|
|
203
|
+
let minWN = min(lumaN, lumaW);
|
|
204
|
+
let rangeMax = max(maxWN, maxESM);
|
|
205
|
+
let rangeMin = min(minWN, minESM);
|
|
206
|
+
let rangeMaxScaled = rangeMax * qualityEdgeThreshold;
|
|
207
|
+
let range = rangeMax - rangeMin;
|
|
208
|
+
let rangeMaxClamped = max(qualityEdgeThresholdMin, rangeMaxScaled);
|
|
209
|
+
if (range < rangeMaxClamped) {
|
|
210
|
+
return rgbyM;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
let lumaNW = fxaaLuma(
|
|
214
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(-1.0, -1.0), reciprocalFrame)
|
|
215
|
+
);
|
|
216
|
+
let lumaSE = fxaaLuma(
|
|
217
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(1.0, 1.0), reciprocalFrame)
|
|
218
|
+
);
|
|
219
|
+
let lumaNE = fxaaLuma(
|
|
220
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(1.0, -1.0), reciprocalFrame)
|
|
221
|
+
);
|
|
222
|
+
let lumaSW = fxaaLuma(
|
|
223
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(-1.0, 1.0), reciprocalFrame)
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
let lumaNS = lumaN + lumaS;
|
|
227
|
+
let lumaWE = lumaW + lumaE;
|
|
228
|
+
let subpixReciprocalRange = 1.0 / range;
|
|
229
|
+
let subpixNSWE = lumaNS + lumaWE;
|
|
230
|
+
let edgeHorizontal1 = -2.0 * lumaM + lumaNS;
|
|
231
|
+
let edgeVertical1 = -2.0 * lumaM + lumaWE;
|
|
232
|
+
|
|
233
|
+
let lumaNESE = lumaNE + lumaSE;
|
|
234
|
+
let lumaNWNE = lumaNW + lumaNE;
|
|
235
|
+
let edgeHorizontal2 = -2.0 * lumaE + lumaNESE;
|
|
236
|
+
let edgeVertical2 = -2.0 * lumaN + lumaNWNE;
|
|
237
|
+
|
|
238
|
+
let lumaNWSW = lumaNW + lumaSW;
|
|
239
|
+
let lumaSWSE = lumaSW + lumaSE;
|
|
240
|
+
let edgeHorizontal4 = abs(edgeHorizontal1) * 2.0 + abs(edgeHorizontal2);
|
|
241
|
+
let edgeVertical4 = abs(edgeVertical1) * 2.0 + abs(edgeVertical2);
|
|
242
|
+
let edgeHorizontal3 = -2.0 * lumaW + lumaNWSW;
|
|
243
|
+
let edgeVertical3 = -2.0 * lumaS + lumaSWSE;
|
|
244
|
+
let edgeHorizontal = abs(edgeHorizontal3) + edgeHorizontal4;
|
|
245
|
+
let edgeVertical = abs(edgeVertical3) + edgeVertical4;
|
|
246
|
+
|
|
247
|
+
let subpixNWSWNESE = lumaNWSW + lumaNESE;
|
|
248
|
+
let horizontalSpan = edgeHorizontal >= edgeVertical;
|
|
249
|
+
var lengthSign = reciprocalFrame.x;
|
|
250
|
+
let subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;
|
|
251
|
+
if (!horizontalSpan) {
|
|
252
|
+
lumaN = lumaW;
|
|
253
|
+
lumaS = lumaE;
|
|
254
|
+
}
|
|
255
|
+
if (horizontalSpan) {
|
|
256
|
+
lengthSign = reciprocalFrame.y;
|
|
257
|
+
}
|
|
258
|
+
let subpixB = subpixA * (1.0 / 12.0) - lumaM;
|
|
259
|
+
|
|
260
|
+
let gradientN = lumaN - lumaM;
|
|
261
|
+
let gradientS = lumaS - lumaM;
|
|
262
|
+
var lumaNN = lumaN + lumaM;
|
|
263
|
+
let lumaSS = lumaS + lumaM;
|
|
264
|
+
let pairN = abs(gradientN) >= abs(gradientS);
|
|
265
|
+
let gradient = max(abs(gradientN), abs(gradientS));
|
|
266
|
+
if (pairN) {
|
|
267
|
+
lengthSign = -lengthSign;
|
|
268
|
+
}
|
|
269
|
+
let subpixC = fxaaSat(abs(subpixB) * subpixReciprocalRange);
|
|
270
|
+
|
|
271
|
+
var posB = posM;
|
|
272
|
+
var offNP = vec2f(0.0);
|
|
273
|
+
if (horizontalSpan) {
|
|
274
|
+
offNP = vec2f(reciprocalFrame.x, 0.0);
|
|
275
|
+
posB.y += lengthSign * 0.5;
|
|
276
|
+
} else {
|
|
277
|
+
offNP = vec2f(0.0, reciprocalFrame.y);
|
|
278
|
+
posB.x += lengthSign * 0.5;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
var posN = posB - offNP * fxaaGetQualityStep(0u);
|
|
282
|
+
var posP = posB + offNP * fxaaGetQualityStep(0u);
|
|
283
|
+
let subpixD = -2.0 * subpixC + 3.0;
|
|
284
|
+
var lumaEndN = fxaaLuma(fxaaTexTop(sourceTexture, sourceTextureSampler, posN));
|
|
285
|
+
let subpixE = subpixC * subpixC;
|
|
286
|
+
var lumaEndP = fxaaLuma(fxaaTexTop(sourceTexture, sourceTextureSampler, posP));
|
|
287
|
+
|
|
288
|
+
if (!pairN) {
|
|
289
|
+
lumaNN = lumaSS;
|
|
290
|
+
}
|
|
291
|
+
let gradientScaled = gradient * 0.25;
|
|
292
|
+
let lumaMM = lumaM - lumaNN * 0.5;
|
|
293
|
+
let subpixF = subpixD * subpixE;
|
|
294
|
+
let lumaMoreThanZero = lumaMM < 0.0;
|
|
295
|
+
|
|
296
|
+
lumaEndN -= lumaNN * 0.5;
|
|
297
|
+
lumaEndP -= lumaNN * 0.5;
|
|
298
|
+
var doneN = abs(lumaEndN) >= gradientScaled;
|
|
299
|
+
var doneP = abs(lumaEndP) >= gradientScaled;
|
|
300
|
+
var doneNP = !doneN || !doneP;
|
|
301
|
+
var qualityStepIndex = 1u;
|
|
302
|
+
loop {
|
|
303
|
+
if (!(doneNP && qualityStepIndex < 12u)) {
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
let qualityStep = fxaaGetQualityStep(qualityStepIndex);
|
|
308
|
+
if (!doneN) {
|
|
309
|
+
posN -= offNP * qualityStep;
|
|
310
|
+
}
|
|
311
|
+
if (!doneP) {
|
|
312
|
+
posP += offNP * qualityStep;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
qualityStepIndex += 1u;
|
|
316
|
+
if (qualityStepIndex >= 12u) {
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (!doneN) {
|
|
321
|
+
lumaEndN = fxaaLuma(fxaaTexTop(sourceTexture, sourceTextureSampler, posN));
|
|
322
|
+
lumaEndN -= lumaNN * 0.5;
|
|
323
|
+
doneN = abs(lumaEndN) >= gradientScaled;
|
|
324
|
+
}
|
|
325
|
+
if (!doneP) {
|
|
326
|
+
lumaEndP = fxaaLuma(fxaaTexTop(sourceTexture, sourceTextureSampler, posP));
|
|
327
|
+
lumaEndP -= lumaNN * 0.5;
|
|
328
|
+
doneP = abs(lumaEndP) >= gradientScaled;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
doneNP = !doneN || !doneP;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
var dstN = posM.x - posN.x;
|
|
335
|
+
var dstP = posP.x - posM.x;
|
|
336
|
+
if (!horizontalSpan) {
|
|
337
|
+
dstN = posM.y - posN.y;
|
|
338
|
+
dstP = posP.y - posM.y;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
let goodSpanN = (lumaEndN < 0.0) != lumaMoreThanZero;
|
|
342
|
+
let spanLength = dstP + dstN;
|
|
343
|
+
let goodSpanP = (lumaEndP < 0.0) != lumaMoreThanZero;
|
|
344
|
+
let spanLengthReciprocal = 1.0 / spanLength;
|
|
345
|
+
|
|
346
|
+
let directionN = dstN < dstP;
|
|
347
|
+
let dst = min(dstN, dstP);
|
|
348
|
+
let goodSpan = select(goodSpanP, goodSpanN, directionN);
|
|
349
|
+
let subpixG = subpixF * subpixF;
|
|
350
|
+
let pixelOffset = dst * -spanLengthReciprocal + 0.5;
|
|
351
|
+
let subpixH = subpixG * qualitySubpix;
|
|
352
|
+
|
|
353
|
+
let pixelOffsetGood = select(0.0, pixelOffset, goodSpan);
|
|
354
|
+
let pixelOffsetSubpix = max(pixelOffsetGood, subpixH);
|
|
355
|
+
if (!horizontalSpan) {
|
|
356
|
+
posM.x += pixelOffsetSubpix * lengthSign;
|
|
357
|
+
}
|
|
358
|
+
if (horizontalSpan) {
|
|
359
|
+
posM.y += pixelOffsetSubpix * lengthSign;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return fxaaTexTop(sourceTexture, sourceTextureSampler, posM);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
fn fxaa_sampleColor(
|
|
366
|
+
sourceTexture: texture_2d<f32>,
|
|
367
|
+
sourceTextureSampler: sampler,
|
|
368
|
+
texSize: vec2f,
|
|
369
|
+
texCoord: vec2f
|
|
370
|
+
) -> vec4f {
|
|
371
|
+
let qualitySubpix = 0.5;
|
|
372
|
+
let qualityEdgeThreshold = 0.125;
|
|
373
|
+
let qualityEdgeThresholdMin = 0.0833;
|
|
374
|
+
|
|
375
|
+
return fxaaPixelShader(
|
|
376
|
+
texCoord,
|
|
377
|
+
sourceTexture,
|
|
378
|
+
sourceTextureSampler,
|
|
379
|
+
vec2f(1.0) / texSize,
|
|
380
|
+
qualitySubpix,
|
|
381
|
+
qualityEdgeThreshold,
|
|
382
|
+
qualityEdgeThresholdMin
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
`;
|
|
386
|
+
|
|
100
387
|
const fs = /* glsl */ `
|
|
101
388
|
#define FXAA_QUALITY_PRESET 29
|
|
102
389
|
|
|
@@ -688,6 +975,7 @@ export type FXAAUniforms = {};
|
|
|
688
975
|
export const fxaa = {
|
|
689
976
|
name: 'fxaa',
|
|
690
977
|
propTypes: {},
|
|
978
|
+
source,
|
|
691
979
|
fs,
|
|
692
980
|
passes: [{sampler: true}],
|
|
693
981
|
getUniforms: props => props
|
|
@@ -10,22 +10,21 @@ struct brightnessContrastUniforms {
|
|
|
10
10
|
contrast: f32
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
@group(0) @binding(1) var<uniform> brightnessContrast : brightnessContrastUniforms;
|
|
13
|
+
@group(0) @binding(auto) var<uniform> brightnessContrast : brightnessContrastUniforms;
|
|
15
14
|
|
|
16
15
|
fn brightnessContrast_filterColor_ext(color: vec4f, texSize: vec2<f32>, texCoords: vec2<f32>) -> vec4f {
|
|
17
|
-
color.rgb
|
|
16
|
+
var resultRgb = color.rgb + vec3f(brightnessContrast.brightness);
|
|
18
17
|
if (brightnessContrast.contrast > 0.0) {
|
|
19
|
-
|
|
18
|
+
resultRgb = (resultRgb - vec3f(0.5)) / (1.0 - brightnessContrast.contrast) + vec3f(0.5);
|
|
20
19
|
} else {
|
|
21
|
-
|
|
20
|
+
resultRgb = (resultRgb - vec3f(0.5)) * (1.0 + brightnessContrast.contrast) + vec3f(0.5);
|
|
22
21
|
}
|
|
23
|
-
return vec4f(
|
|
22
|
+
return vec4f(resultRgb, color.a);
|
|
24
23
|
}
|
|
25
24
|
`;
|
|
26
25
|
|
|
27
26
|
const fs = /* glsl */ `\
|
|
28
|
-
uniform brightnessContrastUniforms {
|
|
27
|
+
layout(std140) uniform brightnessContrastUniforms {
|
|
29
28
|
float brightness;
|
|
30
29
|
float contrast;
|
|
31
30
|
} brightnessContrast;
|
|
@@ -6,42 +6,50 @@ import type {ShaderPass} from '@luma.gl/shadertools';
|
|
|
6
6
|
|
|
7
7
|
// Do a 9x9 bilateral box filter
|
|
8
8
|
const source = /* wgsl */ `\
|
|
9
|
-
|
|
10
9
|
struct denoiseUniforms {
|
|
11
|
-
strength: f32
|
|
10
|
+
strength: f32,
|
|
12
11
|
};
|
|
13
12
|
|
|
14
|
-
@group(0)
|
|
15
|
-
|
|
16
|
-
fn denoise_sampleColor(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
13
|
+
@group(0) @binding(auto) var<uniform> denoise: denoiseUniforms;
|
|
14
|
+
|
|
15
|
+
fn denoise_sampleColor(
|
|
16
|
+
sourceTexture: texture_2d<f32>,
|
|
17
|
+
sourceTextureSampler: sampler,
|
|
18
|
+
texSize: vec2f,
|
|
19
|
+
texCoord: vec2f
|
|
20
|
+
) -> vec4f {
|
|
21
|
+
let adjustedExponent = 3.0 + 200.0 * pow(1.0 - denoise.strength, 4.0);
|
|
22
|
+
let center = textureSample(sourceTexture, sourceTextureSampler, texCoord);
|
|
23
|
+
var color = vec4f(0.0);
|
|
24
|
+
var total = 0.0;
|
|
25
|
+
|
|
26
|
+
for (var x = -4.0; x <= 4.0; x += 1.0) {
|
|
27
|
+
for (var y = -4.0; y <= 4.0; y += 1.0) {
|
|
28
|
+
let offsetColor = textureSample(
|
|
29
|
+
sourceTexture,
|
|
30
|
+
sourceTextureSampler,
|
|
31
|
+
texCoord + vec2f(x, y) / texSize
|
|
32
|
+
);
|
|
33
|
+
let weight = pow(
|
|
34
|
+
1.0 - abs(dot(offsetColor.rgb - center.rgb, vec3f(0.25))),
|
|
35
|
+
adjustedExponent
|
|
36
|
+
);
|
|
37
|
+
color += offsetColor * weight;
|
|
38
|
+
total += weight;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
33
41
|
|
|
34
|
-
|
|
35
|
-
}
|
|
42
|
+
return color / total;
|
|
43
|
+
}
|
|
36
44
|
`;
|
|
37
45
|
|
|
38
46
|
const fs = /* glsl */ `\
|
|
39
|
-
uniform
|
|
47
|
+
layout(std140) uniform denoiseUniforms {
|
|
40
48
|
float strength;
|
|
41
49
|
} denoise;
|
|
42
50
|
|
|
43
|
-
vec4
|
|
44
|
-
float adjustedExponent = 3. + 200. * pow(1. -
|
|
51
|
+
vec4 denoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
52
|
+
float adjustedExponent = 3. + 200. * pow(1. - denoise.strength, 4.);
|
|
45
53
|
|
|
46
54
|
vec4 center = texture(source, texCoord);
|
|
47
55
|
vec4 color = vec4(0.0);
|
|
@@ -5,49 +5,42 @@
|
|
|
5
5
|
import type {ShaderPass} from '@luma.gl/shadertools';
|
|
6
6
|
|
|
7
7
|
const source = /* wgsl */ `\
|
|
8
|
-
|
|
9
8
|
struct hueSaturationUniforms {
|
|
10
9
|
hue: f32,
|
|
11
10
|
saturation: f32,
|
|
12
11
|
};
|
|
13
12
|
|
|
14
|
-
@group(0)
|
|
15
|
-
|
|
16
|
-
fn hueSaturation_filterColor(color:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return color;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
fn hueSaturation_filterColor_ext(color: vec4<f32>, texSize: vec2<f32>, texCoord: vec2<f32>) -> vec4<f32> {
|
|
45
|
-
return hueSaturation_filterColor(color);
|
|
46
|
-
}
|
|
13
|
+
@group(0) @binding(auto) var<uniform> hueSaturation: hueSaturationUniforms;
|
|
14
|
+
|
|
15
|
+
fn hueSaturation_filterColor(color: vec4f) -> vec4f {
|
|
16
|
+
let angle = hueSaturation.hue * 3.14159265;
|
|
17
|
+
let s = sin(angle);
|
|
18
|
+
let c = cos(angle);
|
|
19
|
+
let weights = (vec3f(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + vec3f(1.0)) / 3.0;
|
|
20
|
+
|
|
21
|
+
var resultRgb = vec3f(
|
|
22
|
+
dot(color.rgb, weights.xyz),
|
|
23
|
+
dot(color.rgb, weights.zxy),
|
|
24
|
+
dot(color.rgb, weights.yzx)
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
let average = (resultRgb.r + resultRgb.g + resultRgb.b) / 3.0;
|
|
28
|
+
if (hueSaturation.saturation > 0.0) {
|
|
29
|
+
resultRgb += (vec3f(average) - resultRgb) * (1.0 - 1.0 / (1.001 - hueSaturation.saturation));
|
|
30
|
+
} else {
|
|
31
|
+
resultRgb += (vec3f(average) - resultRgb) * (-hueSaturation.saturation);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return vec4f(resultRgb, color.a);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
fn hueSaturation_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
38
|
+
return hueSaturation_filterColor(color);
|
|
39
|
+
}
|
|
47
40
|
`;
|
|
48
41
|
|
|
49
42
|
const fs = /* glsl */ `\
|
|
50
|
-
uniform hueSaturationUniforms {
|
|
43
|
+
layout(std140) uniform hueSaturationUniforms {
|
|
51
44
|
float hue;
|
|
52
45
|
float saturation;
|
|
53
46
|
} hueSaturation;
|
|
@@ -6,26 +6,27 @@ import type {ShaderPass} from '@luma.gl/shadertools';
|
|
|
6
6
|
|
|
7
7
|
const source = /* wgsl */ `\
|
|
8
8
|
struct noiseUniforms {
|
|
9
|
-
amount: f32
|
|
9
|
+
amount: f32,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
@group(0) @binding(
|
|
12
|
+
@group(0) @binding(auto) var<uniform> noise: noiseUniforms;
|
|
13
13
|
|
|
14
14
|
fn rand(co: vec2f) -> f32 {
|
|
15
15
|
return fract(sin(dot(co.xy, vec2f(12.9898, 78.233))) * 43758.547);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
fn noise_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
let diff = (rand(texCoord) - 0.5) * noise.amount;
|
|
20
|
+
var result = color;
|
|
21
|
+
result.r += diff;
|
|
22
|
+
result.g += diff;
|
|
23
|
+
result.b += diff;
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
25
26
|
`;
|
|
26
27
|
|
|
27
28
|
const fs = /* glsl */ `\
|
|
28
|
-
uniform noiseUniforms {
|
|
29
|
+
layout(std140) uniform noiseUniforms {
|
|
29
30
|
float amount;
|
|
30
31
|
} noise;
|
|
31
32
|
|
|
@@ -6,31 +6,32 @@ import type {ShaderPass} from '@luma.gl/shadertools';
|
|
|
6
6
|
|
|
7
7
|
const source = /* wgsl */ `\
|
|
8
8
|
struct sepiaUniforms {
|
|
9
|
-
amount: f32
|
|
9
|
+
amount: f32,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
@group(0) @binding(
|
|
12
|
+
@group(0) @binding(auto) var<uniform> sepia: sepiaUniforms;
|
|
13
13
|
|
|
14
14
|
fn sepia_filterColor(color: vec4f) -> vec4f {
|
|
15
|
-
let r
|
|
16
|
-
let g
|
|
17
|
-
let b
|
|
15
|
+
let r = color.r;
|
|
16
|
+
let g = color.g;
|
|
17
|
+
let b = color.b;
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
var result = color;
|
|
20
|
+
result.r =
|
|
20
21
|
min(1.0, (r * (1.0 - (0.607 * sepia.amount))) + (g * (0.769 * sepia.amount)) + (b * (0.189 * sepia.amount)));
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
result.g = min(1.0, (r * 0.349 * sepia.amount) + (g * (1.0 - (0.314 * sepia.amount))) + (b * 0.168 * sepia.amount));
|
|
23
|
+
result.b = min(1.0, (r * 0.272 * sepia.amount) + (g * 0.534 * sepia.amount) + (b * (1.0 - (0.869 * sepia.amount))));
|
|
23
24
|
|
|
24
|
-
return
|
|
25
|
+
return result;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
fn sepia_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
28
29
|
return sepia_filterColor(color);
|
|
29
30
|
}
|
|
30
31
|
`;
|
|
31
32
|
|
|
32
33
|
const fs = /* glsl */ `\
|
|
33
|
-
uniform sepiaUniforms {
|
|
34
|
+
layout(std140) uniform sepiaUniforms {
|
|
34
35
|
float amount;
|
|
35
36
|
} sepia;
|
|
36
37
|
|
|
@@ -6,26 +6,26 @@ import type {ShaderPass} from '@luma.gl/shadertools';
|
|
|
6
6
|
|
|
7
7
|
const source = /* wgsl */ `\
|
|
8
8
|
struct vibranceUniforms {
|
|
9
|
-
amount: f32
|
|
9
|
+
amount: f32,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
@group(0) @binding(
|
|
12
|
+
@group(0) @binding(auto) var<uniform> vibrance: vibranceUniforms;
|
|
13
13
|
|
|
14
|
-
fn vibrance_filterColor(vec4f
|
|
15
|
-
let average
|
|
16
|
-
let mx
|
|
17
|
-
let amt
|
|
18
|
-
|
|
19
|
-
return color;
|
|
14
|
+
fn vibrance_filterColor(color: vec4f) -> vec4f {
|
|
15
|
+
let average = (color.r + color.g + color.b) / 3.0;
|
|
16
|
+
let mx = max(color.r, max(color.g, color.b));
|
|
17
|
+
let amt = (mx - average) * (-vibrance.amount * 3.0);
|
|
18
|
+
let resultRgb = mix(color.rgb, vec3f(mx), amt);
|
|
19
|
+
return vec4f(resultRgb, color.a);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
fn vibrance_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
23
23
|
return vibrance_filterColor(color);
|
|
24
24
|
}
|
|
25
25
|
`;
|
|
26
26
|
|
|
27
27
|
const fs = /* glsl */ `\
|
|
28
|
-
uniform vibranceUniforms {
|
|
28
|
+
layout(std140) uniform vibranceUniforms {
|
|
29
29
|
float amount;
|
|
30
30
|
} vibrance;
|
|
31
31
|
|
|
@@ -7,28 +7,24 @@ import type {ShaderPass} from '@luma.gl/shadertools';
|
|
|
7
7
|
const source = /* wgsl */ `\
|
|
8
8
|
struct vignetteUniforms {
|
|
9
9
|
radius: f32,
|
|
10
|
-
amount: f32
|
|
10
|
+
amount: f32,
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
@group(0) @binding(
|
|
13
|
+
@group(0) @binding(auto) var<uniform> vignette: vignetteUniforms;
|
|
14
14
|
|
|
15
|
-
fn
|
|
16
|
-
let
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
fn vignette_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) ->vec4f {
|
|
24
|
-
let dist: f32 = distance(texCoord, vec2f(0.5, 0.5));
|
|
25
|
-
let ratio: f32 = smoothstep(0.8, vignette.radius * 0.799, dist * (vignette.amount + vignette.radius));
|
|
26
|
-
return color.rgba * ratio + (1.0 - ratio)*vec4f(0.0, 0.0, 0.0, 1.0);
|
|
15
|
+
fn vignette_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
16
|
+
let dist = distance(texCoord, vec2f(0.5, 0.5));
|
|
17
|
+
let ratio = smoothstep(
|
|
18
|
+
0.8,
|
|
19
|
+
vignette.radius * 0.799,
|
|
20
|
+
dist * (vignette.amount + vignette.radius)
|
|
21
|
+
);
|
|
22
|
+
return color * ratio + vec4f(0.0, 0.0, 0.0, 1.0) * (1.0 - ratio);
|
|
27
23
|
}
|
|
28
24
|
`;
|
|
29
25
|
|
|
30
26
|
const fs = /* glsl */ `\
|
|
31
|
-
uniform vignetteUniforms {
|
|
27
|
+
layout(std140) uniform vignetteUniforms {
|
|
32
28
|
float radius;
|
|
33
29
|
float amount;
|
|
34
30
|
} vignette;
|