ugly-game 0.15.43 → 0.15.44

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.
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  export declare const CROWD_MATERIAL_COUNT = 5;
2
3
  export declare const CROWD_RECORD_FLOATS = 24;
3
4
  export declare const CROWD_REC_LAYER = 20;
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  // ─────────────────────────────────────────────────────────────────────────────
2
3
  // GPU CROWD — thousands of individually-shaped, individually-animated characters.
3
4
  //
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  export declare const MAX_CASCADES = 4;
2
3
  /**
3
4
  * Per-world surface + motion parameters.
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  // ─────────────────────────────────────────────────────────────────────────────
2
3
  // GPU PROPS — instanced static-mesh renderer for scattered nature props (PLATFORM). Draws each cooked
3
4
  // model (tree/rock/bush/…) many times at per-instance world transforms, lit + fogged to match the
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  export interface SkinCreature {
2
3
  rest: Float32Array;
3
4
  normals: Float32Array;
@@ -1,9 +1,4 @@
1
- // ─────────────────────────────────────────────────────────────────────────────
2
- // GPU SKIN — a reusable WebGPU renderer for skinned creatures (PLATFORM). A compute pass deforms the
3
- // rest mesh (AND its normals) by each creature's bone palette; the render pass draws them with the SAME
4
- // lighting model as the terrain/prop renderers — sun lambert on smooth per-vertex normals + ambient +
5
- // distance fog — so creatures sit in the scene consistently instead of looking flat/mismatched.
6
- // ─────────────────────────────────────────────────────────────────────────────
1
+ /// <reference types="@webgpu/types" preserve="true" />
7
2
  export const MAX_CASCADES = 4; // must match gpuShadow's
8
3
  const SKIN = /* wgsl */ `
9
4
  @group(0) @binding(0) var<storage,read> rest: array<vec4f>;
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  export interface TranscodedTexture {
2
3
  texture: GPUTexture;
3
4
  format: GPUTextureFormat;
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  // Runtime Basis Universal transcoder → GPU-compressed WebGPU texture. The runtime half of
2
3
  // design/asset-streaming.md §3/§4: a cooked .ugm carries textures as ETC1S KTX2 (see
3
4
  // demo/cli/assets/texture.ts cookTextureBasis), and at load we transcode them to whatever compressed
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  export interface FrameStats {
2
3
  meanLum: number;
3
4
  minLum: number;
@@ -1,9 +1,4 @@
1
- // FULL-FRAME visual-regression harness: render a pinned deterministic scene to an offscreen
2
- // target, READ THE WHOLE FRAMEBUFFER BACK, and reduce it to (a) sanity stats and (b) a small
3
- // perceptual SIGNATURE that can be compared to a committed golden. This is how the eyeballed
4
- // render demos become actual regression tests — a broken render (all-black, blown-out, changed)
5
- // fails automatically instead of needing a human to notice. Pairs with shaderProbe.ts (which
6
- // checks material values); this checks a whole rendered frame.
1
+ /// <reference types="@webgpu/types" preserve="true" />
7
2
  const SIZE = 256, GRID = 8; // 256×256 render (bytesPerRow = 1024, 256-aligned); 8×8 signature
8
3
  export class FrameProbe {
9
4
  device;
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  export interface Instance {
2
3
  x: number;
3
4
  y: number;
package/dist/gpuDriven.js CHANGED
@@ -1,14 +1,4 @@
1
- // ─────────────────────────────────────────────────────────────────────────────
2
- // GPU-DRIVEN render backend (WebGPU) — executes the render IR's DrawPlan on the GPU.
3
- // The whole scene lives in a storage buffer; a COMPUTE shader frustum-culls every
4
- // instance and writes, per pipeline (material), an atomic instanceCount + a compacted
5
- // list of visible instance indices; then ONE indirect draw per pipeline renders all
6
- // its visible instances. CPU draw calls = O(pipelines), independent of instance count.
7
- //
8
- // This is the real backend for the render IR (shared/renderIR.ts is the CPU reference
9
- // oracle it's validated against). Instances are billboarded quads for now — the shape
10
- // is not the point; the draw-call model is. See design/moonshot-open-world.md §5.
11
- // ─────────────────────────────────────────────────────────────────────────────
1
+ /// <reference types="@webgpu/types" preserve="true" />
12
2
  const INSTANCE_F32 = 8; // pos.xyz, scale | material, bounds, pad, pad
13
3
  const ARG_U32 = 4; // drawIndirect: vertexCount, instanceCount, firstVertex, firstInstance
14
4
  const WGSL = /* wgsl */ `
