ugly-game 0.15.60 → 0.15.61
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/gpuTaaResolve.d.ts +5 -0
- package/dist/gpuTaaResolve.js +55 -4
- package/package.json +18 -17
package/dist/gpuTaaResolve.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare class GpuTaaResolve {
|
|
|
7
7
|
private pipe;
|
|
8
8
|
private uBuf;
|
|
9
9
|
private u;
|
|
10
|
+
private dirtyRects;
|
|
10
11
|
private samp;
|
|
11
12
|
private hist;
|
|
12
13
|
private histView;
|
|
@@ -24,6 +25,10 @@ export declare class GpuTaaResolve {
|
|
|
24
25
|
setInputs(colorView: GPUTextureView, depthView: GPUTextureView): void;
|
|
25
26
|
/** Throw the history away — camera cuts, teleports, origin rebases, pause→resume. */
|
|
26
27
|
invalidate(): void;
|
|
28
|
+
/** Discard history in a normalized framebuffer rectangle on the next frame.
|
|
29
|
+
* Caller includes old/new projected bounds and its sampling guard band.
|
|
30
|
+
* Overflow falls back to a full reset, never to stale geometry history. */
|
|
31
|
+
invalidateRect(rect: readonly [number, number, number, number]): void;
|
|
27
32
|
/**
|
|
28
33
|
* Resolve one frame. `invCurrVP` inverts the UNJITTERED current view-projection; `prevVP` is the
|
|
29
34
|
* previous frame's UNJITTERED view-projection. Jitter belongs in the geometry pass's projection
|
package/dist/gpuTaaResolve.js
CHANGED
|
@@ -48,7 +48,8 @@ struct RU {
|
|
|
48
48
|
prevVP: mat4x4<f32>,
|
|
49
49
|
texel: vec4<f32>, // xy = 1/size, zw = size
|
|
50
50
|
ctrl: vec4<f32>, // x = history blend, y = enabled, z = reset, w = clip sigma
|
|
51
|
-
depthControl: vec4<f32>, // x = disocclusion rejection enabled
|
|
51
|
+
depthControl: vec4<f32>, // x = disocclusion rejection enabled; y = dirty rectangle count
|
|
52
|
+
dirtyRects: array<vec4<f32>,16>, // normalized framebuffer UV, min.xy/max.zw
|
|
52
53
|
};
|
|
53
54
|
@group(0) @binding(0) var<uniform> ru: RU;
|
|
54
55
|
@group(0) @binding(1) var histSamp: sampler;
|
|
@@ -79,8 +80,15 @@ struct ROut { @location(0) screen: vec4<f32>, @location(1) hist: vec4<f32> };
|
|
|
79
80
|
let perspective = abs(ru.invCurrVP[2].w) > 0.000001;
|
|
80
81
|
let eyeDepth = 1.0 / max(abs(wp4.w), 0.00000001);
|
|
81
82
|
let historyDepth = log2(1.0 + eyeDepth);
|
|
82
|
-
//
|
|
83
|
-
|
|
83
|
+
// Retire only the affected footprint when streamed geometry changes. The
|
|
84
|
+
// count is normally zero; this adds no texture reads or extra render pass.
|
|
85
|
+
var dirty = false;
|
|
86
|
+
for (var j = 0u; j < u32(ru.depthControl.y); j++) {
|
|
87
|
+
let rect = ru.dirtyRects[j];
|
|
88
|
+
dirty = dirty || (all(uv >= rect.xy) && all(uv <= rect.zw));
|
|
89
|
+
}
|
|
90
|
+
// Disabled, camera cut, or changed region: current color is authoritative.
|
|
91
|
+
if (ru.ctrl.y < 0.5 || ru.ctrl.z > 0.5 || dirty) { o.screen = vec4(cur, 1.0); o.hist = vec4(cur, historyDepth); return o; }
|
|
84
92
|
|
|
85
93
|
// ANTI-GHOSTING CLAMP, by VARIANCE rather than by min/max. A raw 3x3 min/max box is enormous over
|
|
86
94
|
// high-frequency detail -- a voxel world's textured terrain spans most of the range inside any
|
|
@@ -145,7 +153,8 @@ export class GpuTaaResolve {
|
|
|
145
153
|
format;
|
|
146
154
|
pipe;
|
|
147
155
|
uBuf;
|
|
148
|
-
u = new Float32Array(
|
|
156
|
+
u = new Float32Array(108); // matrices, controls and16dirty rectangles
|
|
157
|
+
dirtyRects = [];
|
|
149
158
|
samp;
|
|
150
159
|
hist = [];
|
|
151
160
|
histView = [];
|
|
@@ -216,6 +225,44 @@ export class GpuTaaResolve {
|
|
|
216
225
|
/** Throw the history away — camera cuts, teleports, origin rebases, pause→resume. */
|
|
217
226
|
invalidate() {
|
|
218
227
|
this.primed = false;
|
|
228
|
+
this.dirtyRects.length = 0;
|
|
229
|
+
}
|
|
230
|
+
/** Discard history in a normalized framebuffer rectangle on the next frame.
|
|
231
|
+
* Caller includes old/new projected bounds and its sampling guard band.
|
|
232
|
+
* Overflow falls back to a full reset, never to stale geometry history. */
|
|
233
|
+
invalidateRect(rect) {
|
|
234
|
+
if (!rect.every(Number.isFinite) || rect[0] > rect[2] || rect[1] > rect[3])
|
|
235
|
+
throw new Error('TAA invalidation requires finite ordered UV bounds');
|
|
236
|
+
if (!this.primed)
|
|
237
|
+
return;
|
|
238
|
+
const r = [
|
|
239
|
+
Math.max(0, rect[0]),
|
|
240
|
+
Math.max(0, rect[1]),
|
|
241
|
+
Math.min(1, rect[2]),
|
|
242
|
+
Math.min(1, rect[3]),
|
|
243
|
+
];
|
|
244
|
+
if (r[0] >= r[2] || r[1] >= r[3])
|
|
245
|
+
return;
|
|
246
|
+
// Coalesce intersecting regions, retaining a conservative union. Restart
|
|
247
|
+
// after a merge because the enlarged rectangle may touch earlier ones.
|
|
248
|
+
for (let j = 0; j < this.dirtyRects.length;) {
|
|
249
|
+
const a = this.dirtyRects[j];
|
|
250
|
+
if (r[0] <= a[2] && r[2] >= a[0] && r[1] <= a[3] && r[3] >= a[1]) {
|
|
251
|
+
r[0] = Math.min(r[0], a[0]);
|
|
252
|
+
r[1] = Math.min(r[1], a[1]);
|
|
253
|
+
r[2] = Math.max(r[2], a[2]);
|
|
254
|
+
r[3] = Math.max(r[3], a[3]);
|
|
255
|
+
this.dirtyRects.splice(j, 1);
|
|
256
|
+
j = 0;
|
|
257
|
+
}
|
|
258
|
+
else
|
|
259
|
+
j++;
|
|
260
|
+
}
|
|
261
|
+
if (this.dirtyRects.length === 16) {
|
|
262
|
+
this.invalidate();
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
this.dirtyRects.push(r);
|
|
219
266
|
}
|
|
220
267
|
/**
|
|
221
268
|
* Resolve one frame. `invCurrVP` inverts the UNJITTERED current view-projection; `prevVP` is the
|
|
@@ -246,6 +293,10 @@ export class GpuTaaResolve {
|
|
|
246
293
|
(this.format === 'rgba16float' || this.format === 'rgba32float')
|
|
247
294
|
? 1
|
|
248
295
|
: 0;
|
|
296
|
+
this.u[41] = this.dirtyRects.length;
|
|
297
|
+
for (let j = 0; j < this.dirtyRects.length; j++)
|
|
298
|
+
this.u.set(this.dirtyRects[j], 44 + j * 4);
|
|
299
|
+
this.dirtyRects.length = 0;
|
|
249
300
|
this.device.queue.writeBuffer(this.uBuf, 0, this.u);
|
|
250
301
|
const pass = enc.beginRenderPass({
|
|
251
302
|
colorAttachments: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ugly-game",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.61",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -15,6 +15,22 @@
|
|
|
15
15
|
"files": [
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"preinstall": "npx only-allow pnpm",
|
|
20
|
+
"build": "tsc -p tsconfig.json && mkdir -p dist/assets/basis && cp src/assets/basis/basis_transcoder.js src/assets/basis/basis_transcoder.bin dist/assets/basis/",
|
|
21
|
+
"lint": "ugly-app lint",
|
|
22
|
+
"lint:fix": "ugly-app lint --fix",
|
|
23
|
+
"test": "node --experimental-strip-types --import ./tools/tsResolve.mjs --test src/*.test.mts && pnpm run test:gpu-skin",
|
|
24
|
+
"test:flight": "node --experimental-strip-types --import ./tools/tsResolve.mjs --test src/flight*.test.mts",
|
|
25
|
+
"test:flight-browser": "playwright test -c playwright.flight.config.ts",
|
|
26
|
+
"test:props-browser": "playwright test -c playwright.props.config.ts",
|
|
27
|
+
"test:flight-perf": "playwright test -c playwright.flight.config.ts --grep 'CPU and retained-memory'",
|
|
28
|
+
"test:types": "tsc -p tsconfig.test.json",
|
|
29
|
+
"test:package-types": "node tools/packageTypesSmoke.mjs",
|
|
30
|
+
"pretty": "prettier --write .",
|
|
31
|
+
"prepublishOnly": "pnpm run pretty && ugly-app lint && tsc -p tsconfig.json && mkdir -p dist/assets/basis && cp src/assets/basis/basis_transcoder.js src/assets/basis/basis_transcoder.bin dist/assets/basis/",
|
|
32
|
+
"test:gpu-skin": "node --experimental-transform-types --import ./tools/tsResolve.mjs --test src/assets/gpuSkin.test.mts"
|
|
33
|
+
},
|
|
18
34
|
"dependencies": {
|
|
19
35
|
"@webgpu/types": "^0.1.40",
|
|
20
36
|
"meshoptimizer": "^1.2.0"
|
|
@@ -30,20 +46,5 @@
|
|
|
30
46
|
"typescript": "^5.6.0",
|
|
31
47
|
"ugly-app": "^0.1.841",
|
|
32
48
|
"wesl": "0.7.28"
|
|
33
|
-
},
|
|
34
|
-
"scripts": {
|
|
35
|
-
"preinstall": "npx only-allow pnpm",
|
|
36
|
-
"build": "tsc -p tsconfig.json && mkdir -p dist/assets/basis && cp src/assets/basis/basis_transcoder.js src/assets/basis/basis_transcoder.bin dist/assets/basis/",
|
|
37
|
-
"lint": "ugly-app lint",
|
|
38
|
-
"lint:fix": "ugly-app lint --fix",
|
|
39
|
-
"test": "node --experimental-strip-types --import ./tools/tsResolve.mjs --test src/*.test.mts && pnpm run test:gpu-skin",
|
|
40
|
-
"test:flight": "node --experimental-strip-types --import ./tools/tsResolve.mjs --test src/flight*.test.mts",
|
|
41
|
-
"test:flight-browser": "playwright test -c playwright.flight.config.ts",
|
|
42
|
-
"test:props-browser": "playwright test -c playwright.props.config.ts",
|
|
43
|
-
"test:flight-perf": "playwright test -c playwright.flight.config.ts --grep 'CPU and retained-memory'",
|
|
44
|
-
"test:types": "tsc -p tsconfig.test.json",
|
|
45
|
-
"test:package-types": "node tools/packageTypesSmoke.mjs",
|
|
46
|
-
"pretty": "prettier --write .",
|
|
47
|
-
"test:gpu-skin": "node --experimental-transform-types --import ./tools/tsResolve.mjs --test src/assets/gpuSkin.test.mts"
|
|
48
49
|
}
|
|
49
|
-
}
|
|
50
|
+
}
|