@ludicon/spark.js 0.0.14 → 0.0.15
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/spark.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const V = /* @__PURE__ */ Object.assign({ "./spark_astc_rgb.wgsl": () => import("./spark_astc_rgb-DaSIMKXW.js"), "./spark_astc_rgba.wgsl": () => import("./spark_astc_rgba-BToA2Rcq.js"), "./spark_bc1_rgb.wgsl": () => import("./spark_bc1_rgb-DZwuM1tO.js"), "./spark_bc4_r.wgsl": () => import("./spark_bc4_r-DjThizCH.js"), "./spark_bc5_rg.wgsl": () => import("./spark_bc5_rg-6bO0Gvo9.js"), "./spark_bc7_rgb.wgsl": () => import("./spark_bc7_rgb-FXpBw9fE.js"), "./spark_bc7_rgba.wgsl": () => import("./spark_bc7_rgba-C8Hi2pUY.js"), "./spark_eac_r.wgsl": () => import("./spark_eac_r-D8HGiglc.js"), "./spark_eac_rg.wgsl": () => import("./spark_eac_rg-DvsrLP9h.js"), "./spark_etc2_rgb.wgsl": () => import("./spark_etc2_rgb-C-j5FZpn.js"), "./utils.wgsl": () => import("./utils-
|
|
2
|
-
Object.entries(V).map(([
|
|
1
|
+
const V = /* @__PURE__ */ Object.assign({ "./spark_astc_rgb.wgsl": () => import("./spark_astc_rgb-DaSIMKXW.js"), "./spark_astc_rgba.wgsl": () => import("./spark_astc_rgba-BToA2Rcq.js"), "./spark_bc1_rgb.wgsl": () => import("./spark_bc1_rgb-DZwuM1tO.js"), "./spark_bc4_r.wgsl": () => import("./spark_bc4_r-DjThizCH.js"), "./spark_bc5_rg.wgsl": () => import("./spark_bc5_rg-6bO0Gvo9.js"), "./spark_bc7_rgb.wgsl": () => import("./spark_bc7_rgb-FXpBw9fE.js"), "./spark_bc7_rgba.wgsl": () => import("./spark_bc7_rgba-C8Hi2pUY.js"), "./spark_eac_r.wgsl": () => import("./spark_eac_r-D8HGiglc.js"), "./spark_eac_rg.wgsl": () => import("./spark_eac_rg-DvsrLP9h.js"), "./spark_etc2_rgb.wgsl": () => import("./spark_etc2_rgb-C-j5FZpn.js"), "./utils.wgsl": () => import("./utils-_0JXKkpk.js") }), I = Object.fromEntries(
|
|
2
|
+
Object.entries(V).map(([u, e]) => [u.replace("./", ""), async () => (await e()).default])
|
|
3
3
|
), i = {
|
|
4
4
|
ASTC_4x4_RGB: 0,
|
|
5
5
|
ASTC_4x4_RGBA: 1,
|
|
@@ -329,26 +329,29 @@ const V = /* @__PURE__ */ Object.assign({ "./spark_astc_rgb.wgsl": () => import(
|
|
|
329
329
|
!0
|
|
330
330
|
// BC7_RGB
|
|
331
331
|
];
|
|
332
|
-
function w(
|
|
333
|
-
if (!
|
|
332
|
+
function w(u, e) {
|
|
333
|
+
if (!u)
|
|
334
334
|
throw new Error(e);
|
|
335
335
|
}
|
|
336
|
-
function H(
|
|
337
|
-
return typeof GPUDevice < "u" &&
|
|
336
|
+
function H(u) {
|
|
337
|
+
return typeof GPUDevice < "u" && u instanceof GPUDevice;
|
|
338
338
|
}
|
|
339
339
|
function j() {
|
|
340
340
|
return ["iPad Simulator", "iPhone Simulator", "iPod Simulator", "iPad", "iPhone", "iPod"].includes(navigator.platform) || // iPad on iOS 13 detection
|
|
341
341
|
navigator.userAgent.includes("Mac") && "ontouchend" in document;
|
|
342
342
|
}
|
|
343
343
|
function O() {
|
|
344
|
-
const
|
|
345
|
-
|
|
344
|
+
const u = navigator.userAgent;
|
|
345
|
+
if (u.includes("Chrome") || u.includes("Chromium"))
|
|
346
|
+
return null;
|
|
347
|
+
const e = u.match(/Safari\/(\d+(\.\d+)?)/);
|
|
348
|
+
return e && parseFloat(e[1]);
|
|
346
349
|
}
|
|
347
350
|
function k() {
|
|
348
|
-
const
|
|
349
|
-
return
|
|
351
|
+
const u = navigator.userAgent.match(/Firefox\/(\d+(\.\d+)?)/);
|
|
352
|
+
return u && parseFloat(u[1]);
|
|
350
353
|
}
|
|
351
|
-
function Q(
|
|
354
|
+
function Q(u) {
|
|
352
355
|
const e = /* @__PURE__ */ new Set(), r = {
|
|
353
356
|
"texture-compression-bc": [
|
|
354
357
|
i.BC1_RGB,
|
|
@@ -361,31 +364,31 @@ function Q(c) {
|
|
|
361
364
|
"texture-compression-astc": [i.ASTC_4x4_RGB, i.ASTC_4x4_RGBA]
|
|
362
365
|
};
|
|
363
366
|
for (const [t, s] of Object.entries(r))
|
|
364
|
-
if (
|
|
367
|
+
if (u.features.has(t))
|
|
365
368
|
for (const n of s)
|
|
366
369
|
e.add(n);
|
|
367
370
|
return e;
|
|
368
371
|
}
|
|
369
|
-
function Z(
|
|
372
|
+
function Z(u) {
|
|
370
373
|
const e = document.createElement("canvas");
|
|
371
|
-
e.width =
|
|
374
|
+
e.width = u.width, e.height = u.height;
|
|
372
375
|
const r = e.getContext("2d");
|
|
373
|
-
r.drawImage(
|
|
374
|
-
const t = r.getImageData(0, 0,
|
|
376
|
+
r.drawImage(u, 0, 0);
|
|
377
|
+
const t = r.getImageData(0, 0, u.width, u.height);
|
|
375
378
|
return new Uint8Array(t.data.buffer);
|
|
376
379
|
}
|
|
377
|
-
function J(
|
|
378
|
-
return /\.svg(?:$|\?)/i.test(
|
|
380
|
+
function J(u) {
|
|
381
|
+
return /\.svg(?:$|\?)/i.test(u) || /^data:image\/svg\+xml[,;]/i.test(u);
|
|
379
382
|
}
|
|
380
|
-
function K(
|
|
383
|
+
function K(u) {
|
|
381
384
|
return new Promise((e, r) => {
|
|
382
385
|
const t = new Image();
|
|
383
|
-
t.crossOrigin = "anonymous", t.decoding = "async", t.onload = () => e(t), t.onerror = r, t.src =
|
|
386
|
+
t.crossOrigin = "anonymous", t.decoding = "async", t.onload = () => e(t), t.onerror = r, t.src = u;
|
|
384
387
|
});
|
|
385
388
|
}
|
|
386
|
-
async function ee(
|
|
387
|
-
const r = await fetch(
|
|
388
|
-
if (!r.ok) throw new Error(`HTTP ${r.status} for ${
|
|
389
|
+
async function ee(u, e = {}) {
|
|
390
|
+
const r = await fetch(u, { mode: "cors" });
|
|
391
|
+
if (!r.ok) throw new Error(`HTTP ${r.status} for ${u}`);
|
|
389
392
|
const t = await r.blob();
|
|
390
393
|
return createImageBitmap(t, {
|
|
391
394
|
imageOrientation: e.flipY ? "flipY" : "none",
|
|
@@ -394,17 +397,17 @@ async function ee(c, e = {}) {
|
|
|
394
397
|
});
|
|
395
398
|
}
|
|
396
399
|
const te = O();
|
|
397
|
-
function N(
|
|
398
|
-
return J(
|
|
400
|
+
function N(u) {
|
|
401
|
+
return J(u) || te ? K(u) : ee(u);
|
|
399
402
|
}
|
|
400
403
|
const L = 256, F = 4;
|
|
401
|
-
function re(
|
|
404
|
+
function re(u, e, r, t) {
|
|
402
405
|
let s = 0, n = 0;
|
|
403
406
|
const a = [];
|
|
404
407
|
do {
|
|
405
|
-
const o = Math.ceil(
|
|
406
|
-
s++, a.push({ offset: n, alignedSize: f, w:
|
|
407
|
-
} while (t && (
|
|
408
|
+
const o = Math.ceil(u / 4), c = Math.ceil(e / 4), l = Math.ceil(o * r / L) * L, f = c * l;
|
|
409
|
+
s++, a.push({ offset: n, alignedSize: f, w: u, h: e, bw: o, bh: c, bytesPerRow: l }), n += f, u = Math.max(1, Math.floor(u / 2)), e = Math.max(1, Math.floor(e / 2));
|
|
410
|
+
} while (t && (u >= F || e >= F));
|
|
408
411
|
return { mipmapCount: s, outputSize: n, bufferRanges: a };
|
|
409
412
|
}
|
|
410
413
|
class D {
|
|
@@ -552,7 +555,7 @@ class D {
|
|
|
552
555
|
w(this.#e, "Spark is not initialized");
|
|
553
556
|
const t = e instanceof Image || e instanceof ImageBitmap || e instanceof GPUTexture ? e : await N(e);
|
|
554
557
|
console.log("Loaded image", t);
|
|
555
|
-
const s = await this.#d(r, t), n = this.#h(s), a = Math.ceil(t.width / 4) * 4, o = Math.ceil(t.height / 4) * 4,
|
|
558
|
+
const s = await this.#d(r, t), n = this.#h(s), a = Math.ceil(t.width / 4) * 4, o = Math.ceil(t.height / 4) * 4, c = W[s], l = r.generateMipmaps || r.mips, { mipmapCount: f, outputSize: h, bufferRanges: m } = re(a, o, c, l), b = (r.srgb || r.format?.endsWith("srgb")) && X[s], _ = b ? 1 : r.normal ? 2 : 0, B = $[s] + (b ? "-srgb" : ""), A = b ? ["rgba8unorm", "rgba8unorm-srgb"] : ["rgba8unorm"], x = this.#G++;
|
|
556
559
|
console.time("create input texture #" + x);
|
|
557
560
|
let C = GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST;
|
|
558
561
|
this.#a ? C |= GPUTextureUsage.RENDER_ATTACHMENT : C |= GPUTextureUsage.STORAGE_BINDING;
|
|
@@ -820,10 +823,10 @@ class D {
|
|
|
820
823
|
});
|
|
821
824
|
if (typeof n.getCompilationInfo == "function") {
|
|
822
825
|
const o = await n.getCompilationInfo();
|
|
823
|
-
if (o.messages.some((
|
|
826
|
+
if (o.messages.some((c) => c.type == "error")) {
|
|
824
827
|
console.error("WGSL compilation errors:");
|
|
825
|
-
for (const
|
|
826
|
-
console.error(
|
|
828
|
+
for (const c of o.messages)
|
|
829
|
+
console.error(c);
|
|
827
830
|
throw new Error("Shader compilation failed");
|
|
828
831
|
}
|
|
829
832
|
}
|
|
@@ -926,9 +929,9 @@ class D {
|
|
|
926
929
|
let r = !0, t = !0, s = 0;
|
|
927
930
|
const n = Math.min(1024 * 128, e.length);
|
|
928
931
|
for (let a = 0; a < n; a += 4) {
|
|
929
|
-
const o = e[a] / 255,
|
|
930
|
-
e[a + 3] < 255 && (r = !1), (o !=
|
|
931
|
-
const h = 2 * o - 1, m = 2 *
|
|
932
|
+
const o = e[a] / 255, c = e[a + 1] / 255, l = e[a + 2] / 255;
|
|
933
|
+
e[a + 3] < 255 && (r = !1), (o != c || c != l) && (t = !1);
|
|
934
|
+
const h = 2 * o - 1, m = 2 * c - 1, b = 2 * l - 1, _ = h * h + m * m + b * b, B = Math.sqrt(_);
|
|
932
935
|
(Math.abs(B - 1) > 0.2 || b < -0.1) && (s += 1);
|
|
933
936
|
}
|
|
934
937
|
return r ? t ? 1 : 16 * s < n ? 2 : 3 : 4;
|
|
@@ -948,10 +951,10 @@ class D {
|
|
|
948
951
|
]
|
|
949
952
|
}), a = this.#e.createCommandEncoder(), o = a.beginComputePass();
|
|
950
953
|
o.setPipeline(this.#m), o.setBindGroup(0, n);
|
|
951
|
-
const { width:
|
|
954
|
+
const { width: c, height: l } = e, f = Math.ceil(c / 8), h = Math.ceil(l / 8);
|
|
952
955
|
o.dispatchWorkgroups(f, h), o.end(), a.copyBufferToBuffer(t, 0, s, 0, 12), this.#e.queue.submit([a.finish()]), await this.#e.queue.onSubmittedWorkDone(), await s.mapAsync(GPUMapMode.READ);
|
|
953
956
|
const m = new Uint32Array(s.getMappedRange()), b = m[0] == 0, _ = m[1] == 0, B = m[2];
|
|
954
|
-
return s.unmap(), s.destroy(), t.destroy(), b ? _ ? 1 : 4 * B <
|
|
957
|
+
return s.unmap(), s.destroy(), t.destroy(), b ? _ ? 1 : 4 * B < c * l ? 2 : 3 : 4;
|
|
955
958
|
}
|
|
956
959
|
// Apply scaling and flipY transform.
|
|
957
960
|
#_(e, r, t, s, n, a, o) {
|
|
@@ -959,8 +962,8 @@ class D {
|
|
|
959
962
|
this.#P(e, r, t, s, n, a, o);
|
|
960
963
|
return;
|
|
961
964
|
}
|
|
962
|
-
const
|
|
963
|
-
|
|
965
|
+
const c = e.beginComputePass(), l = o ? this.#u : this.#o;
|
|
966
|
+
c.setPipeline(l);
|
|
964
967
|
const f = this.#e.createBindGroup({
|
|
965
968
|
layout: l.getBindGroupLayout(0),
|
|
966
969
|
entries: [
|
|
@@ -993,15 +996,15 @@ class D {
|
|
|
993
996
|
}
|
|
994
997
|
]
|
|
995
998
|
});
|
|
996
|
-
|
|
999
|
+
c.setBindGroup(0, f), c.dispatchWorkgroups(Math.ceil(s / 8), Math.ceil(n / 8)), c.end();
|
|
997
1000
|
}
|
|
998
1001
|
// Apply scaling and flipY transform.
|
|
999
1002
|
#P(e, r, t, s, n, a, o) {
|
|
1000
|
-
const
|
|
1003
|
+
const c = a == 1 ? "rgba8unorm-srgb" : "rgba8unorm", l = t.createView({
|
|
1001
1004
|
baseMipLevel: 0,
|
|
1002
1005
|
mipLevelCount: 1,
|
|
1003
1006
|
dimension: "2d",
|
|
1004
|
-
format:
|
|
1007
|
+
format: c,
|
|
1005
1008
|
usage: GPUTextureUsage.RENDER_ATTACHMENT
|
|
1006
1009
|
}), f = e.beginRenderPass({
|
|
1007
1010
|
colorAttachments: [
|
|
@@ -1012,7 +1015,7 @@ class D {
|
|
|
1012
1015
|
clearValue: [0, 0, 0, 0]
|
|
1013
1016
|
}
|
|
1014
1017
|
]
|
|
1015
|
-
}), h = o ? this.#u[
|
|
1018
|
+
}), h = o ? this.#u[c] : this.#o[c];
|
|
1016
1019
|
f.setPipeline(h);
|
|
1017
1020
|
const m = this.#e.createBindGroup({
|
|
1018
1021
|
layout: h.getBindGroupLayout(0),
|
|
@@ -1039,20 +1042,20 @@ class D {
|
|
|
1039
1042
|
f.setBindGroup(0, m), f.draw(4, 1, 0, 0), f.end();
|
|
1040
1043
|
}
|
|
1041
1044
|
async #w(e, r, t, s, n, a) {
|
|
1042
|
-
let o = s,
|
|
1045
|
+
let o = s, c = n;
|
|
1043
1046
|
if (this.#a)
|
|
1044
1047
|
for (let l = 0; l < t - 1; l++)
|
|
1045
|
-
o = Math.max(1, Math.floor(o / 2)),
|
|
1048
|
+
o = Math.max(1, Math.floor(o / 2)), c = Math.max(1, Math.floor(c / 2)), this.#y(e, r, l, l + 1, o, c, a);
|
|
1046
1049
|
else {
|
|
1047
1050
|
const l = e.beginComputePass();
|
|
1048
1051
|
l.setPipeline(this.#s);
|
|
1049
1052
|
for (let f = 0; f < t - 1; f++)
|
|
1050
|
-
o = Math.max(1, Math.floor(o / 2)),
|
|
1053
|
+
o = Math.max(1, Math.floor(o / 2)), c = Math.max(1, Math.floor(c / 2)), this.#x(l, r, f, f + 1, o, c, a);
|
|
1051
1054
|
l.end();
|
|
1052
1055
|
}
|
|
1053
1056
|
}
|
|
1054
1057
|
#x(e, r, t, s, n, a, o) {
|
|
1055
|
-
const
|
|
1058
|
+
const c = this.#e.createBindGroup({
|
|
1056
1059
|
layout: this.#s.getBindGroupLayout(0),
|
|
1057
1060
|
entries: [
|
|
1058
1061
|
{
|
|
@@ -1084,14 +1087,14 @@ class D {
|
|
|
1084
1087
|
}
|
|
1085
1088
|
]
|
|
1086
1089
|
});
|
|
1087
|
-
e.setBindGroup(0,
|
|
1090
|
+
e.setBindGroup(0, c), e.dispatchWorkgroups(Math.ceil(n / 8), Math.ceil(a / 8));
|
|
1088
1091
|
}
|
|
1089
1092
|
#y(e, r, t, s, n, a, o) {
|
|
1090
|
-
const
|
|
1093
|
+
const c = o == 1 ? "rgba8unorm-srgb" : "rgba8unorm", l = r.createView({
|
|
1091
1094
|
baseMipLevel: s,
|
|
1092
1095
|
mipLevelCount: 1,
|
|
1093
1096
|
dimension: "2d",
|
|
1094
|
-
format:
|
|
1097
|
+
format: c,
|
|
1095
1098
|
usage: GPUTextureUsage.RENDER_ATTACHMENT
|
|
1096
1099
|
}), f = e.beginRenderPass({
|
|
1097
1100
|
colorAttachments: [
|
|
@@ -1103,14 +1106,14 @@ class D {
|
|
|
1103
1106
|
}
|
|
1104
1107
|
]
|
|
1105
1108
|
}), h = this.#e.createBindGroup({
|
|
1106
|
-
layout: this.#s[
|
|
1109
|
+
layout: this.#s[c].getBindGroupLayout(0),
|
|
1107
1110
|
entries: [
|
|
1108
1111
|
{
|
|
1109
1112
|
binding: 0,
|
|
1110
1113
|
resource: r.createView({
|
|
1111
1114
|
baseMipLevel: t,
|
|
1112
1115
|
mipLevelCount: 1,
|
|
1113
|
-
format:
|
|
1116
|
+
format: c,
|
|
1114
1117
|
usage: GPUTextureUsage.TEXTURE_BINDING
|
|
1115
1118
|
})
|
|
1116
1119
|
},
|
|
@@ -1124,7 +1127,7 @@ class D {
|
|
|
1124
1127
|
}
|
|
1125
1128
|
]
|
|
1126
1129
|
});
|
|
1127
|
-
f.setPipeline(this.#s[
|
|
1130
|
+
f.setPipeline(this.#s[c]), f.setBindGroup(0, h), f.draw(4, 1, 0, 0), f.end();
|
|
1128
1131
|
}
|
|
1129
1132
|
}
|
|
1130
1133
|
export {
|
|
@@ -2,6 +2,10 @@ const n = `struct Params {
|
|
|
2
2
|
colorMode: u32,
|
|
3
3
|
};
|
|
4
4
|
|
|
5
|
+
const COLOR_LINEAR : u32 = 0u;
|
|
6
|
+
const COLOR_SRGB : u32 = 1u;
|
|
7
|
+
const COLOR_NORMAL : u32 = 2u;
|
|
8
|
+
|
|
5
9
|
@group(0) @binding(0) var src : texture_2d<f32>;
|
|
6
10
|
@group(0) @binding(1) var dst : texture_storage_2d<rgba8unorm, write>;
|
|
7
11
|
@group(0) @binding(2) var smp: sampler;
|
|
@@ -38,25 +42,53 @@ fn mipmap(@builtin(global_invocation_id) id : vec3<u32>) {
|
|
|
38
42
|
|
|
39
43
|
let size_rcp = vec2f(1.0) / vec2f(dstSize);
|
|
40
44
|
|
|
41
|
-
// We
|
|
42
|
-
//
|
|
45
|
+
// We take 4 samples explicitly in order to support alpha weighting and for slightly more correct
|
|
46
|
+
// results when using non multiple of two textures.
|
|
43
47
|
let uv0 = (vec2f(id.xy) + vec2f(0.25)) * size_rcp;
|
|
44
48
|
let uv1 = uv0 + 0.5 * size_rcp;
|
|
45
49
|
|
|
46
50
|
var color = vec4f(0.0);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
|
|
52
|
+
if (params.colorMode == COLOR_SRGB) {
|
|
53
|
+
let c00 = textureSampleLevel(src, smp, vec2f(uv0.x, uv0.y), 0);
|
|
54
|
+
let c10 = textureSampleLevel(src, smp, vec2f(uv1.x, uv0.y), 0);
|
|
55
|
+
let c01 = textureSampleLevel(src, smp, vec2f(uv0.x, uv1.y), 0);
|
|
56
|
+
let c11 = textureSampleLevel(src, smp, vec2f(uv1.x, uv1.y), 0);
|
|
57
|
+
|
|
58
|
+
let a00 = c00.a;
|
|
59
|
+
let a10 = c10.a;
|
|
60
|
+
let a01 = c01.a;
|
|
61
|
+
let a11 = c11.a;
|
|
62
|
+
let a_sum = a00 + a10 + a01 + a11;
|
|
63
|
+
|
|
64
|
+
color.a = 0.25 * a_sum;
|
|
65
|
+
if (a_sum > 1.0 / 256.0) {
|
|
66
|
+
color.r = (c00.r * a00 + c10.r * a10 + c01.r * a01 + c11.r * a11) / a_sum;
|
|
67
|
+
color.g = (c00.g * a00 + c10.g * a10 + c01.g * a01 + c11.g * a11) / a_sum;
|
|
68
|
+
color.b = (c00.b * a00 + c10.b * a10 + c01.b * a01 + c11.b * a11) / a_sum;
|
|
69
|
+
} else {
|
|
70
|
+
color.r = 0.25 * (c00.r + c10.r + c01.r + c11.r);
|
|
71
|
+
color.g = 0.25 * (c00.g + c10.g + c01.g + c11.g);
|
|
72
|
+
color.b = 0.25 * (c00.b + c10.b + c01.b + c11.b);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
// For linear colors, we assume no alpha.
|
|
77
|
+
// @@ We could normalize/reconstruct normals before averaging.
|
|
78
|
+
color += textureSampleLevel(src, smp, vec2f(uv0.x, uv0.y), 0);
|
|
79
|
+
color += textureSampleLevel(src, smp, vec2f(uv1.x, uv0.y), 0);
|
|
80
|
+
color += textureSampleLevel(src, smp, vec2f(uv0.x, uv1.y), 0);
|
|
81
|
+
color += textureSampleLevel(src, smp, vec2f(uv1.x, uv1.y), 0);
|
|
82
|
+
color *= 0.25;
|
|
83
|
+
}
|
|
52
84
|
|
|
53
85
|
// This would be the single sample implementation:
|
|
54
86
|
// let uv = (vec2f(id.xy) + vec2f(0.5)) * size_rcp;
|
|
55
87
|
// var color = textureSampleLevel(src, smp, vec2f(uv.x, uv.y), 0);
|
|
56
88
|
|
|
57
|
-
if (params.colorMode ==
|
|
89
|
+
if (params.colorMode == COLOR_SRGB) {
|
|
58
90
|
color = linear_to_srgb_vec4(color);
|
|
59
|
-
} else if (params.colorMode ==
|
|
91
|
+
} else if (params.colorMode == COLOR_NORMAL) {
|
|
60
92
|
color = normalize_vec4(color);
|
|
61
93
|
}
|
|
62
94
|
|
|
@@ -73,9 +105,9 @@ fn resize(@builtin(global_invocation_id) id : vec3<u32>) {
|
|
|
73
105
|
let uv = (vec2f(id.xy) + vec2f(0.5)) / vec2f(dstSize);
|
|
74
106
|
var color = textureSampleLevel(src, smp, uv, 0);
|
|
75
107
|
|
|
76
|
-
if (params.colorMode ==
|
|
108
|
+
if (params.colorMode == COLOR_SRGB) {
|
|
77
109
|
color = linear_to_srgb_vec4(color);
|
|
78
|
-
} else if (params.colorMode ==
|
|
110
|
+
} else if (params.colorMode == COLOR_NORMAL) {
|
|
79
111
|
color = normalize_vec4(color);
|
|
80
112
|
}
|
|
81
113
|
|
|
@@ -92,9 +124,9 @@ fn flipy(@builtin(global_invocation_id) id : vec3<u32>) {
|
|
|
92
124
|
let uv = (vec2f(f32(id.x), f32(dstSize.y - 1u - id.y)) + vec2f(0.5)) / vec2f(dstSize);
|
|
93
125
|
var color = textureSampleLevel(src, smp, uv, 0);
|
|
94
126
|
|
|
95
|
-
if (params.colorMode ==
|
|
127
|
+
if (params.colorMode == COLOR_SRGB) {
|
|
96
128
|
color = linear_to_srgb_vec4(color);
|
|
97
|
-
} else if (params.colorMode ==
|
|
129
|
+
} else if (params.colorMode == COLOR_NORMAL) {
|
|
98
130
|
color = normalize_vec4(color);
|
|
99
131
|
}
|
|
100
132
|
|