ugly-game 0.15.65 → 0.15.67
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/assets/gpuCrowd.d.ts +6 -1
- package/dist/assets/gpuCrowd.js +12 -4
- package/dist/assets/gpuProps.d.ts +15 -0
- package/dist/assets/gpuProps.js +11 -6
- package/dist/assets/gpuSkin.d.ts +6 -1
- package/dist/assets/gpuSkin.js +24 -10
- package/dist/depthConvention.d.ts +10 -0
- package/dist/depthConvention.js +28 -0
- package/dist/gpuTaaResolve.d.ts +6 -1
- package/dist/gpuTaaResolve.js +14 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +4 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="@webgpu/types" preserve="true" />
|
|
2
|
+
import { type DepthConvention } from '../depthConvention.js';
|
|
2
3
|
export declare const CROWD_MATERIAL_COUNT = 5;
|
|
3
4
|
export declare const CROWD_RECORD_FLOATS = 24;
|
|
4
5
|
export declare const CROWD_REC_LAYER = 20;
|
|
@@ -687,6 +688,8 @@ export declare class GpuCrowdRenderer {
|
|
|
687
688
|
private device;
|
|
688
689
|
/** Swap-chain format. Held for the render pipeline the draw pass builds. */
|
|
689
690
|
readonly format: GPUTextureFormat;
|
|
691
|
+
/** The caller's scene depth: format, clear and which compare means nearer. */
|
|
692
|
+
readonly depth: DepthConvention;
|
|
690
693
|
private morphPipe;
|
|
691
694
|
private addPipe;
|
|
692
695
|
private normalPipe;
|
|
@@ -795,7 +798,9 @@ export declare class GpuCrowdRenderer {
|
|
|
795
798
|
private skin;
|
|
796
799
|
constructor(device: GPUDevice,
|
|
797
800
|
/** Swap-chain format. Held for the render pipeline the draw pass builds. */
|
|
798
|
-
format: GPUTextureFormat
|
|
801
|
+
format: GPUTextureFormat,
|
|
802
|
+
/** The caller's scene depth: format, clear and which compare means nearer. */
|
|
803
|
+
depth?: DepthConvention);
|
|
799
804
|
/** The rung geometry and pool sizes, once the assets are in. Null before `setAssets`. */
|
|
800
805
|
get assetPlan(): CrowdPlan | null;
|
|
801
806
|
/** The four pools, for the skin pass and for a harness that reads a slot back to check it. */
|
package/dist/assets/gpuCrowd.js
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
// "must match" comment, and a crowd that disagreed would light its characters out of a different
|
|
26
26
|
// number of cascades than the ground they stand on.
|
|
27
27
|
import { MAX_CASCADES } from './gpuSkin';
|
|
28
|
+
import { depthClearValue, FORWARD_DEPTH, nearerCompare, } from '../depthConvention.js';
|
|
28
29
|
import { CROWD_MATERIAL_COUNT as CROWD_MATERIAL_COUNT_VALUE, CROWD_RECORD_FLOATS as CROWD_RECORD_FLOATS_VALUE, CROWD_REC_LAYER as CROWD_REC_LAYER_VALUE, CROWD_REC_MATERIAL as CROWD_REC_MATERIAL_VALUE, CROWD_REC_MODEL as CROWD_REC_MODEL_VALUE, CROWD_REC_PALETTE_SLOT as CROWD_REC_PALETTE_SLOT_VALUE, CROWD_REC_POOL_SLOT as CROWD_REC_POOL_SLOT_VALUE, CROWD_REC_TINT as CROWD_REC_TINT_VALUE, writeCrowdRecord as writeCrowdRecordValue, } from './crowdRecord.js';
|
|
29
30
|
export const CROWD_MATERIAL_COUNT = CROWD_MATERIAL_COUNT_VALUE;
|
|
30
31
|
export const CROWD_RECORD_FLOATS = CROWD_RECORD_FLOATS_VALUE;
|
|
@@ -1427,6 +1428,7 @@ const INITIAL_MERGE_ENTRIES = 4096;
|
|
|
1427
1428
|
export class GpuCrowdRenderer {
|
|
1428
1429
|
device;
|
|
1429
1430
|
format;
|
|
1431
|
+
depth;
|
|
1430
1432
|
morphPipe;
|
|
1431
1433
|
addPipe;
|
|
1432
1434
|
normalPipe;
|
|
@@ -1536,9 +1538,12 @@ export class GpuCrowdRenderer {
|
|
|
1536
1538
|
skin = null;
|
|
1537
1539
|
constructor(device,
|
|
1538
1540
|
/** Swap-chain format. Held for the render pipeline the draw pass builds. */
|
|
1539
|
-
format
|
|
1541
|
+
format,
|
|
1542
|
+
/** The caller's scene depth: format, clear and which compare means nearer. */
|
|
1543
|
+
depth = FORWARD_DEPTH) {
|
|
1540
1544
|
this.device = device;
|
|
1541
1545
|
this.format = format;
|
|
1546
|
+
this.depth = depth;
|
|
1542
1547
|
const sm = device.createShaderModule({ code: MORPH });
|
|
1543
1548
|
this.morphBGL = device.createBindGroupLayout({
|
|
1544
1549
|
entries: CROWD_BINDINGS.morph,
|
|
@@ -1610,9 +1615,9 @@ export class GpuCrowdRenderer {
|
|
|
1610
1615
|
targets: [{ format, ...(st.blend ? { blend: st.blend } : {}) }],
|
|
1611
1616
|
},
|
|
1612
1617
|
depthStencil: {
|
|
1613
|
-
format:
|
|
1618
|
+
format: depth.format,
|
|
1614
1619
|
depthWriteEnabled: st.depthWriteEnabled,
|
|
1615
|
-
depthCompare:
|
|
1620
|
+
depthCompare: nearerCompare(depth),
|
|
1616
1621
|
},
|
|
1617
1622
|
});
|
|
1618
1623
|
this.drawPipe = render(S.opaque);
|
|
@@ -2423,7 +2428,10 @@ export class GpuCrowdRenderer {
|
|
|
2423
2428
|
view: depthView,
|
|
2424
2429
|
...(load
|
|
2425
2430
|
? { depthLoadOp: 'load' }
|
|
2426
|
-
: {
|
|
2431
|
+
: {
|
|
2432
|
+
depthClearValue: depthClearValue(this.depth),
|
|
2433
|
+
depthLoadOp: 'clear',
|
|
2434
|
+
}),
|
|
2427
2435
|
depthStoreOp: 'store',
|
|
2428
2436
|
},
|
|
2429
2437
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="@webgpu/types" preserve="true" />
|
|
2
|
+
import { type DepthConvention } from '../depthConvention.js';
|
|
2
3
|
export declare const MAX_CASCADES = 4;
|
|
3
4
|
/**
|
|
4
5
|
* Per-world surface + motion parameters.
|
|
@@ -81,6 +82,12 @@ export interface PropRendererOptions extends Partial<PropLook> {
|
|
|
81
82
|
* occluder pass is unaffected (always single-sample).
|
|
82
83
|
*/
|
|
83
84
|
sampleCount?: 1 | 4;
|
|
85
|
+
/**
|
|
86
|
+
* The caller's scene depth convention for every pipeline that targets its depth view. Default
|
|
87
|
+
* FORWARD_DEPTH (depth24plus, `less`). REVERSED_DEPTH needs a depth32float view and a projection
|
|
88
|
+
* that maps near to 1 and far to 0. The sun-shadow occluder keeps its own depth domain.
|
|
89
|
+
*/
|
|
90
|
+
depth?: DepthConvention;
|
|
84
91
|
}
|
|
85
92
|
export interface PropMesh {
|
|
86
93
|
/** Offline-cooked deformation bounds. Omit for procedural meshes. */
|
|
@@ -103,6 +110,12 @@ export interface PropMesh {
|
|
|
103
110
|
transmission?: number;
|
|
104
111
|
/** Display-referred albedo render texture, bypassing lighting/tone mapping. */
|
|
105
112
|
unlit?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Self-lit surface (flames, embers, lamps): vertex colour × albedo texture,
|
|
115
|
+
* display-referred, bypassing lighting and tone mapping but still fogged
|
|
116
|
+
* with distance. Unlike `unlit`, vertex colours count.
|
|
117
|
+
*/
|
|
118
|
+
glow?: boolean;
|
|
106
119
|
/** Caller-owned linear occlusion/roughness/metalness map (RGB). */
|
|
107
120
|
ormMap?: GPUTexture;
|
|
108
121
|
normalScale?: number;
|
|
@@ -318,6 +331,8 @@ export declare class GpuPropsRenderer {
|
|
|
318
331
|
private look;
|
|
319
332
|
/** MSAA sample count the draw pipelines were built with. */
|
|
320
333
|
readonly sampleCount: 1 | 4;
|
|
334
|
+
/** The caller's scene depth convention, fixed at construction. */
|
|
335
|
+
readonly depth: DepthConvention;
|
|
321
336
|
/** Per-world look + motion. Defaults are inert: no sway, no grain, no grade. */
|
|
322
337
|
private world;
|
|
323
338
|
private phase;
|
package/dist/assets/gpuProps.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// The cull reuses the SAME plane extraction the rest of the engine uses. A second, local copy of
|
|
8
8
|
// Gribb-Hartmann is exactly how a cull ends up disagreeing with the projection it is culling for.
|
|
9
9
|
import { frustumPlanes } from '../mat4';
|
|
10
|
+
import { FORWARD_DEPTH, nearerCompare, } from '../depthConvention.js';
|
|
10
11
|
export const MAX_CASCADES = 4; // must match gpuShadow's
|
|
11
12
|
const SHADER = /* wgsl */ `
|
|
12
13
|
// wind = (dirX, dirZ, amplitude, phase) — sway, amplitude scaled by the world's air density
|
|
@@ -438,6 +439,7 @@ fn linearToSrgb(c: vec3<f32>) -> vec3<f32> {
|
|
|
438
439
|
lit = toneMap(radiance);
|
|
439
440
|
}
|
|
440
441
|
// A display-referred render texture (rear-view camera) is already lit.
|
|
442
|
+
if (mtl.optics.y > 1.5) { return vec4(mix(tex.rgb * i.c, u.fog.xyz, f), mtl.mat.x); }
|
|
441
443
|
if (mtl.optics.y > 0.5) { return vec4(tex.rgb, mtl.mat.x); }
|
|
442
444
|
return vec4(mix(lit, u.fog.xyz, f), opacity);
|
|
443
445
|
}`;
|
|
@@ -667,6 +669,8 @@ export class GpuPropsRenderer {
|
|
|
667
669
|
look = { ...DEFAULT_LOOK };
|
|
668
670
|
/** MSAA sample count the draw pipelines were built with. */
|
|
669
671
|
sampleCount;
|
|
672
|
+
/** The caller's scene depth convention, fixed at construction. */
|
|
673
|
+
depth;
|
|
670
674
|
/** Per-world look + motion. Defaults are inert: no sway, no grain, no grade. */
|
|
671
675
|
world = {
|
|
672
676
|
windDir: [1, 0],
|
|
@@ -710,11 +714,12 @@ export class GpuPropsRenderer {
|
|
|
710
714
|
}
|
|
711
715
|
constructor(device, format, options = {}) {
|
|
712
716
|
this.device = device;
|
|
713
|
-
const { sampleCount = 1, ...look } = options;
|
|
717
|
+
const { sampleCount = 1, depth = FORWARD_DEPTH, ...look } = options;
|
|
714
718
|
// Runtime guard for untyped callers: WebGPU only guarantees 1 and 4.
|
|
715
719
|
if (![1, 4].includes(sampleCount))
|
|
716
720
|
throw new RangeError(`Unsupported prop sampleCount ${String(sampleCount)}`);
|
|
717
721
|
this.sampleCount = sampleCount;
|
|
722
|
+
this.depth = depth;
|
|
718
723
|
this.setLook(look);
|
|
719
724
|
const sm = device.createShaderModule({ code: SHADER });
|
|
720
725
|
// The three groups the SHADER declares, written out so BOTH render pipelines share them. Under
|
|
@@ -815,9 +820,9 @@ export class GpuPropsRenderer {
|
|
|
815
820
|
...commonDraw,
|
|
816
821
|
fragment: { module: sm, entryPoint: 'fs', targets: [{ format }] },
|
|
817
822
|
depthStencil: {
|
|
818
|
-
format:
|
|
823
|
+
format: depth.format,
|
|
819
824
|
depthWriteEnabled: true,
|
|
820
|
-
depthCompare:
|
|
825
|
+
depthCompare: nearerCompare(depth),
|
|
821
826
|
},
|
|
822
827
|
};
|
|
823
828
|
this.pipe = device.createRenderPipeline(opaqueDescriptor);
|
|
@@ -847,9 +852,9 @@ export class GpuPropsRenderer {
|
|
|
847
852
|
// in submission order — the nearer one clips the farther. For the glassy species (ice
|
|
848
853
|
// crystals, tektite shards) that is the right trade.
|
|
849
854
|
depthStencil: {
|
|
850
|
-
format:
|
|
855
|
+
format: depth.format,
|
|
851
856
|
depthWriteEnabled: true,
|
|
852
|
-
depthCompare:
|
|
857
|
+
depthCompare: nearerCompare(depth),
|
|
853
858
|
},
|
|
854
859
|
};
|
|
855
860
|
this.blendPipe = device.createRenderPipeline(blendDescriptor);
|
|
@@ -1161,7 +1166,7 @@ export class GpuPropsRenderer {
|
|
|
1161
1166
|
Math.max(0, Math.min(1, m.pearlStrength ?? 0)),
|
|
1162
1167
|
0,
|
|
1163
1168
|
Math.max(0, Math.min(1, m.transmission ?? 0)),
|
|
1164
|
-
m.unlit ? 1 : 0,
|
|
1169
|
+
m.unlit ? 1 : m.glow ? 2 : 0,
|
|
1165
1170
|
0,
|
|
1166
1171
|
0,
|
|
1167
1172
|
]);
|
package/dist/assets/gpuSkin.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="@webgpu/types" preserve="true" />
|
|
2
|
+
import { type DepthConvention } from '../depthConvention.js';
|
|
2
3
|
export interface SkinCreature {
|
|
3
4
|
rest: Float32Array;
|
|
4
5
|
normals: Float32Array;
|
|
@@ -130,6 +131,8 @@ export interface SkinCreaturePose {
|
|
|
130
131
|
export declare const MAX_CASCADES = 4;
|
|
131
132
|
export declare class GpuSkinRenderer {
|
|
132
133
|
private device;
|
|
134
|
+
/** The caller's scene depth: format, clear and which compare means nearer. */
|
|
135
|
+
readonly depth: DepthConvention;
|
|
133
136
|
private skinPipe;
|
|
134
137
|
private drawPipe;
|
|
135
138
|
/**
|
|
@@ -168,7 +171,9 @@ export declare class GpuSkinRenderer {
|
|
|
168
171
|
private texIds;
|
|
169
172
|
private nextTexId;
|
|
170
173
|
private texId;
|
|
171
|
-
constructor(device: GPUDevice, format: GPUTextureFormat
|
|
174
|
+
constructor(device: GPUDevice, format: GPUTextureFormat,
|
|
175
|
+
/** The caller's scene depth: format, clear and which compare means nearer. */
|
|
176
|
+
depth?: DepthConvention);
|
|
172
177
|
setCreatures(list: SkinCreature[]): void;
|
|
173
178
|
/**
|
|
174
179
|
* Upload a new pose without reinstalling geometry. The list addresses the current
|
package/dist/assets/gpuSkin.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
/// <reference types="@webgpu/types" preserve="true" />
|
|
2
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
3
|
+
// GPU SKIN — a reusable WebGPU renderer for skinned creatures (PLATFORM). A compute pass deforms the
|
|
4
|
+
// rest mesh (AND its normals) by each creature's bone palette; the render pass draws them with the SAME
|
|
5
|
+
// lighting model as the terrain/prop renderers — sun lambert on smooth per-vertex normals + ambient +
|
|
6
|
+
// distance fog — so creatures sit in the scene consistently instead of looking flat/mismatched.
|
|
7
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
8
|
+
import { depthClearValue, FORWARD_DEPTH, nearerCompare, } from '../depthConvention.js';
|
|
2
9
|
/**
|
|
3
10
|
* Every GPUBuffer owned by one packed creature, stated exhaustively.
|
|
4
11
|
*
|
|
@@ -172,6 +179,7 @@ const DRAW = drawWgsl(VS_ATTR);
|
|
|
172
179
|
const DRAW_INST = drawWgsl(VS_INST);
|
|
173
180
|
export class GpuSkinRenderer {
|
|
174
181
|
device;
|
|
182
|
+
depth;
|
|
175
183
|
skinPipe;
|
|
176
184
|
drawPipe;
|
|
177
185
|
/**
|
|
@@ -222,8 +230,11 @@ export class GpuSkinRenderer {
|
|
|
222
230
|
}
|
|
223
231
|
return id;
|
|
224
232
|
}
|
|
225
|
-
constructor(device, format
|
|
233
|
+
constructor(device, format,
|
|
234
|
+
/** The caller's scene depth: format, clear and which compare means nearer. */
|
|
235
|
+
depth = FORWARD_DEPTH) {
|
|
226
236
|
this.device = device;
|
|
237
|
+
this.depth = depth;
|
|
227
238
|
const sm = device.createShaderModule({ code: SKIN });
|
|
228
239
|
this.skinPipe = device.createComputePipeline({
|
|
229
240
|
layout: 'auto',
|
|
@@ -337,9 +348,9 @@ export class GpuSkinRenderer {
|
|
|
337
348
|
...common,
|
|
338
349
|
fragment: { module: dm, entryPoint: 'fs', targets: [{ format }] },
|
|
339
350
|
depthStencil: {
|
|
340
|
-
format:
|
|
351
|
+
format: depth.format,
|
|
341
352
|
depthWriteEnabled: true,
|
|
342
|
-
depthCompare:
|
|
353
|
+
depthCompare: nearerCompare(depth),
|
|
343
354
|
},
|
|
344
355
|
});
|
|
345
356
|
this.blendPipe = device.createRenderPipeline({
|
|
@@ -376,12 +387,12 @@ export class GpuSkinRenderer {
|
|
|
376
387
|
],
|
|
377
388
|
},
|
|
378
389
|
depthStencil: {
|
|
379
|
-
format:
|
|
390
|
+
format: depth.format,
|
|
380
391
|
// ⚠️ OFF. A translucent surface that writes depth hides what is behind it, which is exactly
|
|
381
392
|
// what the caller asked to see through. It still TESTS against depth, so an opaque creature
|
|
382
393
|
// in front still occludes it.
|
|
383
394
|
depthWriteEnabled: false,
|
|
384
|
-
depthCompare:
|
|
395
|
+
depthCompare: nearerCompare(depth),
|
|
385
396
|
},
|
|
386
397
|
});
|
|
387
398
|
// ⚠️ ITS OWN LAYOUT WITH A FOURTH GROUP, and its own shader module. The instanced vertex stage
|
|
@@ -400,9 +411,9 @@ export class GpuSkinRenderer {
|
|
|
400
411
|
...instCommon,
|
|
401
412
|
fragment: { module: im, entryPoint: 'fs', targets: [{ format }] },
|
|
402
413
|
depthStencil: {
|
|
403
|
-
format:
|
|
414
|
+
format: depth.format,
|
|
404
415
|
depthWriteEnabled: true,
|
|
405
|
-
depthCompare:
|
|
416
|
+
depthCompare: nearerCompare(depth),
|
|
406
417
|
},
|
|
407
418
|
});
|
|
408
419
|
this.instBlendPipe = device.createRenderPipeline({
|
|
@@ -425,9 +436,9 @@ export class GpuSkinRenderer {
|
|
|
425
436
|
],
|
|
426
437
|
},
|
|
427
438
|
depthStencil: {
|
|
428
|
-
format:
|
|
439
|
+
format: depth.format,
|
|
429
440
|
depthWriteEnabled: false,
|
|
430
|
-
depthCompare:
|
|
441
|
+
depthCompare: nearerCompare(depth),
|
|
431
442
|
},
|
|
432
443
|
});
|
|
433
444
|
const dummy = device.createTexture({
|
|
@@ -773,7 +784,10 @@ export class GpuSkinRenderer {
|
|
|
773
784
|
view: depthView,
|
|
774
785
|
...(load
|
|
775
786
|
? { depthLoadOp: 'load' }
|
|
776
|
-
: {
|
|
787
|
+
: {
|
|
788
|
+
depthClearValue: depthClearValue(this.depth),
|
|
789
|
+
depthLoadOp: 'clear',
|
|
790
|
+
}),
|
|
777
791
|
depthStoreOp: 'store',
|
|
778
792
|
},
|
|
779
793
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface DepthConvention {
|
|
2
|
+
readonly format: GPUTextureFormat;
|
|
3
|
+
readonly reversed: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare const FORWARD_DEPTH: DepthConvention;
|
|
6
|
+
export declare const REVERSED_DEPTH: DepthConvention;
|
|
7
|
+
/** The compare under which the NEARER fragment passes. */
|
|
8
|
+
export declare function nearerCompare(c: DepthConvention, orEqual?: boolean): GPUCompareFunction;
|
|
9
|
+
/** The depth a cleared buffer holds: the far plane, 1 forward and 0 reversed. */
|
|
10
|
+
export declare function depthClearValue(c: DepthConvention): number;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// SCENE DEPTH CONVENTION. Which way the caller's scene depth buffer points, so a renderer that draws
|
|
2
|
+
// into someone else's depth view builds pipelines that match it.
|
|
3
|
+
//
|
|
4
|
+
// FORWARD: depth24plus, cleared to 1, nearer wins with `less`. The default and the historical behaviour.
|
|
5
|
+
// REVERSED: depth32float, cleared to 0, nearer wins with `greater`. The caller's projection maps the
|
|
6
|
+
// near plane to 1 and the far plane to 0, which spends the float exponent on distance: a planet-scale
|
|
7
|
+
// far/near ratio keeps sub-block depth resolution at kilometres, where a 24-bit forward buffer resolves
|
|
8
|
+
// only blocks and distant surfaces z-fight.
|
|
9
|
+
//
|
|
10
|
+
// Shadow maps are their own depth domain and do not follow this; each renderer keeps its own.
|
|
11
|
+
export const FORWARD_DEPTH = {
|
|
12
|
+
format: 'depth24plus',
|
|
13
|
+
reversed: false,
|
|
14
|
+
};
|
|
15
|
+
export const REVERSED_DEPTH = {
|
|
16
|
+
format: 'depth32float',
|
|
17
|
+
reversed: true,
|
|
18
|
+
};
|
|
19
|
+
/** The compare under which the NEARER fragment passes. */
|
|
20
|
+
export function nearerCompare(c, orEqual = false) {
|
|
21
|
+
if (c.reversed)
|
|
22
|
+
return orEqual ? 'greater-equal' : 'greater';
|
|
23
|
+
return orEqual ? 'less-equal' : 'less';
|
|
24
|
+
}
|
|
25
|
+
/** The depth a cleared buffer holds: the far plane, 1 forward and 0 reversed. */
|
|
26
|
+
export function depthClearValue(c) {
|
|
27
|
+
return c.reversed ? 0 : 1;
|
|
28
|
+
}
|
package/dist/gpuTaaResolve.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/// <reference types="@webgpu/types" preserve="true" />
|
|
2
|
+
import { type DepthConvention } from './depthConvention.js';
|
|
2
3
|
/** Halton(2,3) sub-pixel jitter for frame `i`, in CLIP space. Multiply into the projection. */
|
|
3
4
|
export declare function haltonJitter(i: number, w: number, h: number, samples?: number): [number, number];
|
|
4
5
|
export declare class GpuTaaResolve {
|
|
6
|
+
/** The caller's scene depth. The resolve is convention-agnostic (see the header); recorded here. */
|
|
7
|
+
readonly depth: DepthConvention;
|
|
5
8
|
private device;
|
|
6
9
|
private format;
|
|
7
10
|
private pipe;
|
|
@@ -18,7 +21,9 @@ export declare class GpuTaaResolve {
|
|
|
18
21
|
private w;
|
|
19
22
|
private h;
|
|
20
23
|
private primed;
|
|
21
|
-
constructor(device: GPUDevice, format: GPUTextureFormat
|
|
24
|
+
constructor(device: GPUDevice, format: GPUTextureFormat,
|
|
25
|
+
/** The caller's scene depth. The resolve is convention-agnostic (see the header); recorded here. */
|
|
26
|
+
depth?: DepthConvention);
|
|
22
27
|
/** (Re)allocate history at the render size. Also invalidates history — a resize is a cut. */
|
|
23
28
|
resize(w: number, h: number, colorView: GPUTextureView, depthView: GPUTextureView): void;
|
|
24
29
|
/** Bind group i READS history[i]; the same frame WRITES history[1-i]. */
|
package/dist/gpuTaaResolve.js
CHANGED
|
@@ -23,10 +23,18 @@
|
|
|
23
23
|
// (an MRT motion target on the geometry pass), and this pass gains a `motionView` input rather than
|
|
24
24
|
// being replaced.
|
|
25
25
|
//
|
|
26
|
-
//
|
|
26
|
+
// DEPTH CONVENTION. The pass reads depth only to unproject it through `invCurrVP`, so it is agnostic
|
|
27
|
+
// to the direction of the caller's depth buffer as long as `invCurrVP`/`prevVP` are built from the
|
|
28
|
+
// SAME projection that rasterized it: a reversed projection (near 1, far 0) inverts to the same world
|
|
29
|
+
// point a forward one does, and `pc.w` (the history depth) is the eye depth either way. The
|
|
30
|
+
// orthographic test reads |invCurrVP[2].w|, whose sign is all a reversed projection changes. The
|
|
31
|
+
// constructor's `depth` records the convention for callers.
|
|
32
|
+
//
|
|
33
|
+
// Sky pixels sit at the far-plane clear (1.0 forward, 0.0 reversed). Unprojecting them yields a point on the far plane, which reprojects
|
|
27
34
|
// correctly under camera ROTATION and slightly wrongly under camera TRANSLATION -- the parallax of
|
|
28
35
|
// something infinitely far away is zero, and the far plane is not infinite. At normal draw
|
|
29
36
|
// distances the error is far below a pixel.
|
|
37
|
+
import { FORWARD_DEPTH } from './depthConvention.js';
|
|
30
38
|
/** Halton(2,3) sub-pixel jitter for frame `i`, in CLIP space. Multiply into the projection. */
|
|
31
39
|
export function haltonJitter(i, w, h, samples = 8) {
|
|
32
40
|
const radical = (n, base) => {
|
|
@@ -180,6 +188,7 @@ struct ROut { @location(0) screen: vec4<f32>, @location(1) hist: vec4<f32> };
|
|
|
180
188
|
}
|
|
181
189
|
`;
|
|
182
190
|
export class GpuTaaResolve {
|
|
191
|
+
depth;
|
|
183
192
|
device;
|
|
184
193
|
format;
|
|
185
194
|
pipe;
|
|
@@ -196,7 +205,10 @@ export class GpuTaaResolve {
|
|
|
196
205
|
w = 0;
|
|
197
206
|
h = 0;
|
|
198
207
|
primed = false;
|
|
199
|
-
constructor(device, format
|
|
208
|
+
constructor(device, format,
|
|
209
|
+
/** The caller's scene depth. The resolve is convention-agnostic (see the header); recorded here. */
|
|
210
|
+
depth = FORWARD_DEPTH) {
|
|
211
|
+
this.depth = depth;
|
|
200
212
|
this.device = device;
|
|
201
213
|
this.format = format;
|
|
202
214
|
const mod = device.createShaderModule({ code: RESOLVE_WGSL });
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ugly-game",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.67",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
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
21
|
"lint": "ugly-app lint",
|
|
22
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",
|
|
23
|
+
"test": "node --experimental-strip-types --import ./tools/tsResolve.mjs --test src/*.test.mts && pnpm run test:gpu-skin && pnpm run test:depth-convention",
|
|
24
24
|
"test:flight": "node --experimental-strip-types --import ./tools/tsResolve.mjs --test src/flight*.test.mts",
|
|
25
25
|
"test:flight-browser": "playwright test -c playwright.flight.config.ts",
|
|
26
26
|
"test:props-browser": "playwright test -c playwright.props.config.ts",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"test:package-types": "node tools/packageTypesSmoke.mjs",
|
|
30
30
|
"pretty": "prettier --write .",
|
|
31
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"
|
|
32
|
+
"test:gpu-skin": "node --experimental-transform-types --import ./tools/tsResolve.mjs --test src/assets/gpuSkin.test.mts",
|
|
33
|
+
"test:depth-convention": "node --experimental-transform-types --import ./tools/tsResolve.mjs --test src/assets/depthConvention.test.mts"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
36
|
"@webgpu/types": "^0.1.40",
|