package/dist/gpuGI.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  export interface GIBox {
2
3
  x: number;
3
4
  y: number;
package/dist/gpuGI.js CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  // Render increment 8 — BAKED GLOBAL ILLUMINATION via an irradiance probe grid (DDGI-style).
2
3
  // The last of GAME.md §3.6's named look gaps. Real-time path tracing is out; the tractable form
3
4
  // is to PRECOMPUTE indirect light into a 3D grid of probes, then sample it per-pixel. Each probe
@@ -1,4 +1,5 @@
1
- import { type Graph } from './shaderGraph';
1
+ /// <reference types="@webgpu/types" preserve="true" />
2
+ import { type Graph } from './shaderGraph.js';
2
3
  export interface GraphInstance {
3
4
  x: number;
4
5
  y: number;
package/dist/gpuGraph.js CHANGED
@@ -1,9 +1,10 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  // Renders each shader GRAPH as its own pipeline: compileGraph() emits a `material()` WGSL fn that
2
3
  // is spliced into a shared scene template (cube instances + Cook-Torrance PBR lighting). So the
3
4
  // LIGHTING is engine-owned and identical; only the artist-authored material() differs per graph —
4
5
  // exactly how a production shader-graph pipeline works. No hand-written per-material WGSL.
5
- import { CUBE } from './cube';
6
- import { compileGraph } from './shaderGraph';
6
+ import { CUBE } from './cube.js';
7
+ import { compileGraph } from './shaderGraph.js';
7
8
  function sceneWGSL(materialFn) {
8
9
  return /* wgsl */ `
9
10
  struct Inst { pos: vec4<f32>, scl: vec4<f32> };
package/dist/gpuLit.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  export interface Instance {
2
3
  x: number;
3
4
  y: number;
package/dist/gpuLit.js CHANGED
@@ -1,12 +1,4 @@
1
- // ─────────────────────────────────────────────────────────────────────────────
2
- // GPU-driven LIT renderer — the shading program begins here (GAME.md §3.6). Builds
3
- // on the proven cull backend (compute frustum-cull → per-pipeline indirect draw) and
4
- // adds real lighting: instances render as lit impostor SPHERES (a billboard quad whose
5
- // fragment reconstructs a sphere normal), shaded by a directional sun + a buffer of
6
- // MANY dynamic POINT LIGHTS. This is the many-dynamic-lights look the open-world axis
7
- // needs; a later increment adds tiled/clustered light culling to scale the light count.
8
- // See design/moonshot-open-world.md §5 (phase 4), design/engine-build-plan.md.
9
- // ─────────────────────────────────────────────────────────────────────────────
1
+ /// <reference types="@webgpu/types" preserve="true" />
10
2
  const INSTANCE_F32 = 8, ARG_U32 = 4, LIGHT_F32 = 8, CAM_F32 = 64;
11
3
  const WGSL = /* wgsl */ `
12
4
  struct Inst { pos: vec4<f32>, attr: vec4<f32> };
package/dist/gpuPost.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  export declare class PostChain {
2
3
  private device;
3
4
  private w;
package/dist/gpuPost.js CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  // Stage 2 — a MULTI-STEP GPU POST-PROCESSING CHAIN over the HDR scene, the thing the earlier
2
3
  // "few draw calls, analytic shading" demos conspicuously lacked. Five fullscreen passes:
3
4
  // 1. BRIGHT extract (threshold the HDR → the bloom/flare source, at half res)
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  export declare const SHADOW_SIZE = 2048;
2
3
  export declare const SHADOW_WGSL = "\nfn shadowFactor(lightVP: mat4x4<f32>, world: vec3<f32>, ndl: f32, texel: f32,\n shadowMap: texture_depth_2d, shadowSamp: sampler_comparison) -> f32 {\n let lp = lightVP * vec4(world, 1.0);\n let proj = lp.xyz / lp.w;\n let uv = proj.xy * vec2(0.5, -0.5) + vec2(0.5, 0.5);\n if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0 || proj.z > 1.0 || proj.z < 0.0) { return 1.0; }\n let bias = max(0.0025 * (1.0 - ndl), 0.0012);\n var s = 0.0;\n for (var dy = -1; dy <= 1; dy = dy + 1) {\n for (var dx = -1; dx <= 1; dx = dx + 1) {\n s = s + textureSampleCompareLevel(shadowMap, shadowSamp, uv + vec2(f32(dx), f32(dy)) * texel, proj.z - bias);\n }\n }\n return s / 9.0;\n}";
3
4
  export declare class GpuShadowMap {
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  // ─────────────────────────────────────────────────────────────────────────────
2
3
  // GPU SHADOW MAP (PLATFORM) — a shared directional-sun depth map + PCF sampling helper, so the outdoor
3
4
  // scene casts real shadows (the single biggest look upgrade after lighting; it also makes the sun's
package/dist/gpuSpot.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import type { CubeInstance } from './cube';
2
- export type { CubeInstance } from './cube';
1
+ /// <reference types="@webgpu/types" preserve="true" />
2
+ import type { CubeInstance } from './cube.js';
3
+ export type { CubeInstance } from './cube.js';
3
4
  export interface Spot {
4
5
  px: number;
5
6
  py: number;
package/dist/gpuSpot.js CHANGED
@@ -1,10 +1,11 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  // Render IR increment 6 — POINT-LIGHT (spotlight) SHADOWS. Pairs increment 4 (many lights)
2
3
  // with increment 5 (shadows): now the positional lights themselves cast real shadows. Full
3
4
  // omnidirectional cube shadows for 1,600 lights is infeasible (6 faces each), so this is the
4
5
  // tractable, honest form — a handful of shadow-casting SPOTLIGHTS, each with its own 2D shadow
5
6
  // map (a perspective light view) packed into a depth-2d-ARRAY. Same PCF-comparison machinery
6
7
  // as the sun, extended to a positional light with a cone + distance falloff, times L lights.
7
- import { CUBE } from './cube';
8
+ import { CUBE } from './cube.js';
8
9
  export const NUM_SPOTS = 6;
9
10
  const SHADOW_SIZE = 1536;
10
11
  const COMMON = /* wgsl */ `
package/dist/gpuSsao.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  export declare class GpuSSAO {
2
3
  private device;
3
4
  private pipe;
package/dist/gpuSsao.js CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  // SCREEN-SPACE CONTACT AO — the missing cue that makes voxel terrain read as 3D. Fixed directional fill shades a
2
3
  // face by its ORIENTATION, but a large flat ground plane has one normal everywhere, so it still looks flat. What
3
4
  // the eye actually uses to read shape is the DARK where surfaces meet: the base of a step, the inside corner of a
package/dist/gpuTaa.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import type { CubeInstance } from './cube';
2
- export type { CubeInstance } from './cube';
1
+ /// <reference types="@webgpu/types" preserve="true" />
2
+ import type { CubeInstance } from './cube.js';
3
+ export type { CubeInstance } from './cube.js';
3
4
  export declare class GpuTaaRenderer {
4
5
  private device;
5
6
  private w;
package/dist/gpuTaa.js CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  // Render IR increment 7 — TEMPORAL ANTI-ALIASING (TAA). The last of GAME.md §3.6's named
2
3
  // "biggest look gaps", and the proper fix for the residual shadow/edge shimmer of a moving
3
4
  // camera. The engine complexity here is the temporal pipeline, not the shading:
@@ -10,7 +11,7 @@
10
11
  // Reuses the cube geometry from gpuShadow. Sun-lit (no shadow map here) to keep the module
11
12
  // focused on the temporal machinery. `?taa=0` on the page disables jitter + accumulation so the
12
13
  // raw aliased image is visible for comparison.
13
- import { CUBE } from './cube';
14
+ import { CUBE } from './cube.js';
14
15
  const COLOR_FMT = 'rgba16float';
15
16
  const MOTION_FMT = 'rg16float';
16
17
  const SCENE_WGSL = /* wgsl */ `
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  /** Halton(2,3) sub-pixel jitter for frame `i`, in CLIP space. Multiply into the projection. */
2
3
  export declare function haltonJitter(i: number, w: number, h: number, samples?: number): [number, number];
3
4
  export declare class GpuTaaResolve {
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  // PLATFORM PASS. Temporal anti-aliasing as a POST PASS over an existing colour+depth pair, so any
2
3
  // renderer in this package can get TAA without becoming a TAA renderer.
3
4
  //
@@ -1,4 +1,5 @@
1
- import { type GpuShadowMap } from './gpuShadowMap';
1
+ /// <reference types="@webgpu/types" preserve="true" />
2
+ import { type GpuShadowMap } from './gpuShadowMap.js';
2
3
  export declare class GpuTerrainRenderer {
3
4
  private device;
4
5
  private terrainPipe;
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  // ─────────────────────────────────────────────────────────────────────────────
2
3
  // GPU TERRAIN — a smooth lit triangle-mesh renderer for the world surface (PLATFORM), replacing the
3
4
  // boxy instanced-cube look. Draws an indexed mesh (per-vertex position / normal / colour) with a sun
@@ -5,7 +6,7 @@
5
6
  // its depth into the shared sun shadow map) and RECEIVES sun shadows (PCF sample in the fragment), so
6
7
  // hills and props darken the ground they occlude — which also makes the sun's direction legible.
7
8
  // ─────────────────────────────────────────────────────────────────────────────
8
- import { SHADOW_WGSL } from './gpuShadowMap';
9
+ import { SHADOW_WGSL } from './gpuShadowMap.js';
9
10
  const TERRAIN =
10
11
  /* wgsl */ `
11
12
  struct U { mvp: mat4x4<f32>, sun: vec4<f32>, sunCol: vec4<f32>, amb: vec4<f32>, cam: vec4<f32>, fog: vec4<f32>, lightVP: mat4x4<f32>, shadowP: vec4<f32> };
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  export interface Instance {
2
3
  x: number;
3
4
  y: number;
package/dist/gpuTiled.js CHANGED
@@ -1,11 +1,4 @@
1
- // ─────────────────────────────────────────────────────────────────────────────
2
- // Tiled (forward+) light culling — scales the many-dynamic-lights renderer from
3
- // hundreds to THOUSANDS of lights. A COMPUTE pass bins each light into the screen
4
- // tiles its projected sphere overlaps; the fragment shader then shades only its
5
- // tile's lights → O(lights-per-tile) instead of O(all-lights). Same story as the
6
- // instance brute→grid cull, applied to lights. Builds on the GPU-driven lit backend
7
- // (shared/gpuLit). See design/moonshot-open-world.md §5 (phase 4), GAME.md §3.6.
8
- // ─────────────────────────────────────────────────────────────────────────────
1
+ /// <reference types="@webgpu/types" preserve="true" />
9
2
  const INSTANCE_F32 = 8, ARG_U32 = 4, LIGHT_F32 = 8, CAM_F32 = 72;
10
3
  export const TILE = 24, MAX_PER_TILE = 256;
11
4
  const WGSL = /* wgsl */ `
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  /** Milliseconds per labelled span, plus the whole bracketed region as `total`. */
2
3
  export type GpuSpans = Record<string, number>;
3
4
  export declare class GpuTimer {
package/dist/gpuTimer.js CHANGED
@@ -1,32 +1,4 @@
1
- // PLATFORM PASS-TIMER. Real GPU time per render pass, via `timestamp-query`.
2
- //
3
- // Why marks between passes rather than `timestampWrites` on the pass descriptor: every renderer in
4
- // this package (GpuShadowRenderer, GpuSSAO, GpuPropsRenderer, …) opens its own `beginRenderPass`
5
- // inside `frame()`. Timing via the pass descriptor would mean threading a query set through every
6
- // one of those private call sites. `encoder.writeTimestamp` brackets spans on the ENCODER instead,
7
- // so a caller can time existing renderers without any of them changing:
8
- //
9
- // timer.begin(enc);
10
- // skyR.frame(enc, …); timer.mark(enc, 'sky');
11
- // renderer.frame(enc, …); timer.mark(enc, 'cubes');
12
- // ssaoR.frame(enc, …); timer.mark(enc, 'ssao');
13
- // timer.end(enc);
14
- // device.queue.submit([enc.finish()]);
15
- // timer.poll(); // non-blocking; results land a few frames later
16
- //
17
- // MEASURED on the Electron WebGPU host, timing two 512² passes whose fragment loops differ 5000×:
18
- // `timestampWrites` reported 0.072 / 79.19 ms and `encoder.writeTimestamp` 0.137 / 70.32 ms. Both
19
- // attribute correctly, so the encoder path was chosen purely because it needs no renderer changes.
20
- //
21
- // THE TRAP, worth knowing before trusting any number this produces: a render pass whose result is
22
- // never consumed can be dropped by the driver, and then its time lands in a NEIGHBOURING span. An
23
- // early version of the oracle drew two passes into one texture with `loadOp: 'clear'` and never
24
- // read it; the first pass was dead work, got elided, and the timer duly reported the heavy pass at
25
- // 0.01 ms. The timer was right and the scene was a lie. If a span looks impossibly cheap, check
26
- // that something downstream actually reads what the pass wrote.
27
- //
28
- // Unsupported devices degrade quietly: `supported` is false, marks are no-ops, and `spans()` stays
29
- // empty so callers fall back to wall-clock frame time.
1
+ /// <reference types="@webgpu/types" preserve="true" />
30
2
  const MAX_MARKS = 32; // query-set slots: 1 begin + up to 31 marks
31
3
  const RING = 3; // readback buffers in flight — enough to never stall a 60fps loop
32
4
  export class GpuTimer {
@@ -1,4 +1,5 @@
1
- import type { CubeInstance } from './cube';
1
+ /// <reference types="@webgpu/types" preserve="true" />
2
+ import type { CubeInstance } from './cube.js';
2
3
  /** A dynamic instance that also knows where it was last frame (for its motion vector). */
3
4
  export interface WorldInstance extends CubeInstance {
4
5
  px: number;
package/dist/gpuWorld.js CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
1
2
  // The integrated scene renderer: sun SHADOW MAPPING + TAA in one pipeline, driven by the
2
3
  // deterministic ECS sim. The new hard part vs. the isolated /gputaa demo is PER-OBJECT MOTION
3
4
  // VECTORS: the sim moves crates/character/projectiles every frame, so camera-only reprojection
@@ -5,7 +6,7 @@
5
6
  // pass emits a true motion vector (camera motion + object motion), and TAA reprojects history
6
7
  // through it. Passes: (1) shadow depth from the sun, (2) shadow-lit scene → MRT color+motion
7
8
  // (jittered), (3) TAA resolve → screen + ping-ponged history.
8
- import { CUBE } from './cube';
9
+ import { CUBE } from './cube.js';
9
10
  const COLOR_FMT = 'rgba16float';
10
11
  const MOTION_FMT = 'rg16float';
11
12
  const SHADOW_SIZE = 2048;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugly-game",
3
- "version": "0.15.43",
3
+ "version": "0.15.44",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -25,10 +25,12 @@
25
25
  "test:flight-browser": "playwright test -c playwright.flight.config.ts",
26
26
  "test:flight-perf": "playwright test -c playwright.flight.config.ts --grep 'CPU and retained-memory'",
27
27
  "test:types": "tsc -p tsconfig.test.json",
28
+ "test:package-types": "node tools/packageTypesSmoke.mjs",
28
29
  "pretty": "prettier --write .",
29
30
  "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/"
30
31
  },
31
32
  "dependencies": {
33
+ "@webgpu/types": "^0.1.40",
32
34
  "meshoptimizer": "^1.2.0"
33
35
  },
34
36
  "peerDependencies": {
@@ -38,7 +40,6 @@
38
40
  "@playwright/test": "^1.62.1",
39
41
  "@types/node": "^22.20.1",
40
42
  "@types/react": "^19.0.0",
41
- "@webgpu/types": "^0.1.40",
42
43
  "prettier": "^3.9.5",
43
44
  "typescript": "^5.6.0",
44
45
  "ugly-app": "^0.1.841",