@pinkaphant/kolmo 0.1.1 → 0.1.3
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/LICENSE +21 -0
- package/README.md +16 -14
- package/bin/kolmo.mjs +19 -54
- package/dist/body/HeldItem.d.ts +22 -0
- package/dist/body/HeldItem.js +171 -0
- package/dist/body/KhrBody.d.ts +26 -0
- package/dist/body/KhrBody.js +179 -0
- package/dist/body/bodySi.d.ts +59 -0
- package/dist/body/bodySi.js +61 -0
- package/dist/body/index.d.ts +3 -0
- package/dist/body/index.js +4 -0
- package/dist/engine/index.d.ts +4 -4
- package/dist/engine/index.js +12 -3
- package/dist/engine/kolmoActor.d.ts +11 -4
- package/dist/engine/kolmoActor.js +197 -0
- package/dist/engine/kolmoInput.d.ts +12 -0
- package/dist/engine/kolmoInput.js +80 -0
- package/dist/engine/kolmoIsland.d.ts +3 -1
- package/dist/engine/kolmoIsland.js +311 -0
- package/dist/engine/kolmoLongDrive.js +223 -0
- package/dist/engine/kolmoRigs.js +59 -0
- package/dist/engine/kolmoStore.d.ts +53 -27
- package/dist/engine/kolmoStore.js +211 -0
- package/dist/engine/kolmoSurface.d.ts +1 -1
- package/dist/engine/kolmoSurface.js +182 -0
- package/dist/engine/kolmoVehicle.d.ts +2 -1
- package/dist/engine/kolmoVehicle.js +244 -0
- package/dist/engine/kolmoVehicleDriver.d.ts +30 -0
- package/dist/engine/kolmoVehicleDriver.js +38 -0
- package/dist/engine/kolmoWorld.d.ts +7 -15
- package/dist/engine/kolmoWorld.js +136 -0
- package/dist/engine/longDriveKit.d.ts +4 -2
- package/dist/engine/longDriveKit.js +254 -0
- package/dist/engine/mainlandMacroCell.d.ts +3 -7
- package/dist/engine/mainlandMacroCell.js +247 -0
- package/dist/engine/shiftedFixedBody.d.ts +13 -0
- package/dist/engine/shiftedFixedBody.js +64 -0
- package/dist/importer/ChopShopPanel.js +465 -0
- package/dist/importer/DomainWorkshopPanel.d.ts +9 -4
- package/dist/importer/DomainWorkshopPanel.js +385 -0
- package/dist/importer/GateHudBar.js +312 -0
- package/dist/importer/GlbImportGate.js +250 -0
- package/dist/importer/ImperativeVehicleRig.js +336 -0
- package/dist/importer/ImporterPlinthUikitTags.js +112 -0
- package/dist/importer/Step1CalibrationPlinth.js +275 -0
- package/dist/importer/Step2UniversalPad.js +244 -0
- package/dist/importer/VfxEmitterPool.js +91 -0
- package/dist/importer/chopShopActions.d.ts +22 -2
- package/dist/importer/chopShopActions.js +232 -0
- package/dist/importer/gateStore.d.ts +1 -1
- package/dist/importer/gateStore.js +92 -0
- package/dist/importer/glbNormalizer.js +133 -0
- package/dist/importer/importerWebMcp.d.ts +17 -6
- package/dist/importer/importerWebMcp.js +343 -0
- package/dist/importer/index.js +22 -3
- package/dist/importer/khrCompiler.d.ts +1 -1
- package/dist/importer/khrCompiler.js +434 -0
- package/dist/importer/launcherBake.js +51 -0
- package/dist/importer/meshIslands.d.ts +1 -1
- package/dist/importer/meshIslands.js +301 -0
- package/dist/importer/surfaceCutter.js +254 -0
- package/dist/importer/surfaceTopology.js +183 -0
- package/dist/importer/universalGateBake.js +162 -0
- package/dist/importer/usdToGlb.js +294 -0
- package/dist/importer/useChopShopController.d.ts +11 -2
- package/dist/importer/useChopShopController.js +364 -0
- package/dist/importer/vehiclePanelAnim.js +214 -0
- package/dist/importer/wheelAxlePairing.d.ts +1 -2
- package/dist/importer/wheelAxlePairing.js +102 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +69 -14
- package/dist/junk/DestructibleTarget.js +154 -0
- package/dist/junk/KolmoJunk.js +65 -0
- package/dist/junk/ShardPieces.d.ts +6 -4
- package/dist/junk/ShardPieces.js +74 -0
- package/dist/junk/TargetDecals.js +51 -0
- package/dist/junk/bvhShatter.js +55 -0
- package/dist/junk/bvhTriCollector.js +78 -0
- package/dist/junk/index.js +11 -1
- package/dist/junk/junkGeometry.js +69 -0
- package/dist/junk/junkImportSanitize.js +54 -0
- package/dist/junk/junkImporter.js +95 -0
- package/dist/junk/junkLabelCanvas.js +67 -0
- package/dist/junk/junkLabels.js +35 -0
- package/dist/junk/targetHelpers.js +103 -0
- package/dist/junk/targetHitLogic.js +128 -0
- package/dist/junk/useTargetAssets.js +102 -0
- package/dist/physics/index.d.ts +26 -0
- package/dist/physics/index.js +84 -0
- package/dist/schema/kolmoSchema.d.ts +2 -1
- package/dist/schema/kolmoSchema.js +184 -0
- package/dist/shaders/celestialBackdrop.d.ts +1 -1
- package/dist/shaders/celestialBackdrop.js +344 -0
- package/dist/shaders/index.d.ts +0 -1
- package/dist/shaders/index.js +9 -1
- package/dist/shaders/plumeAndSparkle.js +271 -0
- package/dist/shaders/ps2GlslShared.d.ts +1 -1
- package/dist/shaders/ps2GlslShared.js +3 -0
- package/dist/shaders/ps2MaterialsTSL.js +65 -0
- package/dist/shaders/ps2MaterialsWebGL.js +40 -0
- package/dist/shaders/ps2RoadWebGL.js +101 -0
- package/dist/shaders/ps2TerrainWebGL.js +54 -0
- package/dist/shaders/ps2Textures.js +224 -0
- package/dist/shaders/retroPalettes.js +188 -0
- package/dist/shaders/retroShader.d.ts +31 -3
- package/dist/shaders/retroShader.js +249 -0
- package/dist/shaders/tsl.d.ts +1 -0
- package/dist/shaders/tsl.js +1 -0
- package/dist/vite/index.d.ts +15 -0
- package/dist/vite/index.js +90 -0
- package/dist/world/frontage.js +32 -0
- package/dist/world/index.d.ts +1 -1
- package/dist/world/index.js +11 -3
- package/dist/world/infiniteWorld2D.js +244 -0
- package/dist/world/island.js +201 -0
- package/dist/world/macroCellSchema.js +27 -0
- package/dist/world/macroKnightAStar.js +171 -0
- package/dist/world/random.js +33 -0
- package/dist/world/road.js +136 -0
- package/dist/world/roadRibbon.d.ts +6 -6
- package/dist/world/roadRibbon.js +161 -0
- package/dist/world/terrain.js +87 -0
- package/dist/world/worldTypes.js +111 -0
- package/package.json +36 -19
- package/dist/engine-BeKvBM8d.js +0 -1745
- package/dist/importer-D9bdcGTh.js +0 -5113
- package/dist/junk-B4bC1zAl.js +0 -1049
- package/dist/kolmoSurface-DTnrFXH0.js +0 -558
- package/dist/shaders-GS71Ek1A.js +0 -1383
- package/dist/world-PRWPYrlx.js +0 -947
- package/dist/worldTypes-Z0KfdCd0.js +0 -226
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { SplitMix32 as e, hashSeed as t } from "../world/worldTypes.js";
|
|
2
|
+
import * as n from "three";
|
|
3
|
+
// src/shaders/ps2Textures.ts
|
|
4
|
+
var r = {
|
|
5
|
+
DIRT: 0,
|
|
6
|
+
GRASS: 1,
|
|
7
|
+
SAND: 2,
|
|
8
|
+
ROCK: 3,
|
|
9
|
+
GRAVEL: 4,
|
|
10
|
+
FOREST: 5,
|
|
11
|
+
SNOW: 6,
|
|
12
|
+
ASPHALT: 7
|
|
13
|
+
};
|
|
14
|
+
function i(e, t, n, r) {
|
|
15
|
+
let i = (e % n + n) % n, a = (t % n + n) % n, o = Math.imul(i, 374761393) + Math.imul(a, 668265263) + r | 0;
|
|
16
|
+
return o = Math.imul(o ^ o >>> 13, 1274126177), ((o ^ o >>> 16) >>> 0) / 4294967296;
|
|
17
|
+
}
|
|
18
|
+
function a(e, t, n, r) {
|
|
19
|
+
let a = e * n, o = t * n, s = Math.floor(a), c = Math.floor(o), l = a - s, u = o - c, d = l * l * (3 - 2 * l), f = u * u * (3 - 2 * u), p = i(s, c, n, r), m = i(s + 1, c, n, r), h = i(s, c + 1, n, r), g = i(s + 1, c + 1, n, r);
|
|
20
|
+
return (p * (1 - d) + m * d) * (1 - f) + (h * (1 - d) + g * d) * f;
|
|
21
|
+
}
|
|
22
|
+
var o = (e) => Math.max(0, Math.min(255, Math.round(e))), s = [
|
|
23
|
+
{
|
|
24
|
+
base: [
|
|
25
|
+
108,
|
|
26
|
+
82,
|
|
27
|
+
56
|
|
28
|
+
],
|
|
29
|
+
dark: [
|
|
30
|
+
72,
|
|
31
|
+
53,
|
|
32
|
+
36
|
|
33
|
+
],
|
|
34
|
+
light: [
|
|
35
|
+
138,
|
|
36
|
+
108,
|
|
37
|
+
76
|
|
38
|
+
],
|
|
39
|
+
freqA: 16,
|
|
40
|
+
freqB: 48,
|
|
41
|
+
speckle: .28
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
base: [
|
|
45
|
+
86,
|
|
46
|
+
114,
|
|
47
|
+
52
|
|
48
|
+
],
|
|
49
|
+
dark: [
|
|
50
|
+
58,
|
|
51
|
+
82,
|
|
52
|
+
34
|
|
53
|
+
],
|
|
54
|
+
light: [
|
|
55
|
+
122,
|
|
56
|
+
146,
|
|
57
|
+
68
|
|
58
|
+
],
|
|
59
|
+
freqA: 20,
|
|
60
|
+
freqB: 64,
|
|
61
|
+
speckle: .22
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
base: [
|
|
65
|
+
194,
|
|
66
|
+
174,
|
|
67
|
+
128
|
|
68
|
+
],
|
|
69
|
+
dark: [
|
|
70
|
+
164,
|
|
71
|
+
142,
|
|
72
|
+
98
|
|
73
|
+
],
|
|
74
|
+
light: [
|
|
75
|
+
218,
|
|
76
|
+
202,
|
|
77
|
+
158
|
|
78
|
+
],
|
|
79
|
+
freqA: 12,
|
|
80
|
+
freqB: 64,
|
|
81
|
+
speckle: .14,
|
|
82
|
+
striateY: 3
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
base: [
|
|
86
|
+
112,
|
|
87
|
+
110,
|
|
88
|
+
106
|
|
89
|
+
],
|
|
90
|
+
dark: [
|
|
91
|
+
68,
|
|
92
|
+
66,
|
|
93
|
+
64
|
|
94
|
+
],
|
|
95
|
+
light: [
|
|
96
|
+
148,
|
|
97
|
+
145,
|
|
98
|
+
138
|
|
99
|
+
],
|
|
100
|
+
freqA: 14,
|
|
101
|
+
freqB: 36,
|
|
102
|
+
speckle: .2,
|
|
103
|
+
striateY: 4.5
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
base: [
|
|
107
|
+
124,
|
|
108
|
+
118,
|
|
109
|
+
108
|
|
110
|
+
],
|
|
111
|
+
dark: [
|
|
112
|
+
76,
|
|
113
|
+
72,
|
|
114
|
+
66
|
|
115
|
+
],
|
|
116
|
+
light: [
|
|
117
|
+
168,
|
|
118
|
+
162,
|
|
119
|
+
150
|
|
120
|
+
],
|
|
121
|
+
freqA: 32,
|
|
122
|
+
freqB: 64,
|
|
123
|
+
speckle: .45
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
base: [
|
|
127
|
+
56,
|
|
128
|
+
76,
|
|
129
|
+
42
|
|
130
|
+
],
|
|
131
|
+
dark: [
|
|
132
|
+
36,
|
|
133
|
+
48,
|
|
134
|
+
28
|
|
135
|
+
],
|
|
136
|
+
light: [
|
|
137
|
+
88,
|
|
138
|
+
98,
|
|
139
|
+
54
|
|
140
|
+
],
|
|
141
|
+
freqA: 18,
|
|
142
|
+
freqB: 52,
|
|
143
|
+
speckle: .26
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
base: [
|
|
147
|
+
222,
|
|
148
|
+
228,
|
|
149
|
+
236
|
|
150
|
+
],
|
|
151
|
+
dark: [
|
|
152
|
+
182,
|
|
153
|
+
194,
|
|
154
|
+
212
|
|
155
|
+
],
|
|
156
|
+
light: [
|
|
157
|
+
246,
|
|
158
|
+
248,
|
|
159
|
+
252
|
|
160
|
+
],
|
|
161
|
+
freqA: 12,
|
|
162
|
+
freqB: 40,
|
|
163
|
+
speckle: .1
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
base: [
|
|
167
|
+
54,
|
|
168
|
+
55,
|
|
169
|
+
58
|
|
170
|
+
],
|
|
171
|
+
dark: [
|
|
172
|
+
36,
|
|
173
|
+
37,
|
|
174
|
+
40
|
|
175
|
+
],
|
|
176
|
+
light: [
|
|
177
|
+
86,
|
|
178
|
+
88,
|
|
179
|
+
92
|
|
180
|
+
],
|
|
181
|
+
freqA: 32,
|
|
182
|
+
freqB: 64,
|
|
183
|
+
speckle: .42
|
|
184
|
+
}
|
|
185
|
+
];
|
|
186
|
+
function c(t, n = 128) {
|
|
187
|
+
let r = new e(t), c = [];
|
|
188
|
+
for (let e = 0; e < 8; e++) {
|
|
189
|
+
let t = new Uint8Array(n * n * 4), l = s[e], u = r.next() * 2147483647 | 0, d = r.next() * 2147483647 | 0, f = r.next() * 2147483647 | 0;
|
|
190
|
+
for (let e = 0; e < n; e++) for (let r = 0; r < n; r++) {
|
|
191
|
+
let s = r / n, c = a(s, e / n * (l.striateY ?? 1) % 1, l.freqA, u), p = a(s, e / n, l.freqB, d), m = i(r, e, n, f), h = c * .55 + p * .45;
|
|
192
|
+
m > 1 - l.speckle * .35 ? h = Math.min(1, h + .32) : m < l.speckle * .35 && (h = Math.max(0, h - .3)), h = Math.round(h * 12) / 12;
|
|
193
|
+
let g = h < .5 ? h * 2 : (h - .5) * 2, _ = h < .5 ? l.dark : l.base, v = h < .5 ? l.base : l.light, y = (e * n + r) * 4;
|
|
194
|
+
t[y] = o(_[0] * (1 - g) + v[0] * g), t[y + 1] = o(_[1] * (1 - g) + v[1] * g), t[y + 2] = o(_[2] * (1 - g) + v[2] * g), t[y + 3] = 255;
|
|
195
|
+
}
|
|
196
|
+
c.push(t);
|
|
197
|
+
}
|
|
198
|
+
return c;
|
|
199
|
+
}
|
|
200
|
+
function l(e) {
|
|
201
|
+
let r = e.config.gridCells, i = (e) => {
|
|
202
|
+
let t = new n.DataTexture(e, r, r, n.RGBAFormat, n.UnsignedByteType);
|
|
203
|
+
return t.colorSpace = n.NoColorSpace, t.wrapS = n.ClampToEdgeWrapping, t.wrapT = n.ClampToEdgeWrapping, t.magFilter = n.LinearFilter, t.minFilter = n.LinearFilter, t.generateMipmaps = !1, t.flipY = !1, t.needsUpdate = !0, t;
|
|
204
|
+
}, a = i(e.splat0), o = i(e.splat1), s = new n.DataTexture(e.alphaMap, r, r, n.RedFormat, n.UnsignedByteType);
|
|
205
|
+
s.colorSpace = n.NoColorSpace, s.wrapS = n.ClampToEdgeWrapping, s.wrapT = n.ClampToEdgeWrapping, s.magFilter = n.NearestFilter, s.minFilter = n.NearestFilter, s.generateMipmaps = !1, s.flipY = !1, s.needsUpdate = !0;
|
|
206
|
+
let l = c(t(e.config.seed) ^ 2654435769, 128), u = /* @__PURE__ */ new Uint8Array(524288), d = [];
|
|
207
|
+
for (let e = 0; e < 8; e++) {
|
|
208
|
+
u.set(l[e], e * 128 * 128 * 4);
|
|
209
|
+
let t = new n.DataTexture(l[e], 128, 128, n.RGBAFormat, n.UnsignedByteType);
|
|
210
|
+
t.colorSpace = n.SRGBColorSpace, t.wrapS = n.RepeatWrapping, t.wrapT = n.RepeatWrapping, t.magFilter = n.NearestFilter, t.minFilter = n.LinearMipmapNearestFilter, t.generateMipmaps = !0, t.needsUpdate = !0, d.push(t);
|
|
211
|
+
}
|
|
212
|
+
let f = new n.DataArrayTexture(u, 128, 128, 8);
|
|
213
|
+
return f.format = n.RGBAFormat, f.type = n.UnsignedByteType, f.colorSpace = n.SRGBColorSpace, f.wrapS = n.RepeatWrapping, f.wrapT = n.RepeatWrapping, f.magFilter = n.NearestFilter, f.minFilter = n.LinearMipmapNearestFilter, f.generateMipmaps = !0, f.needsUpdate = !0, {
|
|
214
|
+
splat0Tex: a,
|
|
215
|
+
splat1Tex: o,
|
|
216
|
+
alphaTex: s,
|
|
217
|
+
detailArrayTex: f,
|
|
218
|
+
detailSliceTexs: d,
|
|
219
|
+
dispose: () => {
|
|
220
|
+
a.dispose(), o.dispose(), s.dispose(), f.dispose(), d.forEach((e) => e.dispose());
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
export { r as SPLAT_LAYER, l as createPS2WorldTextures, c as generatePS2DetailSlices };
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import * as e from "three";
|
|
2
|
+
// src/shaders/retroPalettes.ts
|
|
3
|
+
var t = [
|
|
4
|
+
{
|
|
5
|
+
id: "off",
|
|
6
|
+
label: "Off (24-bit)",
|
|
7
|
+
shortLabel: "Off",
|
|
8
|
+
description: "True 24-bit color"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
id: "rgb555",
|
|
12
|
+
label: "RGB555 (32K)",
|
|
13
|
+
shortLabel: "RGB555",
|
|
14
|
+
description: "Dreamcast / PS1 15-bit"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: "rgb444",
|
|
18
|
+
label: "RGB444 (4K)",
|
|
19
|
+
shortLabel: "RGB444",
|
|
20
|
+
description: "DSi / 12-bit crisp"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "rgb332",
|
|
24
|
+
label: "RGB332 (256)",
|
|
25
|
+
shortLabel: "RGB332",
|
|
26
|
+
description: "8-bit arcade quant"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "crunchy16",
|
|
30
|
+
label: "Crunchy 16",
|
|
31
|
+
shortLabel: "16-Col",
|
|
32
|
+
description: "16-color indexed LUT"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: "crunchy64",
|
|
36
|
+
label: "Crunchy 64",
|
|
37
|
+
shortLabel: "64-Col",
|
|
38
|
+
description: "64-color indexed LUT"
|
|
39
|
+
}
|
|
40
|
+
], n = [
|
|
41
|
+
"#050811",
|
|
42
|
+
"#141c33",
|
|
43
|
+
"#27395c",
|
|
44
|
+
"#53739e",
|
|
45
|
+
"#a6bfd9",
|
|
46
|
+
"#f2f7ff",
|
|
47
|
+
"#1c4f6e",
|
|
48
|
+
"#38e8ff",
|
|
49
|
+
"#199474",
|
|
50
|
+
"#70e899",
|
|
51
|
+
"#5e2b59",
|
|
52
|
+
"#d1436e",
|
|
53
|
+
"#8c381f",
|
|
54
|
+
"#ff6b00",
|
|
55
|
+
"#ffb847",
|
|
56
|
+
"#fff29c"
|
|
57
|
+
], r = [
|
|
58
|
+
...n,
|
|
59
|
+
"#0a1020",
|
|
60
|
+
"#10182b",
|
|
61
|
+
"#1b2742",
|
|
62
|
+
"#354b73",
|
|
63
|
+
"#6e8db8",
|
|
64
|
+
"#cad9ec",
|
|
65
|
+
"#ffffff",
|
|
66
|
+
"#000000",
|
|
67
|
+
"#0e2b3d",
|
|
68
|
+
"#14445c",
|
|
69
|
+
"#1f6a8a",
|
|
70
|
+
"#2498b5",
|
|
71
|
+
"#58c9e8",
|
|
72
|
+
"#9eeeff",
|
|
73
|
+
"#d6fbff",
|
|
74
|
+
"#0b222e",
|
|
75
|
+
"#0f3b35",
|
|
76
|
+
"#175e4e",
|
|
77
|
+
"#238264",
|
|
78
|
+
"#39b57d",
|
|
79
|
+
"#86e39b",
|
|
80
|
+
"#c6f7c2",
|
|
81
|
+
"#426130",
|
|
82
|
+
"#96b54c",
|
|
83
|
+
"#2a1638",
|
|
84
|
+
"#422059",
|
|
85
|
+
"#672d78",
|
|
86
|
+
"#993e8f",
|
|
87
|
+
"#d160a6",
|
|
88
|
+
"#ff9ec7",
|
|
89
|
+
"#4a1b2d",
|
|
90
|
+
"#8c2640",
|
|
91
|
+
"#b83333",
|
|
92
|
+
"#eb564b",
|
|
93
|
+
"#ff8559",
|
|
94
|
+
"#522214",
|
|
95
|
+
"#75341c",
|
|
96
|
+
"#ad4e1d",
|
|
97
|
+
"#db7b21",
|
|
98
|
+
"#ff9f38",
|
|
99
|
+
"#ffd466",
|
|
100
|
+
"#4a3d31",
|
|
101
|
+
"#78624e",
|
|
102
|
+
"#a68b72",
|
|
103
|
+
"#d4bfa6",
|
|
104
|
+
"#2b2d38",
|
|
105
|
+
"#505569",
|
|
106
|
+
"#8a91a8"
|
|
107
|
+
];
|
|
108
|
+
function i(e) {
|
|
109
|
+
let t = e.startsWith("#") ? e.slice(1) : e, n = parseInt(t, 16);
|
|
110
|
+
return [
|
|
111
|
+
n >> 16 & 255,
|
|
112
|
+
n >> 8 & 255,
|
|
113
|
+
n & 255
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
function a(e) {
|
|
117
|
+
let t = e.map(i), n = /* @__PURE__ */ new Uint8Array(131072);
|
|
118
|
+
for (let e = 0; e < 32; e++) {
|
|
119
|
+
let r = Math.round(e / 31 * 255);
|
|
120
|
+
for (let i = 0; i < 32; i++) {
|
|
121
|
+
let a = Math.round(i / 31 * 255);
|
|
122
|
+
for (let o = 0; o < 32; o++) {
|
|
123
|
+
let s = Math.round(o / 31 * 255), c = Infinity, l = t[0];
|
|
124
|
+
for (let e = 0; e < t.length; e++) {
|
|
125
|
+
let n = t[e], i = s - n[0], o = r - n[1], u = a - n[2], d = 2 * i * i + 4 * o * o + 3 * u * u;
|
|
126
|
+
d < c && (c = d, l = n);
|
|
127
|
+
}
|
|
128
|
+
let u = (e * 1024 + (i * 32 + o)) * 4;
|
|
129
|
+
n[u] = l[0], n[u + 1] = l[1], n[u + 2] = l[2], n[u + 3] = 255;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return n;
|
|
134
|
+
}
|
|
135
|
+
function o(t, n = 1024, r = 32) {
|
|
136
|
+
let i = new e.DataTexture(t, n, r, e.RGBAFormat, e.UnsignedByteType);
|
|
137
|
+
return i.magFilter = e.NearestFilter, i.minFilter = e.NearestFilter, i.generateMipmaps = !1, i.colorSpace = e.NoColorSpace, i.unpackAlignment = 1, i.needsUpdate = !0, i;
|
|
138
|
+
}
|
|
139
|
+
var s = {};
|
|
140
|
+
function c(e) {
|
|
141
|
+
let t = s[e];
|
|
142
|
+
if (t) return t;
|
|
143
|
+
let i = e === "crunchy16" ? o(a(n)) : e === "crunchy64" ? o(a(r)) : o(new Uint8Array([
|
|
144
|
+
255,
|
|
145
|
+
255,
|
|
146
|
+
255,
|
|
147
|
+
255
|
|
148
|
+
]), 1, 1);
|
|
149
|
+
return s[e] = i, i;
|
|
150
|
+
}
|
|
151
|
+
function l(t, n = new e.Vector4()) {
|
|
152
|
+
switch (t) {
|
|
153
|
+
case "off": return n.set(255, 255, 255, 0);
|
|
154
|
+
case "rgb444": return n.set(15, 15, 15, 1);
|
|
155
|
+
case "rgb332": return n.set(7, 7, 3, 1);
|
|
156
|
+
case "crunchy16": return n.set(16, .26, 0, 2);
|
|
157
|
+
case "crunchy64": return n.set(64, .14, 0, 2);
|
|
158
|
+
default: return n.set(31, 31, 31, 1);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
var u = [
|
|
162
|
+
"map",
|
|
163
|
+
"normalMap",
|
|
164
|
+
"roughnessMap",
|
|
165
|
+
"metalnessMap",
|
|
166
|
+
"emissiveMap",
|
|
167
|
+
"bumpMap",
|
|
168
|
+
"aoMap"
|
|
169
|
+
];
|
|
170
|
+
function d(t, n) {
|
|
171
|
+
if (!t) return t;
|
|
172
|
+
let r = n?.pixelated !== !1, i = n?.mipmaps !== !1;
|
|
173
|
+
return t.magFilter = r ? e.NearestFilter : e.LinearFilter, t.generateMipmaps = i, t.minFilter = i ? e.NearestMipmapLinearFilter : r ? e.NearestFilter : e.LinearFilter, typeof n?.anisotropy == "number" && Number.isFinite(n.anisotropy) && (t.anisotropy = Math.max(1, Math.round(n.anisotropy))), t.needsUpdate = !0, t;
|
|
174
|
+
}
|
|
175
|
+
function f(e, t) {
|
|
176
|
+
if (!e) return;
|
|
177
|
+
let n = e;
|
|
178
|
+
for (let e of u) {
|
|
179
|
+
let r = n[e];
|
|
180
|
+
r && typeof r == "object" && r.isTexture && d(r, t);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function p(t, n = !1, r) {
|
|
184
|
+
if (n) return .5;
|
|
185
|
+
let i = typeof window < "u" && Number.isFinite(window.devicePixelRatio) && window.devicePixelRatio > 0 ? window.devicePixelRatio : 1, a = Math.min(2, Math.max(1, Math.round(typeof r == "number" && Number.isFinite(r) && r > 0 ? r : i))), o = Number.isFinite(t) ? t : .67, s = e.MathUtils.clamp(o, .33, 1);
|
|
186
|
+
return s >= .98 ? a : a / Math.max(1, Math.round(a / s));
|
|
187
|
+
}
|
|
188
|
+
export { n as PALETTE_CRUNCHY_16, r as PALETTE_CRUNCHY_64, t as RETRO_COLOR_MODES, f as applyRetroFilteringToMaterial, d as applyRetroTextureFiltering, a as buildPaletteLutData, p as computeRetroDpr, l as getColorQuantVector, c as getPaletteLutTexture };
|
|
@@ -21,6 +21,18 @@ export declare const RETRO_UNIFORMS: {
|
|
|
21
21
|
uPaletteLut: {
|
|
22
22
|
value: THREE.DataTexture;
|
|
23
23
|
};
|
|
24
|
+
uAffineStrength: {
|
|
25
|
+
value: number;
|
|
26
|
+
};
|
|
27
|
+
uGouraudStrength: {
|
|
28
|
+
value: number;
|
|
29
|
+
};
|
|
30
|
+
uN64FilterStrength: {
|
|
31
|
+
value: number;
|
|
32
|
+
};
|
|
33
|
+
uN64TexSize: {
|
|
34
|
+
value: number;
|
|
35
|
+
};
|
|
24
36
|
};
|
|
25
37
|
export declare function getRetroShaderUniforms(): {
|
|
26
38
|
uPs1Grid: {
|
|
@@ -41,8 +53,20 @@ export declare function getRetroShaderUniforms(): {
|
|
|
41
53
|
uPaletteLut: {
|
|
42
54
|
value: THREE.DataTexture;
|
|
43
55
|
};
|
|
56
|
+
uAffineStrength: {
|
|
57
|
+
value: number;
|
|
58
|
+
};
|
|
59
|
+
uGouraudStrength: {
|
|
60
|
+
value: number;
|
|
61
|
+
};
|
|
62
|
+
uN64FilterStrength: {
|
|
63
|
+
value: number;
|
|
64
|
+
};
|
|
65
|
+
uN64TexSize: {
|
|
66
|
+
value: number;
|
|
67
|
+
};
|
|
44
68
|
};
|
|
45
|
-
export type RetroPresetId = "dreamcast" | "ps2-shinobi" | "dsi-crisp" | "psx-chonk" | "clean-hd";
|
|
69
|
+
export type RetroPresetId = "dreamcast" | "n64-emu-1080p" | "n64-psx-hybrid" | "psx-plus" | "ps2-shinobi" | "n64-ultra" | "dsi-crisp" | "psx-chonk" | "psx-raw-1995" | "clean-hd";
|
|
46
70
|
export interface RetroPreset {
|
|
47
71
|
id: RetroPresetId;
|
|
48
72
|
label: string;
|
|
@@ -51,14 +75,18 @@ export interface RetroPreset {
|
|
|
51
75
|
pixelSnapAmount: number;
|
|
52
76
|
colorMode: RetroColorMode;
|
|
53
77
|
ditherScale: number;
|
|
78
|
+
affineAmount: number;
|
|
79
|
+
gouraudAmount: number;
|
|
80
|
+
n64FilterAmount: number;
|
|
81
|
+
fogEnabled: boolean;
|
|
54
82
|
}
|
|
55
83
|
export declare const RETRO_PRESETS: readonly RetroPreset[];
|
|
56
84
|
export declare function getRetroPreset(id: RetroPresetId): RetroPreset;
|
|
57
85
|
export declare function syncRetroUniforms(presetId: RetroPresetId): RetroPreset;
|
|
58
|
-
export declare function syncRetroUniforms(ditherAmount: number, pixelSnapAmount?: number, renderScale?: number, colorMode?: RetroColorMode, ditherScale?: number): void;
|
|
86
|
+
export declare function syncRetroUniforms(ditherAmount: number, pixelSnapAmount?: number, renderScale?: number, colorMode?: RetroColorMode, ditherScale?: number, affineAmount?: number, gouraudAmount?: number, n64FilterAmount?: number): void;
|
|
59
87
|
export declare function syncRetroViewport(fbW: number, fbH: number, effectiveDpr: number): void;
|
|
60
88
|
export declare const GLSL_BAYER_RGB555 = "\nvec3 ps1SrgbToLinear(vec3 s) { vec3 a = clamp(s, 0.0, 1.0); return a * (a * (a * 0.305306011 + 0.682171111) + 0.012522878); }\nvec3 ps1LinearToSrgb(vec3 l) { return max(1.055 * pow(clamp(l, 0.0, 1.0), vec3(0.416666667)) - 0.055, vec3(0.0)); }\nfloat ps1Bayer2(vec2 c) { return (c.y < 0.5) ? (c.x < 0.5 ? 0.0 : 2.0) : (c.x < 0.5 ? 3.0 : 1.0); }\nfloat ps1Bayer4x4(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) + 0.5) / 16.0; }\nfloat ps1Bayer8x8(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 16.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.25), 2.0)) + 0.5) / 64.0; }\nvec3 ps1QuantizeRGB555Mix(vec3 col, vec2 fragCoord, float mixAmt) {\n if (mixAmt <= 0.001) return col;\n vec3 srgb = clamp(col, 0.0, 1.0); float bayer = ps1Bayer4x4(fragCoord * 0.5);\n vec3 c0 = floor(srgb * 31.0) / 31.0, c1 = min(c0 + 1.0 / 31.0, vec3(1.0));\n vec3 l0 = ps1SrgbToLinear(c0), l1 = ps1SrgbToLinear(c1);\n vec3 t = clamp((ps1SrgbToLinear(srgb) - l0) / max(l1 - l0, vec3(1e-5)), 0.0, 1.0);\n return mix(c0, c1, step(vec3(mix(0.5, bayer, clamp(mixAmt, 0.0, 1.0))), t));\n}\nvec3 ps1QuantizeRGB555(vec3 col, vec2 fragCoord) { return ps1QuantizeRGB555Mix(col, fragCoord, 1.0); }\n";
|
|
61
|
-
export declare const GLSL_RETRO_QUANTIZE = "\nuniform float uDitherScale; uniform vec4 uColorQuant; uniform sampler2D uPaletteLut;\n\nvec3 ps1SrgbToLinear(vec3 s) { vec3 a = clamp(s, 0.0, 1.0); return a * (a * (a * 0.305306011 + 0.682171111) + 0.012522878); }\nvec3 ps1LinearToSrgb(vec3 l) { return max(1.055 * pow(clamp(l, 0.0, 1.0), vec3(0.416666667)) - 0.055, vec3(0.0)); }\nfloat ps1Bayer2(vec2 c) { return (c.y < 0.5) ? (c.x < 0.5 ? 0.0 : 2.0) : (c.x < 0.5 ? 3.0 : 1.0); }\nfloat ps1Bayer4x4(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) + 0.5) / 16.0; }\nfloat ps1Bayer8x8(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 16.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.25), 2.0)) + 0.5) / 64.0; }\nvec3 ps1QuantizeRGB555Mix(vec3 col, vec2 fragCoord, float mixAmt) {\n if (mixAmt <= 0.001) return col;\n vec3 srgb = clamp(col, 0.0, 1.0); float bayer = ps1Bayer4x4(fragCoord * 0.5);\n vec3 c0 = floor(srgb * 31.0) / 31.0, c1 = min(c0 + 1.0 / 31.0, vec3(1.0));\n vec3 l0 = ps1SrgbToLinear(c0), l1 = ps1SrgbToLinear(c1);\n vec3 t = clamp((ps1SrgbToLinear(srgb) - l0) / max(l1 - l0, vec3(1e-5)), 0.0, 1.0);\n return mix(c0, c1, step(vec3(mix(0.5, bayer, clamp(mixAmt, 0.0, 1.0))), t));\n}\nvec3 ps1QuantizeRGB555(vec3 col, vec2 fragCoord) { return ps1QuantizeRGB555Mix(col, fragCoord, 1.0); }\n\nfloat ps1BayerDither(vec2 fragCoord) { return ps1Bayer4x4(fragCoord / max(uDitherScale, 0.5)); }\nvec3 ps1SamplePaletteLut(vec3 srgb) {\n vec3 c = clamp(srgb, 0.0, 1.0);\n return texture2D(uPaletteLut, vec2((floor(c.b * 31.0 + 0.5) * 32.0 + floor(c.r * 31.0 + 0.5) + 0.5) / 1024.0, (floor(c.g * 31.0 + 0.5) + 0.5) / 32.0)).rgb;\n}\nvec3 ps1QuantizeRetro(vec3 col, vec2 fragCoord, float ditherSpread) {\n if (uColorQuant.w < 0.5) return col;\n vec3 srgb = clamp(col, 0.0, 1.0); float bayer =
|
|
89
|
+
export declare const GLSL_RETRO_QUANTIZE = "\nuniform float uDitherScale; uniform vec4 uColorQuant; uniform sampler2D uPaletteLut;\n\nvec3 ps1SrgbToLinear(vec3 s) { vec3 a = clamp(s, 0.0, 1.0); return a * (a * (a * 0.305306011 + 0.682171111) + 0.012522878); }\nvec3 ps1LinearToSrgb(vec3 l) { return max(1.055 * pow(clamp(l, 0.0, 1.0), vec3(0.416666667)) - 0.055, vec3(0.0)); }\nfloat ps1Bayer2(vec2 c) { return (c.y < 0.5) ? (c.x < 0.5 ? 0.0 : 2.0) : (c.x < 0.5 ? 3.0 : 1.0); }\nfloat ps1Bayer4x4(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) + 0.5) / 16.0; }\nfloat ps1Bayer8x8(vec2 p) { vec2 f = floor(p); return (ps1Bayer2(mod(f, 2.0)) * 16.0 + ps1Bayer2(mod(floor(f * 0.5), 2.0)) * 4.0 + ps1Bayer2(mod(floor(f * 0.25), 2.0)) + 0.5) / 64.0; }\nvec3 ps1QuantizeRGB555Mix(vec3 col, vec2 fragCoord, float mixAmt) {\n if (mixAmt <= 0.001) return col;\n vec3 srgb = clamp(col, 0.0, 1.0); float bayer = ps1Bayer4x4(fragCoord * 0.5);\n vec3 c0 = floor(srgb * 31.0) / 31.0, c1 = min(c0 + 1.0 / 31.0, vec3(1.0));\n vec3 l0 = ps1SrgbToLinear(c0), l1 = ps1SrgbToLinear(c1);\n vec3 t = clamp((ps1SrgbToLinear(srgb) - l0) / max(l1 - l0, vec3(1e-5)), 0.0, 1.0);\n return mix(c0, c1, step(vec3(mix(0.5, bayer, clamp(mixAmt, 0.0, 1.0))), t));\n}\nvec3 ps1QuantizeRGB555(vec3 col, vec2 fragCoord) { return ps1QuantizeRGB555Mix(col, fragCoord, 1.0); }\n\nfloat ps1BayerDither(vec2 fragCoord) { return ps1Bayer4x4(fragCoord / max(uDitherScale, 0.5)); }\nvec3 ps1SamplePaletteLut(vec3 srgb) {\n vec3 c = clamp(srgb, 0.0, 1.0);\n return texture2D(uPaletteLut, vec2((floor(c.b * 31.0 + 0.5) * 32.0 + floor(c.r * 31.0 + 0.5) + 0.5) / 1024.0, (floor(c.g * 31.0 + 0.5) + 0.5) / 32.0)).rgb;\n}\nvec3 ps1QuantizeRetro(vec3 col, vec2 fragCoord, float ditherSpread) {\n if (uColorQuant.w < 0.5) return col;\n vec3 srgb = clamp(col, 0.0, 1.0); float bayer = ps1Bayer4x4(fragCoord / max(uDitherScale, 0.5)), spread = clamp(ditherSpread, 0.0, 1.0);\n if (uColorQuant.w > 1.5) return ps1SamplePaletteLut(ps1LinearToSrgb(clamp(ps1SrgbToLinear(srgb) + (bayer - 0.5) * (uColorQuant.y * spread), 0.0, 1.0)));\n vec3 levels = max(uColorQuant.rgb, vec3(1.0)), c0 = floor(srgb * levels) / levels, c1 = min(c0 + 1.0 / levels, vec3(1.0));\n vec3 l0 = ps1SrgbToLinear(c0), l1 = ps1SrgbToLinear(c1);\n vec3 t = clamp((ps1SrgbToLinear(srgb) - l0) / max(l1 - l0, vec3(1e-5)), 0.0, 1.0);\n return mix(c0, c1, step(vec3(mix(0.5, bayer, spread)), t));\n}\nvec4 ps1SampleN64ThreePoint(sampler2D tex, vec2 uv, float texSize, float mixStrength) {\n vec4 nearestSample = texture2D(tex, uv);\n if (mixStrength <= 0.001) return nearestSample;\n float ts = max(16.0, texSize);\n vec2 p = uv * ts - 0.5;\n vec2 i = floor(p);\n vec2 f = p - i;\n vec2 inv = 1.0 / vec2(ts);\n vec2 uv00 = (i + vec2(0.5, 0.5)) * inv;\n vec2 uv10 = (i + vec2(1.5, 0.5)) * inv;\n vec2 uv01 = (i + vec2(0.5, 1.5)) * inv;\n vec2 uv11 = (i + vec2(1.5, 1.5)) * inv;\n vec4 c10 = texture2D(tex, uv10);\n vec4 c01 = texture2D(tex, uv01);\n vec4 n64Col;\n if (f.x + f.y < 1.0) {\n vec4 c00 = texture2D(tex, uv00);\n n64Col = c00 + f.x * (c10 - c00) + f.y * (c01 - c00);\n } else {\n vec4 c11 = texture2D(tex, uv11);\n n64Col = c11 + (1.0 - f.y) * (c10 - c11) + (1.0 - f.x) * (c01 - c11);\n }\n return mix(nearestSample, n64Col, clamp(mixStrength, 0.0, 1.0));\n}\n";
|
|
62
90
|
export interface RetroMaterialOptions {
|
|
63
91
|
flatShading?: boolean;
|
|
64
92
|
snap?: number;
|