@wildshard/sdk 0.0.1 → 0.2.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/GUIDE.md +790 -0
- package/README.md +13 -5
- package/bin/wildshard.mjs +38 -0
- package/lint/declaration-config.d.mts +2 -0
- package/lint/declaration-config.mjs +19 -0
- package/lint/engine-plugin.d.mts +2 -0
- package/lint/engine-plugin.mjs +40 -0
- package/lint/host-callbacks.d.mts +6 -0
- package/lint/host-callbacks.mjs +123 -0
- package/lint/host-files.d.mts +1 -0
- package/lint/host-files.mjs +7 -0
- package/lint/layer-exports.d.mts +2 -0
- package/lint/layer-exports.mjs +21 -0
- package/lint/legacy-line-basis.json +995 -0
- package/lint/nine-tiling-baseline.json +35 -0
- package/lint/ratchet.json +11 -0
- package/lint/runtime-files.d.mts +12 -0
- package/lint/runtime-files.json +16 -0
- package/lint/runtime-files.mjs +69 -0
- package/lint/runtime-performance.d.mts +6 -0
- package/lint/runtime-performance.mjs +184 -0
- package/lint/sdk-plugin.d.mts +4 -0
- package/lint/sdk-plugin.mjs +134 -0
- package/lint/shardfile-boundaries.d.mts +10 -0
- package/lint/shardfile-boundaries.mjs +122 -0
- package/lint/tile-bake-debt.json +556 -0
- package/package.json +365 -3
- package/scripts/agent-parity.mjs +1524 -0
- package/scripts/agent-sync.mjs +518 -0
- package/scripts/apfs-clone.mjs +67 -0
- package/scripts/assert-store-layout.mjs +23 -0
- package/scripts/astc6-phone-cap.d.mts +3 -0
- package/scripts/astc6-phone-cap.mjs +137 -0
- package/scripts/audit-assets.d.mts +10 -0
- package/scripts/audit-assets.mjs +151 -0
- package/scripts/bake/coatFiles.d.mts +6 -0
- package/scripts/bake/coatFiles.mjs +37 -0
- package/scripts/bake/environment.d.mts +2 -0
- package/scripts/bake/environment.mjs +58 -0
- package/scripts/bake/far-proxies.mjs +45 -0
- package/scripts/bake/keyed-sky.d.mts +4 -0
- package/scripts/bake/keyed-sky.mjs +34 -0
- package/scripts/bake/movers.mjs +56 -0
- package/scripts/bake/nativeWorld.d.mts +6 -0
- package/scripts/bake/nativeWorld.mjs +43 -0
- package/scripts/bake/navmeshGround.ts +22 -0
- package/scripts/bake/near-placeholder.mjs +331 -0
- package/scripts/bake/placeholderShards.mjs +41 -0
- package/scripts/bake/skins.mjs +15 -0
- package/scripts/bake/template-skins.mjs +33 -0
- package/scripts/bake/viewmodelBytes.ts +26 -0
- package/scripts/bake/viewmodelPage.ts +11 -0
- package/scripts/bake/worldHost.d.mts +35 -0
- package/scripts/bake/worldHost.mjs +110 -0
- package/scripts/bake-astc6.cache.json +80 -0
- package/scripts/bake-astc6.far-reach.cache.json +23 -0
- package/scripts/bake-astc6.list.json +111 -0
- package/scripts/bake-astc6.mjs +279 -0
- package/scripts/bake-astc6.nalati-grasslands.cache.json +42 -0
- package/scripts/bake-catalogue.mjs +44 -0
- package/scripts/bake-check.mjs +54 -0
- package/scripts/bake-chunk.mjs +124 -0
- package/scripts/bake-cloud-field.mjs +24 -0
- package/scripts/bake-coats.mjs +110 -0
- package/scripts/bake-data-maps.d.mts +24 -0
- package/scripts/bake-data-maps.mjs +72 -0
- package/scripts/bake-entry-programs.mjs +117 -0
- package/scripts/bake-geometry.mjs +106 -0
- package/scripts/bake-hybrid-tiles.mjs +28 -0
- package/scripts/bake-ktx2.cache.json +276 -0
- package/scripts/bake-ktx2.list.json +365 -0
- package/scripts/bake-ktx2.mjs +477 -0
- package/scripts/bake-map-glb.mjs +127 -0
- package/scripts/bake-map-rest.d.mts +7 -0
- package/scripts/bake-map-rest.mjs +50 -0
- package/scripts/bake-maps.mjs +200 -0
- package/scripts/bake-navmesh.mjs +259 -0
- package/scripts/bake-packs.mjs +129 -0
- package/scripts/bake-pickups.mjs +102 -0
- package/scripts/bake-query-terrain.mjs +64 -0
- package/scripts/bake-recurve-pool.mjs +16 -0
- package/scripts/bake-section-schemas.d.mts +3 -0
- package/scripts/bake-template-shardfile.mjs +32 -0
- package/scripts/bake-textures.mjs +80 -0
- package/scripts/bake-viewmodel-sets.json +45 -0
- package/scripts/bake-viewmodel-sets.mjs +137 -0
- package/scripts/bake-voxel-ao.mjs +119 -0
- package/scripts/bake-water-ripples.mjs +25 -0
- package/scripts/blender/README.md +129 -0
- package/scripts/blender/build.sh +166 -0
- package/scripts/blender/lib/export-scene.mjs +129 -0
- package/scripts/blender/lib/glb-digest.mjs +188 -0
- package/scripts/blender/lib/glb.py +68 -0
- package/scripts/blender/lib/save_blend.py +17 -0
- package/scripts/blender/lib/world_fixture.py +55 -0
- package/scripts/blender/targets.json +591 -0
- package/scripts/build-sdk.mjs +95 -0
- package/scripts/build-shardfiles.d.mts +7 -0
- package/scripts/build-shardfiles.mjs +206 -0
- package/scripts/capture-hero.mjs +137 -0
- package/scripts/check-lift-review.mjs +23 -0
- package/scripts/chromium-keychain-check.mjs +139 -0
- package/scripts/chromium-keychain.d.mts +1 -0
- package/scripts/chromium-keychain.mjs +5 -0
- package/scripts/compile-script.d.mts +3 -0
- package/scripts/compile-script.mjs +8 -0
- package/scripts/creature-color.mjs +255 -0
- package/scripts/decide/calibrate.py +127 -0
- package/scripts/decide/calibration/2026-10-03/labels-s1.tsv +281 -0
- package/scripts/decide/calibration/2026-10-03/labels-s2.tsv +97 -0
- package/scripts/decide/calibration/2026-10-03/labels-s3.tsv +48 -0
- package/scripts/decide/calibration/2026-10-03/labels-s3b.tsv +26 -0
- package/scripts/decide/calibration/2026-10-03/res-capture-status-v1.jsonl +376 -0
- package/scripts/decide/calibration/2026-10-03/res-text-garbled-strings.jsonl +48 -0
- package/scripts/decide/calibration/2026-10-03/res-text-garbled-v1.jsonl +73 -0
- package/scripts/decide/decide.py +262 -0
- package/scripts/decide/decide.sh +50 -0
- package/scripts/decide/layer-purity-pilot.mjs +41 -0
- package/scripts/decide/sets/capture-status.json +46 -0
- package/scripts/decide/sets/layer-purity.json +28 -0
- package/scripts/decide/sets/text-garbled.json +17 -0
- package/scripts/decide/test_decide.py +37 -0
- package/scripts/docs.mjs +15 -0
- package/scripts/entry-reads/crawl.ts +152 -0
- package/scripts/entry-reads/tsconfig.json +25 -0
- package/scripts/gen-format-schema.d.mts +2 -0
- package/scripts/gen-format-schema.mjs +21 -0
- package/scripts/gen-host-catalogue.d.mts +14 -0
- package/scripts/gen-host-catalogue.mjs +108 -0
- package/scripts/gen-shard-layout-doc.d.mts +4 -0
- package/scripts/gen-shard-layout-doc.mjs +55 -0
- package/scripts/gen-shards.d.mts +17 -0
- package/scripts/gen-shards.mjs +311 -0
- package/scripts/goldens/capture-inputs.d.mts +4 -0
- package/scripts/goldens/capture-inputs.mjs +34 -0
- package/scripts/goldens/colour_shift.py +27 -0
- package/scripts/goldens/native-residency.d.mts +10 -0
- package/scripts/goldens/native-residency.mjs +104 -0
- package/scripts/goldens/plot-inputs.d.mts +12 -0
- package/scripts/goldens/plot-inputs.mjs +46 -0
- package/scripts/gpu-texmem.mjs +98 -0
- package/scripts/horizon-matte/config.py +24 -0
- package/scripts/horizon-matte/encode.py +91 -0
- package/scripts/horizon-matte/key.py +141 -0
- package/scripts/horizon-matte/mkjobs.py +33 -0
- package/scripts/horizon-matte/mkjobs_day2.py +11 -0
- package/scripts/horizon-matte/overlap.py +80 -0
- package/scripts/horizon-matte/run_codex.py +57 -0
- package/scripts/horizon-matte/stitch.py +133 -0
- package/scripts/img2mesh/CC0.md +105 -0
- package/scripts/img2mesh/README.md +209 -0
- package/scripts/img2mesh/ab_board.py +102 -0
- package/scripts/img2mesh/birds/birds.json +255 -0
- package/scripts/img2mesh/birds/birds_atlas.py +150 -0
- package/scripts/img2mesh/birds/birds_fix_preview.mjs +103 -0
- package/scripts/img2mesh/birds/birds_fix_render.py +75 -0
- package/scripts/img2mesh/birds/birds_pack.py +110 -0
- package/scripts/img2mesh/birds/birds_phone_b.py +112 -0
- package/scripts/img2mesh/birds/birds_post.py +550 -0
- package/scripts/img2mesh/birds/birds_render.py +125 -0
- package/scripts/img2mesh/birds/birds_sheet.py +33 -0
- package/scripts/img2mesh/birds/birds_view.py +60 -0
- package/scripts/img2mesh/board.py +100 -0
- package/scripts/img2mesh/build_cc0.sh +52 -0
- package/scripts/img2mesh/build_driftwood.sh +12 -0
- package/scripts/img2mesh/build_faces.sh +53 -0
- package/scripts/img2mesh/build_props.py +81 -0
- package/scripts/img2mesh/cc0_export.py +186 -0
- package/scripts/img2mesh/driftwood_post.py +571 -0
- package/scripts/img2mesh/e304_faces.sh +67 -0
- package/scripts/img2mesh/face_remaster.py +911 -0
- package/scripts/img2mesh/face_views.py +95 -0
- package/scripts/img2mesh/faces-e304.json +9 -0
- package/scripts/img2mesh/faces.json +30 -0
- package/scripts/img2mesh/head_cut.py +100 -0
- package/scripts/img2mesh/hi3d_paint.py +94 -0
- package/scripts/img2mesh/hi3d_refine.py +161 -0
- package/scripts/img2mesh/hunyuan_cpu_rasterizer.sh +42 -0
- package/scripts/img2mesh/pine_hollow_phone.sh +13 -0
- package/scripts/img2mesh/props/coral-arch.json +32 -0
- package/scripts/img2mesh/props/ember-furnace.json +30 -0
- package/scripts/img2mesh/props/night-market-gate.json +10 -0
- package/scripts/img2mesh/render_still.py +86 -0
- package/scripts/img2mesh/rig_strip.mjs +46 -0
- package/scripts/img2mesh/rig_transfer.mjs +104 -0
- package/scripts/img2mesh/split_sheet.py +48 -0
- package/scripts/img2mesh/trellis_batch.py +110 -0
- package/scripts/img2mesh/versus_board.py +114 -0
- package/scripts/import-bundle.d.mts +2 -0
- package/scripts/import-bundle.mjs +20 -0
- package/scripts/ktx2-ab-board.py +133 -0
- package/scripts/ktx2-ab.mjs +111 -0
- package/scripts/ktx2-settings.mjs +18 -0
- package/scripts/land.d.mts +14 -0
- package/scripts/land.mjs +809 -0
- package/scripts/lint-dispatch.mjs +14 -0
- package/scripts/map-bake-frames.d.mts +4 -0
- package/scripts/map-bake-frames.mjs +23 -0
- package/scripts/map-geometry.d.mts +9 -0
- package/scripts/map-geometry.mjs +29 -0
- package/scripts/map-world.mjs +162 -0
- package/scripts/mockup-local.sh +46 -0
- package/scripts/music/export-midi.mjs +68 -0
- package/scripts/music/gen/analyze.py +308 -0
- package/scripts/music/gen/audio_jobs.py +46 -0
- package/scripts/music/gen/briefs.json +51 -0
- package/scripts/music/gen/build_page.py +334 -0
- package/scripts/music/gen/folk.json +3187 -0
- package/scripts/music/gen/gen_ace_step.py +156 -0
- package/scripts/music/gen/gen_heartmula.py +187 -0
- package/scripts/music/gen/gen_minimax.py +143 -0
- package/scripts/music/gen/gen_sao.py +122 -0
- package/scripts/music/gen/gen_sao_small.py +104 -0
- package/scripts/music/gen/gen_sfx.py +98 -0
- package/scripts/music/gen/gen_sfx_ezaudio.py +112 -0
- package/scripts/music/gen/gen_sfx_moss.py +112 -0
- package/scripts/music/gen/models.json +61 -0
- package/scripts/music/gen/nalati-jobs.json +104 -0
- package/scripts/music/gen/nalati-score-build.json +119 -0
- package/scripts/music/gen/nalati-score.json +3448 -0
- package/scripts/music/gen/ob7-fit-decisions.json +38 -0
- package/scripts/music/gen/ob7-score-jobs.json +152 -0
- package/scripts/music/gen/ob7-sfx-jobs.json +897 -0
- package/scripts/music/gen/ob7_build.py +469 -0
- package/scripts/music/gen/ob7_generate.py +67 -0
- package/scripts/music/gen/ob7_run.sh +42 -0
- package/scripts/music/gen/orchestral.json +3187 -0
- package/scripts/music/gen/own_score.py +486 -0
- package/scripts/music/gen/ph-jobs.json +27 -0
- package/scripts/music/gen/ph_page.py +222 -0
- package/scripts/music/gen/piano.json +3175 -0
- package/scripts/music/gen/rank_v3.py +248 -0
- package/scripts/music/gen/sfx-best.json +2486 -0
- package/scripts/music/gen/sfx-ezaudio.json +4082 -0
- package/scripts/music/gen/sfx-jobs.json +57 -0
- package/scripts/music/gen/sfx-minimax-jobs.json +16 -0
- package/scripts/music/gen/sfx-minimax.json +289 -0
- package/scripts/music/gen/sfx-moss.json +4082 -0
- package/scripts/music/gen/sfx-nalati-b3-jobs.json +17 -0
- package/scripts/music/gen/sfx-nalati-jobs.json +338 -0
- package/scripts/music/gen/sfx-nalati.json +11202 -0
- package/scripts/music/gen/sfx-nd-jobs.json +57 -0
- package/scripts/music/gen/sfx-nd-moss.json +2097 -0
- package/scripts/music/gen/sfx-nd-sa3-medium.json +2097 -0
- package/scripts/music/gen/sfx-nd-summary.json +38 -0
- package/scripts/music/gen/sfx-peaks.json +7 -0
- package/scripts/music/gen/sfx-ph-jobs.json +169 -0
- package/scripts/music/gen/sfx-ph-moss.json +6564 -0
- package/scripts/music/gen/sfx-ph-sa3-medium.json +7239 -0
- package/scripts/music/gen/sfx-ph-summary.json +63 -0
- package/scripts/music/gen/sfx-sa3-medium.json +4082 -0
- package/scripts/music/gen/sfx-sa3.json +4082 -0
- package/scripts/music/gen/sfx-summary.json +107 -0
- package/scripts/music/gen/sfx_build.py +332 -0
- package/scripts/music/gen/sfx_merge.py +255 -0
- package/scripts/music/gen/sfx_minimax.py +61 -0
- package/scripts/music/gen/sfx_nalati.py +331 -0
- package/scripts/music/gen/sfx_sprite.py +424 -0
- package/scripts/music/gen/stems.py +539 -0
- package/scripts/music/gen/test_loop_meter.py +29 -0
- package/scripts/music/gen/test_ob7_provenance.py +77 -0
- package/scripts/music/gen/v3-folk-build.json +148 -0
- package/scripts/music/gen/v3-folk.json +1818 -0
- package/scripts/music/gen/v3-jobs.json +145 -0
- package/scripts/music/gen/v3-orchestral-build.json +148 -0
- package/scripts/music/gen/v3-orchestral.json +1813 -0
- package/scripts/music/gen/v3-ph-folk-build.json +94 -0
- package/scripts/music/gen/v3-ph-folk.json +1806 -0
- package/scripts/music/gen/v3-ph-orchestral-build.json +94 -0
- package/scripts/music/gen/v3-ph-orchestral.json +1824 -0
- package/scripts/music/gen/v3-ph-piano-build.json +94 -0
- package/scripts/music/gen/v3-ph-piano.json +1818 -0
- package/scripts/music/gen/v3-piano-build.json +148 -0
- package/scripts/music/gen/v3-piano.json +1813 -0
- package/scripts/music/wildshard-theme.mid +0 -0
- package/scripts/music/wildshard-trailer30.mid +0 -0
- package/scripts/named-blob-output.d.mts +8 -0
- package/scripts/named-blob-output.mjs +48 -0
- package/scripts/pack-all.mjs +15 -0
- package/scripts/pid-lock.d.mts +1 -0
- package/scripts/pid-lock.mjs +63 -0
- package/scripts/practice/bake_dummy.py +53 -0
- package/scripts/practice/build_dummies.sh +43 -0
- package/scripts/practice/dummy_parts.py +568 -0
- package/scripts/practice/dummy_rig_gate.py +139 -0
- package/scripts/practice/gate_sheet.py +36 -0
- package/scripts/practice/generate_dummy_unimate.py +132 -0
- package/scripts/practice/pack_dummy.mjs +59 -0
- package/scripts/practice/repair_dummy_weights.mjs +68 -0
- package/scripts/practice/rig_dummy.py +828 -0
- package/scripts/practice/verify_unimate_skin.mjs +356 -0
- package/scripts/preparation-seed.mjs +15 -0
- package/scripts/prepare-basis-tool.mjs +6 -0
- package/scripts/prepare-product.d.mts +14 -0
- package/scripts/prepare-product.mjs +101 -0
- package/scripts/product-build-tools.d.mts +3 -0
- package/scripts/product-build-tools.json +3 -0
- package/scripts/product-build-tools.mjs +31 -0
- package/scripts/publish-public.mjs +7 -0
- package/scripts/push-tables.d.mts +1 -0
- package/scripts/push-tables.mjs +28 -0
- package/scripts/record-shard-mounts.mjs +133 -0
- package/scripts/sdk-externals.d.mts +2 -0
- package/scripts/sdk-externals.mjs +2 -0
- package/scripts/section-inventory.ts +209 -0
- package/scripts/select-candidate.mjs +15 -0
- package/scripts/shard-build-pool.d.mts +4 -0
- package/scripts/shard-build-pool.mjs +53 -0
- package/scripts/shard-line-baseline.json +17 -0
- package/scripts/shard-milestones.d.mts +15 -0
- package/scripts/shard-milestones.mjs +105 -0
- package/scripts/shard-output-report.d.mts +9 -0
- package/scripts/shard-output-report.mjs +85 -0
- package/scripts/shard-platform-cli.mjs +93 -0
- package/scripts/shard-progress.mjs +212 -0
- package/scripts/shard-timelapse.py +102 -0
- package/scripts/shardfile-cold-boot.mjs +79 -0
- package/scripts/shardfile-vite.d.mts +4 -0
- package/scripts/shardfile-vite.mjs +20 -0
- package/scripts/simplify-models.mjs +24 -0
- package/scripts/site-facts.mjs +88 -0
- package/scripts/test-template-gate.mjs +44 -0
- package/scripts/test_golden_compare.py +68 -0
- package/scripts/tex-tiers.cache.json +181 -0
- package/scripts/tex-tiers.mjs +240 -0
- package/scripts/texmem-probe.mjs +184 -0
- package/scripts/unused-assets.mjs +173 -0
- package/scripts/vite-tmp.d.mts +23 -0
- package/scripts/vite-tmp.mjs +157 -0
- package/scripts/wave-line-baselines.json +32 -0
- package/scripts/wildshard.d.mts +4 -0
- package/scripts/wildshard.mjs +105 -0
- package/scripts/witness-checkpoints.d.mts +10 -0
- package/scripts/witness-checkpoints.mjs +84 -0
- package/scripts/witness-generation.d.mts +10 -0
- package/scripts/witness-generation.mjs +45 -0
- package/scripts/witness-manifests.d.mts +8 -0
- package/scripts/witness-manifests.mjs +157 -0
- package/scripts/worktree-ignore.d.mts +4 -0
- package/scripts/worktree-ignore.mjs +36 -0
- package/scripts/worktree-reap.mjs +214 -0
- package/scripts/worktree.mjs +396 -0
- package/scripts/worldclaw/capture-front.sh +28 -0
- package/scripts/worldclaw/design-template.md +62 -0
- package/scripts/worldclaw/spec-map.py +92 -0
- package/scripts/worldclaw/spec.ts +96 -0
- package/skills/wildshard/SKILL.md +50 -0
- package/skills/wildshard-goldens/SKILL.md +54 -0
- package/skills/wildshard-mockup-to-model/SKILL.md +56 -0
- package/skills/wildshard-upgrade/SKILL.md +46 -0
- package/src/.oxfmtrc.json +50 -0
- package/src/.oxlintrc.json +173 -0
- package/src/cli/account/account.ts +199 -0
- package/src/cli/account/command.ts +193 -0
- package/src/cli/account/key.ts +154 -0
- package/src/cli/args.ts +97 -0
- package/src/cli/audio/audio.ts +24 -0
- package/src/cli/bin.mjs +8 -0
- package/src/cli/delete/delete.ts +258 -0
- package/src/cli/help.ts +196 -0
- package/src/cli/hero/adopt.ts +103 -0
- package/src/cli/hero/hero.ts +112 -0
- package/src/cli/hero/stamp.ts +298 -0
- package/src/cli/main.ts +292 -0
- package/src/cli/report.ts +16 -0
- package/src/cli/shardfile/command.ts +50 -0
- package/src/cli/shardfile/shardfile.ts +192 -0
- package/src/cli/upload/api.ts +246 -0
- package/src/cli/upload/compress.ts +55 -0
- package/src/cli/upload/hero.ts +62 -0
- package/src/cli/upload/placement.ts +115 -0
- package/src/cli/upload/provenance.ts +192 -0
- package/src/cli/upload/signature.ts +30 -0
- package/src/cli/upload/upload.ts +269 -0
- package/src/cli/upload/validate.ts +74 -0
- package/src/cli/upload/wire.ts +147 -0
- package/src/cli/version.ts +63 -0
- package/src/commons/bake/portableMath.ts +187 -0
- package/src/commons/catalogue.ts +10 -0
- package/src/commons/courseProgram.ts +32 -0
- package/src/commons/practiceCourse.ts +16 -0
- package/src/commons/scripts/abi.as +14 -0
- package/src/commons/scripts/bridge.as +14 -0
- package/src/commons/scripts/course.as +63 -0
- package/src/scripts/ask-new.sh +29 -0
- package/src/scripts/asks.mjs +141 -0
- package/src/scripts/herdr-prompt.sh +34 -0
- package/src/scripts/herdr-question-open.sh +67 -0
- package/src/scripts/md-wrap.mjs +229 -0
- package/src/server/app.ts +19 -0
- package/src/server/serve.ts +49 -0
- package/src/sharddev/admission.ts +7 -0
- package/src/sharddev/arenaView.ts +15 -0
- package/src/sharddev/as/groupBankV2.ts +36 -0
- package/src/sharddev/as/groupStepV2.ts +13 -0
- package/src/sharddev/as/ws.ts +30 -0
- package/src/sharddev/as/wsV2.ts +180 -0
- package/src/sharddev/assemblyscriptCompiler.d.mts +5 -0
- package/src/sharddev/assemblyscriptCompiler.mjs +14 -0
- package/src/sharddev/assetHandle.ts +84 -0
- package/src/sharddev/assetOwner.ts +70 -0
- package/src/sharddev/assetScope.ts +30 -0
- package/src/sharddev/assets.ts +21 -0
- package/src/sharddev/audio.ts +9 -0
- package/src/sharddev/audioEncode.ts +211 -0
- package/src/sharddev/author.ts +3 -0
- package/src/sharddev/authorError.ts +28 -0
- package/src/sharddev/authorManifest.ts +39 -0
- package/src/sharddev/bake/annulus.ts +19 -0
- package/src/sharddev/bake/assemblyscriptMemo.ts +76 -0
- package/src/sharddev/bake/assemblyscriptMemoPort.ts +4 -0
- package/src/sharddev/bake/authoredWorld.ts +201 -0
- package/src/sharddev/bake/basisEncoder.ts +95 -0
- package/src/sharddev/bake/basisGlb.ts +85 -0
- package/src/sharddev/bake/basisTool.ts +74 -0
- package/src/sharddev/bake/basisToolInputs.ts +476 -0
- package/src/sharddev/bake/byteCodec.ts +33 -0
- package/src/sharddev/bake/canvasAtlas.ts +406 -0
- package/src/sharddev/bake/coarseCopy.ts +59 -0
- package/src/sharddev/bake/colliders.ts +87 -0
- package/src/sharddev/bake/compactGlb.ts +224 -0
- package/src/sharddev/bake/compileScript.ts +119 -0
- package/src/sharddev/bake/compileScriptV2.ts +75 -0
- package/src/sharddev/bake/contactRows.ts +84 -0
- package/src/sharddev/bake/creaturePlacement.ts +117 -0
- package/src/sharddev/bake/export.ts +67 -0
- package/src/sharddev/bake/facetedGeometry.ts +379 -0
- package/src/sharddev/bake/farImpostor.ts +120 -0
- package/src/sharddev/bake/forest.ts +100 -0
- package/src/sharddev/bake/format-hook.mjs +2 -0
- package/src/sharddev/bake/generatorGlb.ts +23 -0
- package/src/sharddev/bake/geometryBounds.ts +77 -0
- package/src/sharddev/bake/geometryError.ts +48 -0
- package/src/sharddev/bake/glb.ts +355 -0
- package/src/sharddev/bake/glbCompression.ts +143 -0
- package/src/sharddev/bake/gltfSource.ts +59 -0
- package/src/sharddev/bake/groundMap.ts +142 -0
- package/src/sharddev/bake/image.ts +20 -0
- package/src/sharddev/bake/isleMap.ts +64 -0
- package/src/sharddev/bake/json.mjs +84 -0
- package/src/sharddev/bake/keyedSky.ts +47 -0
- package/src/sharddev/bake/keyedSkyMemo.ts +39 -0
- package/src/sharddev/bake/kinds.ts +137 -0
- package/src/sharddev/bake/lightSources.ts +31 -0
- package/src/sharddev/bake/mapAssembly.ts +84 -0
- package/src/sharddev/bake/mapRaster.ts +173 -0
- package/src/sharddev/bake/mapRest.ts +57 -0
- package/src/sharddev/bake/mapScenes.ts +234 -0
- package/src/sharddev/bake/materialGraph.ts +32 -0
- package/src/sharddev/bake/meadow.ts +27 -0
- package/src/sharddev/bake/meshoptChoiceMemo.ts +34 -0
- package/src/sharddev/bake/nativeInteractionFacts.ts +5 -0
- package/src/sharddev/bake/nativeLattice.ts +178 -0
- package/src/sharddev/bake/nativeRaster.ts +106 -0
- package/src/sharddev/bake/nativeTerrainField.ts +11 -0
- package/src/sharddev/bake/navigation-json.mjs +38 -0
- package/src/sharddev/bake/navigation.ts +113 -0
- package/src/sharddev/bake/navigationAsset.ts +18 -0
- package/src/sharddev/bake/nearPlaceholder.ts +206 -0
- package/src/sharddev/bake/normalizeRig.ts +80 -0
- package/src/sharddev/bake/phoneAstc.ts +93 -0
- package/src/sharddev/bake/placeholders.ts +581 -0
- package/src/sharddev/bake/placement.ts +80 -0
- package/src/sharddev/bake/portableBytes.ts +18 -0
- package/src/sharddev/bake/portableBytesMemo.ts +50 -0
- package/src/sharddev/bake/practiceCourse.ts +49 -0
- package/src/sharddev/bake/primitives.ts +96 -0
- package/src/sharddev/bake/props.ts +443 -0
- package/src/sharddev/bake/questPlacement.ts +98 -0
- package/src/sharddev/bake/rawTexture.ts +26 -0
- package/src/sharddev/bake/riderArms.ts +97 -0
- package/src/sharddev/bake/rig.ts +95 -0
- package/src/sharddev/bake/riggedHullRecipes.ts +40 -0
- package/src/sharddev/bake/signPlacements.ts +25 -0
- package/src/sharddev/bake/simplifier.ts +52 -0
- package/src/sharddev/bake/skinned.ts +312 -0
- package/src/sharddev/bake/slabChunks.ts +149 -0
- package/src/sharddev/bake/slabs.ts +263 -0
- package/src/sharddev/bake/source-loader.mjs +55 -0
- package/src/sharddev/bake/sourceMetadata.ts +54 -0
- package/src/sharddev/bake/species.ts +368 -0
- package/src/sharddev/bake/specimenCatalogue.ts +47 -0
- package/src/sharddev/bake/splatGround.ts +141 -0
- package/src/sharddev/bake/staticMaterials.ts +171 -0
- package/src/sharddev/bake/terrain.ts +195 -0
- package/src/sharddev/bake/texture.ts +33 -0
- package/src/sharddev/bake/textureWasm.ts +81 -0
- package/src/sharddev/bake/tileEncoder.ts +11 -0
- package/src/sharddev/bake/tileGrid.ts +62 -0
- package/src/sharddev/bake/v2Finite.ts +160 -0
- package/src/sharddev/bake/v2Fuel.ts +71 -0
- package/src/sharddev/bake/wholePartition.ts +74 -0
- package/src/sharddev/bake/wholePieceJoin.ts +147 -0
- package/src/sharddev/bake/world.ts +173 -0
- package/src/sharddev/bake/worldCollision.ts +128 -0
- package/src/sharddev/bake/worldGeometry.ts +237 -0
- package/src/sharddev/bake/worldGlb.ts +123 -0
- package/src/sharddev/bake/worldImage.ts +12 -0
- package/src/sharddev/bake/worldLod.ts +128 -0
- package/src/sharddev/bake/worldRows.ts +102 -0
- package/src/sharddev/bake/worldTextureMemo.ts +63 -0
- package/src/sharddev/bake/zstdBytesMemo.ts +52 -0
- package/src/sharddev/bake.ts +193 -0
- package/src/sharddev/bakePublication.ts +31 -0
- package/src/sharddev/behaviourSource.ts +94 -0
- package/src/sharddev/bin/wildshard.mjs +7 -0
- package/src/sharddev/blobBytes.ts +65 -0
- package/src/sharddev/blobs.ts +138 -0
- package/src/sharddev/bootInventory.ts +129 -0
- package/src/sharddev/bossProfiles.ts +18 -0
- package/src/sharddev/buildBehaviour.ts +77 -0
- package/src/sharddev/buildCacheMetrics.ts +17 -0
- package/src/sharddev/buildDecisionScripts.ts +122 -0
- package/src/sharddev/check.ts +117 -0
- package/src/sharddev/checkProject.ts +126 -0
- package/src/sharddev/cli.ts +191 -0
- package/src/sharddev/clientChannels.ts +169 -0
- package/src/sharddev/clientScripts.ts +10 -0
- package/src/sharddev/commons.ts +77 -0
- package/src/sharddev/commonsCosts.ts +11 -0
- package/src/sharddev/compileMovers.ts +11 -0
- package/src/sharddev/configBoundary.ts +6 -0
- package/src/sharddev/cookInput.ts +40 -0
- package/src/sharddev/crowds.ts +6 -0
- package/src/sharddev/decisionBindingMap.ts +11 -0
- package/src/sharddev/decisionScriptBindings.ts +117 -0
- package/src/sharddev/decisionScripts.ts +28 -0
- package/src/sharddev/decisionSource.ts +51 -0
- package/src/sharddev/dev.ts +113 -0
- package/src/sharddev/director.ts +26 -0
- package/src/sharddev/directorAbi.ts +77 -0
- package/src/sharddev/discoveryDocument.ts +97 -0
- package/src/sharddev/draft.ts +11 -0
- package/src/sharddev/eliteEntryRows.ts +29 -0
- package/src/sharddev/entries.ts +76 -0
- package/src/sharddev/entryReads.ts +73 -0
- package/src/sharddev/executeBundle.ts +55 -0
- package/src/sharddev/finds.ts +5 -0
- package/src/sharddev/formatJsonSchema.ts +3 -0
- package/src/sharddev/generationCache.ts +257 -0
- package/src/sharddev/generationRecipe.ts +94 -0
- package/src/sharddev/handwritten.ts +110 -0
- package/src/sharddev/immutable.ts +14 -0
- package/src/sharddev/interactions.ts +38 -0
- package/src/sharddev/kit/bakedGeometry.ts +16 -0
- package/src/sharddev/kit/geometryPack.ts +110 -0
- package/src/sharddev/ledger.ts +13 -0
- package/src/sharddev/looks/tileField.ts +67 -0
- package/src/sharddev/materialGraphFiles.ts +57 -0
- package/src/sharddev/materials.ts +574 -0
- package/src/sharddev/measure.ts +18 -0
- package/src/sharddev/modes.ts +115 -0
- package/src/sharddev/moverPrograms.ts +213 -0
- package/src/sharddev/movers.ts +75 -0
- package/src/sharddev/nativePopulationRows.ts +46 -0
- package/src/sharddev/newProject.ts +247 -0
- package/src/sharddev/noise.ts +54 -0
- package/src/sharddev/outputProduct.ts +188 -0
- package/src/sharddev/outputRuntime.ts +66 -0
- package/src/sharddev/performancePolicy.ts +18 -0
- package/src/sharddev/phasedBoss.ts +34 -0
- package/src/sharddev/physics.ts +194 -0
- package/src/sharddev/platformSections.ts +42 -0
- package/src/sharddev/plumbing.ts +8 -0
- package/src/sharddev/productOutput.ts +128 -0
- package/src/sharddev/project.ts +337 -0
- package/src/sharddev/projectCompilerIdentity.ts +94 -0
- package/src/sharddev/projectDecisions.ts +66 -0
- package/src/sharddev/projectEntryProof.ts +32 -0
- package/src/sharddev/projectGeneration.ts +219 -0
- package/src/sharddev/projectInputFiles.ts +47 -0
- package/src/sharddev/projectManifest.ts +108 -0
- package/src/sharddev/projectMap.ts +35 -0
- package/src/sharddev/projectOutput.ts +242 -0
- package/src/sharddev/projectPolicy.ts +17 -0
- package/src/sharddev/projectSections.ts +27 -0
- package/src/sharddev/questGraph.ts +25 -0
- package/src/sharddev/quests.ts +65 -0
- package/src/sharddev/random.ts +61 -0
- package/src/sharddev/refusals.ts +234 -0
- package/src/sharddev/reportCard.ts +13 -0
- package/src/sharddev/returnProjectionV2.ts +81 -0
- package/src/sharddev/rows.ts +192 -0
- package/src/sharddev/runtimeImports.ts +38 -0
- package/src/sharddev/runtimeMirrors.ts +39 -0
- package/src/sharddev/runtimePerformance.ts +38 -0
- package/src/sharddev/scene.ts +321 -0
- package/src/sharddev/sceneAnimation.ts +54 -0
- package/src/sharddev/sceneAudio.ts +64 -0
- package/src/sharddev/sceneDeclarations.ts +100 -0
- package/src/sharddev/sceneGraph.ts +139 -0
- package/src/sharddev/sceneTransform.ts +12 -0
- package/src/sharddev/schemaValidation.ts +61 -0
- package/src/sharddev/sections.ts +47 -0
- package/src/sharddev/shardSource.ts +59 -0
- package/src/sharddev/sourceReader.ts +26 -0
- package/src/sharddev/spawns.ts +38 -0
- package/src/sharddev/species/clips.ts +24 -0
- package/src/sharddev/species.ts +29 -0
- package/src/sharddev/speciesBrains.ts +19 -0
- package/src/sharddev/synth.ts +66 -0
- package/src/sharddev/test/compileDualScriptV2.ts +71 -0
- package/src/sharddev/test/compileSimV2.ts +21 -0
- package/src/sharddev/test/diskScriptScenario.ts +86 -0
- package/src/sharddev/test/scriptScenario.ts +249 -0
- package/src/sharddev/test/scriptSource.ts +12 -0
- package/src/sharddev/version.ts +4 -0
- package/src/sharddev/weapons/bowProfile.ts +20 -0
- package/src/sharddev/weapons/firearmRows.ts +11 -0
- package/src/sharddev/weapons/meleeProfile.ts +71 -0
- package/src/sharddev/weapons/thrownProfile.ts +10 -0
- package/src/sharddev/worldScenes.ts +308 -0
- package/src/sharddev/worldSource.ts +82 -0
- package/src/shards/_template/README.md +78 -0
- package/src/shards/_template/assets/2bf489fdb15f1734ddb4c4f32d500ec6da85c765ec7a4eb28dc6781160e7ec8c +0 -0
- package/src/shards/_template/assets/97ec4d8f75f5fa6239ee919444d6dc19fd35896bb305930c1f050ac6e0e0e6a6 +1 -0
- package/src/shards/_template/assets/a6a587a31327f936b1b04c05ade818c73fc8964260918662db43539465e27586 +0 -0
- package/src/shards/_template/assets/b4fbde0422e125b498c3dc8b9a5cc2516c8598f09e9d0e5f6b639b32f98179e6 +0 -0
- package/src/shards/_template/assets/bfa4dfc9c18979f904557ee8deab0058b8a399be10266f5fb1578b403f482fd4 +1 -0
- package/src/shards/_template/assets/ef3b7ff4fd22715771cb7d68a3977a903c5e7c3dc293542687d04b3ef3ace2cb +0 -0
- package/src/shards/_template/assets/f2db05998615ce1cb79ea96be32c168842eb6a2b34ec01feb86d36404603ee54 +0 -0
- package/src/shards/_template/assets/fef98ebb7fce6f66b26e78ac699e5c90f9bdcfaf8cabeb2b58125347eea8b4ab +0 -0
- package/src/shards/_template/behaviour/boss.as +39 -0
- package/src/shards/_template/behaviour/door.as +32 -0
- package/src/shards/_template/behaviour/hooks.json +129 -0
- package/src/shards/_template/behaviour/idle.as +75 -0
- package/src/shards/_template/behaviour/items.as +22 -0
- package/src/shards/_template/card/landscape.jpg +0 -0
- package/src/shards/_template/card/portrait.jpg +0 -0
- package/src/shards/_template/card/thumb.jpg +0 -0
- package/src/shards/_template/data/audio.json +45 -0
- package/src/shards/_template/data/bossDecision.json +83 -0
- package/src/shards/_template/data/budgets.json +70 -0
- package/src/shards/_template/data/card.json +281 -0
- package/src/shards/_template/data/clientScripts.json +987 -0
- package/src/shards/_template/data/creatures.json +65 -0
- package/src/shards/_template/data/director.json +39 -0
- package/src/shards/_template/data/encounters.json +96 -0
- package/src/shards/_template/data/items.json +172 -0
- package/src/shards/_template/data/layout.json +66 -0
- package/src/shards/_template/data/ledger.json +32 -0
- package/src/shards/_template/data/look.json +521 -0
- package/src/shards/_template/data/map.json +64 -0
- package/src/shards/_template/data/moves.json +16 -0
- package/src/shards/_template/data/placeholder.json +8 -0
- package/src/shards/_template/data/plumbing.json +32 -0
- package/src/shards/_template/data/quests.json +223 -0
- package/src/shards/_template/data/rows.json +423 -0
- package/src/shards/_template/data/skins.json +66 -0
- package/src/shards/_template/data/spawn.json +6 -0
- package/src/shards/_template/data/targets.json +150 -0
- package/src/shards/_template/data/text.json +12 -0
- package/src/shards/_template/data/ui.json +33 -0
- package/src/shards/_template/data/water.json +13 -0
- package/src/shards/_template/generators/behaviour.ts +34 -0
- package/src/shards/_template/generators/boss.ts +29 -0
- package/src/shards/_template/generators/buildOptions.ts +2 -0
- package/src/shards/_template/generators/cell.ts +224 -0
- package/src/shards/_template/generators/districts.ts +215 -0
- package/src/shards/_template/generators/farLook.ts +15 -0
- package/src/shards/_template/generators/generate.ts +27 -0
- package/src/shards/_template/generators/ground.ts +15 -0
- package/src/shards/_template/generators/kit.ts +69 -0
- package/src/shards/_template/generators/landscape.ts +59 -0
- package/src/shards/_template/generators/landscapeNoise.ts +62 -0
- package/src/shards/_template/generators/mapInputs.ts +10 -0
- package/src/shards/_template/generators/product.ts +100 -0
- package/src/shards/_template/generators/productOutput.ts +18 -0
- package/src/shards/_template/generators/props.ts +9 -0
- package/src/shards/_template/generators/templatePropsSource.ts +58 -0
- package/src/shards/_template/generators/terrain.ts +17 -0
- package/src/shards/_template/generators/world.ts +630 -0
- package/src/shards/_template/hero.json +10 -0
- package/src/shards/_template/look/entry-reads.json +20 -0
- package/src/shards/_template/manifest.json +281 -0
- package/src/shards/_template/shard.config.ts +10 -0
- package/src/shared/health.ts +10 -0
- package/src/tools/build-web.ts +59 -0
- package/src/tsconfig.json +30 -0
- package/src/web/app.tsx +53 -0
- package/src/web/index.html +12 -0
- package/src/web/main.tsx +10 -0
- package/src/web/tsconfig.json +13 -0
- package/tsconfig.author.json +23 -0
- package/tsconfig.commons.json +21 -0
- package/tsconfig.json +47 -0
- package/tsconfig.sharddev.json +20 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { KEYCHAIN_ARGS } from './chromium-keychain.mjs';
|
|
3
|
+
import { debugSettings, harnessPins } from '@wildshard/engine/scripts/debug-settings.mjs';
|
|
4
|
+
// gpu-texmem.mjs — how much GPU memory each shard's textures take (E157, KTX2 / Basis GPU compression).
|
|
5
|
+
//
|
|
6
|
+
// Counts at the WebGL call, not from three's bookkeeping: an init script wraps texStorage2D/3D, texImage2D/3D,
|
|
7
|
+
// compressedTexImage2D/3D, generateMipmap, renderbufferStorage(Multisample) and deleteTexture / deleteRenderbuffer, and
|
|
8
|
+
// keeps, per live WebGLTexture, the bytes its levels hold (internal format × width × height × depth; RGB8 counted as 4
|
|
9
|
+
// bytes a texel, which is what the GPU stores; a compressed level is its byte length). A texture that a framebuffer
|
|
10
|
+
// ever attached is a render target and is summed apart (bloom, shadow maps, the composer: not what KTX2 changes).
|
|
11
|
+
// After the settle the page's scene is walked: every texture a material or ShaderMaterial uniform holds is matched to
|
|
12
|
+
// its WebGLTexture (renderer.properties) and labelled with the mesh that draws it, so the table says whose bytes they are.
|
|
13
|
+
//
|
|
14
|
+
// node scripts/gpu-texmem.mjs --url=http://localhost:4391 --chunk=pine-hollow --tier=phone [--tex=ktx2|img] [--tag=x]
|
|
15
|
+
// … --record record individual files through the unavailable-pack fallback and merge the
|
|
16
|
+
// files this boot loaded into scripts/bake-ktx2.list.json (bake-ktx2's list)
|
|
17
|
+
//
|
|
18
|
+
// Phone: 390×844 @3, iPhone UA, `touch=1&tier=phone`. Desktop: 1600×900 @1, `tier=desktop`. One headless Chromium on
|
|
19
|
+
// Metal, muted (`--mute-audio`, `mute=1`), closed at the end. Writes progress/texmem/<tag>-<chunk>-<tier>.json.
|
|
20
|
+
import { writeFileSync, mkdirSync, readFileSync } from 'node:fs';
|
|
21
|
+
import { resolve as resolvePath } from 'node:path';
|
|
22
|
+
import { ledger, report } from './texmem-probe.mjs';
|
|
23
|
+
|
|
24
|
+
const { chromium, devices } = await import('playwright');
|
|
25
|
+
const ROOT = resolvePath(new URL('..', import.meta.url).pathname);
|
|
26
|
+
const argv = process.argv.slice(2);
|
|
27
|
+
const flag = (name, d) => { const a = argv.find((x) => x.startsWith(`--${name}=`)); return a ? a.slice(name.length + 3) : d; };
|
|
28
|
+
const URL_BASE = flag('url', 'http://localhost:4391');
|
|
29
|
+
const CHUNK = flag('chunk', 'pine-hollow');
|
|
30
|
+
const TIER = flag('tier', 'phone');
|
|
31
|
+
const EXTRA = flag('query', '');
|
|
32
|
+
/** --tex=ktx2|img: the textures (E157) — a harness pin (`__wildshardHarness.textures`, G386), never a setting or URL switch;
|
|
33
|
+
* the background prefetch of the other shards (E158) is off either way, so it adds nothing to the ledger */
|
|
34
|
+
const TEX = flag('tex', '');
|
|
35
|
+
const TAG = flag('tag', 'latest');
|
|
36
|
+
const SETTLE = Number(flag('settle', '10')) * 1000;
|
|
37
|
+
const TOP = Number(flag('top', '25'));
|
|
38
|
+
/** --record: merge the texture / model URLs this boot fetched into scripts/bake-ktx2.list.json (what bake-ktx2 bakes) */
|
|
39
|
+
const RECORD = argv.includes('--record');
|
|
40
|
+
|
|
41
|
+
const sleep = (ms) => new Promise((resolve) => { setTimeout(resolve, ms); });
|
|
42
|
+
const browser = await chromium.launch({ args: [...KEYCHAIN_ARGS, '--mute-audio', '--use-angle=metal', '--ignore-gpu-blocklist', '--enable-precise-memory-info', '--js-flags=--expose-gc'] });
|
|
43
|
+
try {
|
|
44
|
+
const phone = TIER === 'phone';
|
|
45
|
+
const iphone = devices['iPhone 16 Pro'];
|
|
46
|
+
const ctx = await browser.newContext(phone
|
|
47
|
+
? { userAgent: iphone.userAgent, isMobile: true, hasTouch: true, deviceScaleFactor: 3, viewport: { width: 390, height: 844 } }
|
|
48
|
+
: { viewport: { width: 1600, height: 900 }, deviceScaleFactor: 1 });
|
|
49
|
+
await ctx.addInitScript(ledger);
|
|
50
|
+
await debugSettings(ctx, { prefetch: 'off' });
|
|
51
|
+
if (TEX !== '') await harnessPins(ctx, { textures: TEX });
|
|
52
|
+
// G221: CLI-only fetch adapter; no in-game option, saved state or network error.
|
|
53
|
+
// The engine's normal unavailable-part fallback fetches each original URL for the ledger.
|
|
54
|
+
if (RECORD) await ctx.addInitScript(() => {
|
|
55
|
+
const fetchNow = window.fetch.bind(window);
|
|
56
|
+
window.fetch = (input, init) => {
|
|
57
|
+
const url = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url;
|
|
58
|
+
return new URL(url, location.href).pathname.startsWith('/assets/packs/')
|
|
59
|
+
? Promise.resolve(new Response(null, { status: 503 })) : fetchNow(input, init);
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
const page = await ctx.newPage();
|
|
63
|
+
const errors = [];
|
|
64
|
+
page.on('pageerror', (e) => errors.push(e.message.slice(0, 200)));
|
|
65
|
+
page.on('console', (m) => { if (m.type() === 'error' || /ktx2|KTX2|basis/i.test(m.text())) errors.push(`[${m.type()}] ${m.text().slice(0, 200)}`); });
|
|
66
|
+
const q = [`chunk=${CHUNK}`, 'mute=1', 'skipintro=1', 'nolock=1', 'sw=0', `tier=${TIER}`, phone ? 'touch=1' : '', EXTRA].filter(Boolean).join('&');
|
|
67
|
+
const t0 = Date.now();
|
|
68
|
+
await page.goto(`${URL_BASE}/?${q}`, { waitUntil: 'domcontentloaded' });
|
|
69
|
+
await page.waitForFunction(() => Boolean(window.__wildshard?.world?.game), undefined, { timeout: 300000, polling: 500 });
|
|
70
|
+
const readyS = (Date.now() - t0) / 1000;
|
|
71
|
+
await sleep(SETTLE);
|
|
72
|
+
// the JS heap after a full collection: what the page holds, not the garbage the boot left
|
|
73
|
+
await page.evaluate(async () => { for (let i = 0; i < 3; i++) { window.gc?.(); await new Promise((resolve) => { setTimeout(resolve, 200); }); } });
|
|
74
|
+
const r = await page.evaluate(report, TOP);
|
|
75
|
+
const out = { tag: TAG, chunk: CHUNK, tier: TIER, tex: TEX, query: q, readyS, when: new Date().toISOString(), errors: errors.slice(0, 20), ...r };
|
|
76
|
+
mkdirSync(resolvePath(ROOT, 'progress/texmem'), { recursive: true });
|
|
77
|
+
const file = resolvePath(ROOT, `progress/texmem/${TAG}-${CHUNK}-${TIER}.json`);
|
|
78
|
+
writeFileSync(file, `${JSON.stringify(out, null, 1)}\n`);
|
|
79
|
+
console.log(`[texmem] ${CHUNK} ${TIER} tex=${TEX === '' ? '(default)' : TEX} ${EXTRA} · ready ${readyS.toFixed(0)} s`);
|
|
80
|
+
console.log(` textures ${r.textureMB} MB in ${r.textures} (compressed ${r.compressedMB} MB in ${r.compressedTextures}) · in scene ${r.inSceneMB} MB · render targets ${r.renderTargetMB} MB · renderbuffers ${r.renderbufferMB} MB · JS heap ${r.jsHeapMB} MB`);
|
|
81
|
+
console.log(` by format ${JSON.stringify(r.byFormat)}`);
|
|
82
|
+
for (const [k, v] of Object.entries(r.byClass).sort((a, b) => b[1].mb - a[1].mb).slice(0, 30)) console.log(` ${String(v.mb.toFixed(1)).padStart(7)} MB ${String(v.n).padStart(4)} ${k}`);
|
|
83
|
+
console.log(` compressed ext: ${r.compressedExtensions.join(' ')}`);
|
|
84
|
+
for (const x of r.top) console.log(` ${String(x.mb).padStart(6)} MB ${`${x.w}x${x.h}${x.d > 1 ? `x${x.d}` : ''}`.padEnd(14)} ${x.fmt.padEnd(12)} ${x.mips.padEnd(7)} ${String(x.src).slice(-40).padEnd(40)} ${x.where.slice(0, 90)}`);
|
|
85
|
+
if (errors.length > 0) console.log(` errors: ${errors.slice(0, 5).join(' / ')}`);
|
|
86
|
+
console.log(` → ${file}`);
|
|
87
|
+
if (RECORD) {
|
|
88
|
+
const listFile = resolvePath(ROOT, 'scripts/bake-ktx2.list.json');
|
|
89
|
+
const list = JSON.parse(readFileSync(listFile, 'utf8'));
|
|
90
|
+
const keep = (u) => /\.(glb|gltf|png|jpe?g|webp)$/.test(u) && !/^\/(?:assets|b\/[\w.-]+)\/[^/]+-[\w-]{8}\.\w+$/.test(u) && !u.includes('/hdri/') && !u.startsWith('/assets/gpu/');
|
|
91
|
+
const before = list[TIER].length;
|
|
92
|
+
list[TIER] = [...new Set([...list[TIER], ...r.fetched.filter(keep)])].sort((a, b) => a.localeCompare(b));
|
|
93
|
+
writeFileSync(listFile, `${JSON.stringify(list, null, 1)}\n`);
|
|
94
|
+
console.log(` recorded: ${list[TIER].length - before} new ${TIER} URLs → ${listFile}`);
|
|
95
|
+
}
|
|
96
|
+
} finally {
|
|
97
|
+
await browser.close();
|
|
98
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""config.py — a shard's painted-horizon parameters (PINE-HOLLOW-REMASTER PH-0.3), shared by mkjobs / stitch / key.
|
|
2
|
+
|
|
3
|
+
src/shards/<shard>/art/horizon-matte.json holds the capture (eye, headings, vfov, frame size, tod), the strip (size,
|
|
4
|
+
elevation range — HorizonMatte.ts draws the same range), the stitch feathering, the key's feet and the codex prompt sets.
|
|
5
|
+
Every script takes `--shard <slug>` (default driftwood-isle) or `--config <json>`.
|
|
6
|
+
"""
|
|
7
|
+
import json
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
HERE = Path(__file__).resolve().parent
|
|
11
|
+
DEFAULT_SHARD = 'driftwood-isle'
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def add_args(ap):
|
|
15
|
+
ap.add_argument('--shard', default=DEFAULT_SHARD, help='the shard slug (default driftwood-isle)')
|
|
16
|
+
ap.add_argument('--config', default=None, help='a config JSON (default the shard\'s art/horizon-matte.json)')
|
|
17
|
+
return ap
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def load(args):
|
|
21
|
+
p = Path(args.config) if args.config else HERE.parents[1] / 'src' / 'shards' / args.shard / 'art' / 'horizon-matte.json'
|
|
22
|
+
if not p.exists():
|
|
23
|
+
raise SystemExit(f'horizon-matte: no config for {args.shard} ({p}); copy art/horizon-matte.json from Driftwood and re-shoot the capture')
|
|
24
|
+
return json.loads(p.read_text())
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""encode.py [--shard <slug> | --config <json>] <keyed_rgba.png> <out-base> — a keyed strip → the game's WebP textures.
|
|
3
|
+
|
|
4
|
+
A PBR shard (Pine Hollow) draws its painted horizon in the linear HDR scene, before the post chain's AgX tone map, so the
|
|
5
|
+
painting (display-referred: it was painted over the game's own tone-mapped frames) is sent back through AgX's inverse
|
|
6
|
+
(three's AgXToneMapping, exposure 1: outset⁻¹, the sigmoid's inverse, exp2, inset⁻¹, Rec.2020 → sRGB) to the scene-linear
|
|
7
|
+
values that tone-map back to it. Those are stored sRGB-encoded divided by `encode.scale` (the shader multiplies it back),
|
|
8
|
+
so 8 bits keep the dark forest. Writes <out-base>.webp (the strip's size) and <out-base>-phone.webp (half), lossy with
|
|
9
|
+
alpha at `encode.quality`. `encode.tonemap: "none"` stores the painting as is (a shard without a tone map).
|
|
10
|
+
"""
|
|
11
|
+
import argparse
|
|
12
|
+
import subprocess
|
|
13
|
+
import tempfile
|
|
14
|
+
import os
|
|
15
|
+
import numpy as np
|
|
16
|
+
from PIL import Image
|
|
17
|
+
|
|
18
|
+
import config
|
|
19
|
+
|
|
20
|
+
ap = config.add_args(argparse.ArgumentParser(description='encode a keyed horizon strip for the game'))
|
|
21
|
+
ap.add_argument('src')
|
|
22
|
+
ap.add_argument('out')
|
|
23
|
+
a = ap.parse_args()
|
|
24
|
+
cfg = config.load(a)
|
|
25
|
+
E = cfg.get('encode', {})
|
|
26
|
+
SCALE = float(E.get('scale', 1.0))
|
|
27
|
+
Q = int(E.get('quality', 86))
|
|
28
|
+
|
|
29
|
+
# three.js AgXToneMapping (tonemapping_pars_fragment); GLSL mat3(c0, c1, c2) is column-major
|
|
30
|
+
def colmat(*cols):
|
|
31
|
+
return np.array(cols, dtype=np.float64).T
|
|
32
|
+
SRGB_TO_2020 = colmat((0.6274, 0.0691, 0.0164), (0.3293, 0.9195, 0.0880), (0.0433, 0.0113, 0.8956))
|
|
33
|
+
R2020_TO_SRGB = colmat((1.6605, -0.1246, -0.0182), (-0.5876, 1.1329, -0.1006), (-0.0728, -0.0083, 1.1187))
|
|
34
|
+
INSET = colmat((0.856627153315983, 0.137318972929847, 0.11189821299995), (0.0951212405381588, 0.761241990602591, 0.0767994186031903), (0.0482516061458583, 0.101439036467562, 0.811302368396859))
|
|
35
|
+
OUTSET = colmat((1.1271005818144368, -0.1413297634984383, -0.14132976349843826), (-0.11060664309660323, 1.157823702216272, -0.11060664309660294), (-0.016493938717834573, -0.016493938717834257, 1.2519364065950405))
|
|
36
|
+
MIN_EV, MAX_EV = -12.47393, 4.026069
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def sigmoid(x):
|
|
40
|
+
x2 = x * x; x4 = x2 * x2
|
|
41
|
+
return 15.5 * x4 * x2 - 40.14 * x4 * x + 31.96 * x4 - 6.868 * x2 * x + 0.4298 * x2 + 0.1191 * x - 0.00232
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def agx(c):
|
|
45
|
+
c = c @ SRGB_TO_2020.T @ INSET.T
|
|
46
|
+
c = np.clip((np.log2(np.maximum(c, 1e-10)) - MIN_EV) / (MAX_EV - MIN_EV), 0, 1)
|
|
47
|
+
c = sigmoid(c) @ OUTSET.T
|
|
48
|
+
c = np.power(np.maximum(c, 0), 2.2) @ R2020_TO_SRGB.T
|
|
49
|
+
return np.clip(c, 0, 1)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
XS = np.linspace(0, 1, 8193); YS = np.maximum.accumulate(sigmoid(XS))
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def agx_inverse(d):
|
|
56
|
+
c = d @ np.linalg.inv(R2020_TO_SRGB).T
|
|
57
|
+
c = np.power(np.maximum(c, 0), 1 / 2.2) @ np.linalg.inv(OUTSET).T
|
|
58
|
+
c = np.interp(c, YS, XS)
|
|
59
|
+
c = np.exp2(c * (MAX_EV - MIN_EV) + MIN_EV)
|
|
60
|
+
return np.maximum(c @ np.linalg.inv(INSET).T @ np.linalg.inv(SRGB_TO_2020).T, 0)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def srgb_decode(v):
|
|
64
|
+
return np.where(v <= 0.04045, v / 12.92, ((v + 0.055) / 1.055) ** 2.4)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def srgb_encode(v):
|
|
68
|
+
v = np.clip(v, 0, 1)
|
|
69
|
+
return np.where(v <= 0.0031308, v * 12.92, 1.055 * np.power(v, 1 / 2.4) - 0.055)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
im = np.asarray(Image.open(a.src).convert('RGBA'), dtype=np.float64) / 255
|
|
73
|
+
rgb, alpha = im[..., :3], im[..., 3:]
|
|
74
|
+
if E.get('tonemap', 'none') == 'agx':
|
|
75
|
+
lin = agx_inverse(srgb_decode(rgb))
|
|
76
|
+
back = srgb_encode(agx(lin))
|
|
77
|
+
err = np.abs(back - rgb)[alpha[..., 0] > 0.5]
|
|
78
|
+
print(f'AgX round trip on the land: mean {err.mean() * 255:.2f} / p99 {np.percentile(err, 99) * 255:.2f} (8-bit steps); '
|
|
79
|
+
f'land linear max {lin[alpha[..., 0] > 0.5].max():.2f} / p99.9 {np.percentile(lin[alpha[..., 0] > 0.5], 99.9):.2f}, land clipped over scale {SCALE}: {(lin > SCALE).any(-1)[alpha[..., 0] > 0.5].mean() * 100:.2f} %')
|
|
80
|
+
rgb = srgb_encode(lin / SCALE)
|
|
81
|
+
out = np.dstack([rgb, alpha])
|
|
82
|
+
img = Image.fromarray((out * 255 + 0.5).astype(np.uint8), 'RGBA')
|
|
83
|
+
H, W = img.height, img.width
|
|
84
|
+
for suffix, size in (('', (W, H)), ('-phone', (W // 2, H // 2))):
|
|
85
|
+
dst = f'{a.out}{suffix}.webp'
|
|
86
|
+
im2 = img if size == (W, H) else img.resize(size, Image.LANCZOS)
|
|
87
|
+
with tempfile.TemporaryDirectory() as td:
|
|
88
|
+
png = os.path.join(td, 'x.png'); im2.save(png)
|
|
89
|
+
# cwebp keeps the alpha plane's edges exact (-exact: no RGB bleed under transparent texels is dropped)
|
|
90
|
+
subprocess.run(['cwebp', '-quiet', '-q', str(Q), '-alpha_q', '100', '-exact', '-m', '6', png, '-o', dst], check=True)
|
|
91
|
+
print('wrote', dst, os.path.getsize(dst) // 1024, 'KB')
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""key.py [--shard <slug> | --config <json>] <strip.png> <out_rgba.png> [--night] [--alpha-from other_rgba.png]
|
|
3
|
+
|
|
4
|
+
Pulls the painted far distance off the painted sky: a per-row, slowly varying sky model S(x, y) estimated from the
|
|
5
|
+
strip's own sky pixels, alpha = how far a pixel is from it, colour un-mixed (F = S + (P - S) / a). Below the horizon
|
|
6
|
+
row the painted feet are kept for `key.feet` deg then faded out by -`key.fadeTo` deg (Driftwood: 0.6 / 1.6 — the game's
|
|
7
|
+
sea covers it). The strip's elevation range and the feet come from src/shards/<shard>/art/horizon-matte.json.
|
|
8
|
+
"""
|
|
9
|
+
import argparse
|
|
10
|
+
import numpy as np
|
|
11
|
+
from PIL import Image
|
|
12
|
+
from scipy.ndimage import uniform_filter1d, gaussian_filter
|
|
13
|
+
|
|
14
|
+
import config
|
|
15
|
+
|
|
16
|
+
ap = config.add_args(argparse.ArgumentParser(description='key a stitched horizon strip to RGBA'))
|
|
17
|
+
ap.add_argument('src')
|
|
18
|
+
ap.add_argument('out')
|
|
19
|
+
ap.add_argument('--night', action='store_true', help='the night strip: a darker sky classifier')
|
|
20
|
+
ap.add_argument('--alpha-from', default=None, help='take alpha from this keyed RGBA (the night strip reuses the day alpha)')
|
|
21
|
+
ARGS = ap.parse_args()
|
|
22
|
+
CFG = config.load(ARGS)
|
|
23
|
+
EL_MIN, EL_MAX = CFG['strip']['elMin'], CFG['strip']['elMax']
|
|
24
|
+
FEET, FADE_TO = CFG['key']['feet'], CFG['key']['fadeTo']
|
|
25
|
+
src, out = ARGS.src, ARGS.out
|
|
26
|
+
night = ARGS.night
|
|
27
|
+
P = np.asarray(Image.open(src).convert('RGB'), dtype=np.float32) / 255
|
|
28
|
+
H, W, _ = P.shape
|
|
29
|
+
el = EL_MAX - (EL_MAX - EL_MIN) * (np.arange(H) + 0.5) / H
|
|
30
|
+
|
|
31
|
+
mx = P.max(-1); mn = P.min(-1)
|
|
32
|
+
sat = (mx - mn) / np.maximum(mx, 1e-4)
|
|
33
|
+
r, g, b = P[..., 0], P[..., 1], P[..., 2]
|
|
34
|
+
if night:
|
|
35
|
+
skyish = (b > r + 0.03) & (b >= g) & (mx < 0.55)
|
|
36
|
+
else:
|
|
37
|
+
skyish = (b > r + 0.12) & (b >= g) & (sat > 0.22)
|
|
38
|
+
SKYLINE = CFG['key'].get('mode') == 'skyline'
|
|
39
|
+
if SKYLINE:
|
|
40
|
+
# photoreal land under a plain sky (Pine Hollow): the sky is whatever is smooth and connected to the strip's top — a flood
|
|
41
|
+
# from the top row through low-texture pixels, stopped by the skyline's edge and by the horizon (below it all is land).
|
|
42
|
+
# Colour classifiers fail here: the pale haze band on the horizon is neither blue nor saturated, and hazy far ridges are.
|
|
43
|
+
from scipy.ndimage import label, binary_opening
|
|
44
|
+
elg0 = el[:, None] * np.ones((1, W))
|
|
45
|
+
Pb = gaussian_filter(P, sigma=(1.0, 1.0, 0), mode=['nearest', 'wrap', 'nearest'])
|
|
46
|
+
tex = (np.abs(np.diff(Pb, axis=0, prepend=Pb[:1])) + np.abs(np.diff(Pb, axis=1, prepend=Pb[:, -1:]))).sum(-1)
|
|
47
|
+
tex = gaussian_filter(tex, 0.8, mode=['nearest', 'wrap'])
|
|
48
|
+
top_sky = tex[elg0 > EL_MAX - 3]
|
|
49
|
+
THR = CFG['key'].get('texture', max(0.012, float(np.percentile(top_sky, 99.5)) * 2.5))
|
|
50
|
+
smooth = (tex < THR) & (elg0 > CFG['key'].get('horizon', -0.3))
|
|
51
|
+
lab, _ = label(smooth)
|
|
52
|
+
ids = np.unique(lab[0][lab[0] > 0])
|
|
53
|
+
skyish = binary_opening(np.isin(lab, ids), structure=np.ones((3, 3)))
|
|
54
|
+
print(f'skyline key: texture threshold {THR:.4f}, sky {skyish.mean() * 100:.1f} % of the strip')
|
|
55
|
+
|
|
56
|
+
# sky model: windowed mean of sky-classified pixels along each row (wrapping), then filled / smoothed vertically
|
|
57
|
+
WIN = 301
|
|
58
|
+
S = np.zeros_like(P); cnt = np.zeros((H, W), np.float32)
|
|
59
|
+
m = skyish.astype(np.float32)
|
|
60
|
+
pad = WIN // 2
|
|
61
|
+
def wrapfilt(a):
|
|
62
|
+
ap = np.concatenate([a[:, -pad:], a, a[:, :pad]], 1)
|
|
63
|
+
return uniform_filter1d(ap, WIN, axis=1)[:, pad:pad + W]
|
|
64
|
+
cnt = wrapfilt(m)
|
|
65
|
+
for c in range(3):
|
|
66
|
+
S[..., c] = wrapfilt(P[..., c] * m) / np.maximum(cnt, 1e-4)
|
|
67
|
+
# rows / places with too few sky samples: carry the value down from above
|
|
68
|
+
ok = cnt > 0.08
|
|
69
|
+
for y in range(1, H):
|
|
70
|
+
bad = ~ok[y]
|
|
71
|
+
S[y, bad] = S[y - 1, bad]
|
|
72
|
+
ok[y, bad] = ok[y - 1, bad]
|
|
73
|
+
S = gaussian_filter(S, sigma=(3, 12, 0), mode=['nearest', 'wrap', 'nearest'])
|
|
74
|
+
|
|
75
|
+
d = np.sqrt(((P - S) ** 2).sum(-1))
|
|
76
|
+
lo, hi = (0.035, 0.14) if not night else (0.03, 0.12)
|
|
77
|
+
t = np.clip((d - lo) / (hi - lo), 0, 1)
|
|
78
|
+
A = t * t * (3 - 2 * t)
|
|
79
|
+
A = gaussian_filter(A, 0.6)
|
|
80
|
+
# fill enclosed holes (hazy blue-grey rock faces read as sky): low-alpha pockets not connected to the open sky above
|
|
81
|
+
from scipy.ndimage import binary_fill_holes, binary_closing
|
|
82
|
+
solid = binary_closing(A > 0.45, structure=np.ones((5, 5)), iterations=1)
|
|
83
|
+
solid[int(H * (EL_MAX - 0) / (EL_MAX - EL_MIN)):, :] = True # the sea / ground closes every pocket from below
|
|
84
|
+
wrapw = 64
|
|
85
|
+
tiled = np.concatenate([solid[:, -wrapw:], solid, solid[:, :wrapw]], 1)
|
|
86
|
+
filled = binary_fill_holes(tiled)[:, wrapw:wrapw + W]
|
|
87
|
+
A = np.maximum(A, gaussian_filter(filled.astype(np.float32), 0.8) * filled)
|
|
88
|
+
# below the horizon: keep the painted feet FEET deg, then fade the painted sea out
|
|
89
|
+
elg = el[:, None] * np.ones((1, W))
|
|
90
|
+
below = np.clip((elg + FADE_TO) / (FADE_TO - FEET), 0, 1) # 1 at -FEET deg, 0 at -FADE_TO (Driftwood 0.6 / 1.6)
|
|
91
|
+
A = np.where(elg < 0, np.where(elg > -FEET, 1.0, below), A)
|
|
92
|
+
# very top: nothing
|
|
93
|
+
A *= np.clip((EL_MAX - 0.3 - elg) / 2.0, 0, 1)
|
|
94
|
+
|
|
95
|
+
if SKYLINE:
|
|
96
|
+
# land = everything not flooded as sky, softened ~1 px; inside the sky, a difference key keeps what the flood leaked
|
|
97
|
+
# into (a pale far ridge with no edge) as partial alpha over the live sky
|
|
98
|
+
# the flood stops a few px short of the true skyline (the texture measure is blurred), so the land's top rim and the sky
|
|
99
|
+
# just over it take the difference key; sky farther than ~0.8° from land is clear (the feathered sky-tone steps of the
|
|
100
|
+
# stitch are no land)
|
|
101
|
+
from scipy.ndimage import distance_transform_edt
|
|
102
|
+
land = ~skyish
|
|
103
|
+
rim = land & (distance_transform_edt(land) <= 4)
|
|
104
|
+
near = skyish & (distance_transform_edt(skyish) <= 13)
|
|
105
|
+
# the sky there is the colour right above the column's skyline (the pale haze band on the horizon), not the row mean
|
|
106
|
+
yb = np.clip(H - 1 - np.argmax(skyish[::-1], axis=0), 3, H - 1) # each column's lowest sky row
|
|
107
|
+
Sc = np.stack([P[np.clip(yb - k, 0, H - 1), np.arange(W)] for k in range(4)]).mean(0)
|
|
108
|
+
Sc = gaussian_filter(Sc, sigma=(4, 0), mode=['wrap', 'nearest'])
|
|
109
|
+
S = np.where((rim | near)[..., None], Sc[None], S)
|
|
110
|
+
dS = np.sqrt(((P - S) ** 2).sum(-1))
|
|
111
|
+
tS = np.clip((dS - lo) / (hi - lo), 0, 1)
|
|
112
|
+
aD = tS * tS * (3 - 2 * tS)
|
|
113
|
+
# a distance key calls a half-sky edge pixel solid: where the pixel above is not solid land yet, project the pixel on
|
|
114
|
+
# the line sky -> the land 2 px below it instead (the edge's true coverage)
|
|
115
|
+
P2 = np.concatenate([P[2:], P[-2:]], 0)
|
|
116
|
+
L2 = P2 - S
|
|
117
|
+
aP = np.clip(((P - S) * L2).sum(-1) / np.maximum((L2 ** 2).sum(-1), 1e-4), 0, 1)
|
|
118
|
+
aboveLand = np.concatenate([aD[:1], aD[:-1]], 0) > 0.95
|
|
119
|
+
aD = np.where(aboveLand, aD, np.minimum(aD, aP))
|
|
120
|
+
A = np.where(rim | near, aD, land.astype(np.float32))
|
|
121
|
+
A = gaussian_filter(A, 0.5, mode=['nearest', 'wrap'])
|
|
122
|
+
A = np.where(elg < CFG['key'].get('horizon', -0.3), 1.0, A)
|
|
123
|
+
A *= np.clip((EL_MAX - 0.3 - elg) / 2.0, 0, 1)
|
|
124
|
+
if ARGS.alpha_from:
|
|
125
|
+
other = np.asarray(Image.open(ARGS.alpha_from), dtype=np.float32) / 255
|
|
126
|
+
A = other[..., 3]
|
|
127
|
+
|
|
128
|
+
a = np.maximum(A, 0.5 if SKYLINE else 1e-3)[..., None] # photoreal edges: un-mix gently (a pale rim amplified to white otherwise)
|
|
129
|
+
F = np.clip(S + (P - S) / a, 0, 1)
|
|
130
|
+
F = np.where(A[..., None] > 0.02, F, S) # fully transparent texels keep the sky colour (no dark halos in the mips)
|
|
131
|
+
F = np.where(elg[..., None] < 0, P, F)
|
|
132
|
+
rgba = np.dstack([F, A])
|
|
133
|
+
Image.fromarray((rgba * 255 + 0.5).astype(np.uint8), 'RGBA').save(out)
|
|
134
|
+
Image.fromarray((A * 255).astype(np.uint8)).save(out.replace('.png', '-alpha.png'))
|
|
135
|
+
# preview: over a checker of two sky colours
|
|
136
|
+
bg1 = np.array([0.36, 0.62, 0.95]); bg2 = np.array([0.95, 0.55, 0.35])
|
|
137
|
+
chk = ((np.arange(W)[None, :] // 512) % 2).astype(np.float32)[..., None]
|
|
138
|
+
bg = bg1 * (1 - chk) + bg2 * chk
|
|
139
|
+
comp = F * A[..., None] + bg * (1 - A[..., None])
|
|
140
|
+
Image.fromarray((comp * 255).astype(np.uint8)).save(out.replace('.png', '-comp.jpg'), quality=88)
|
|
141
|
+
print('wrote', out, 'mean alpha above horizon', float(A[elg > 0].mean()))
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""mkjobs.py [--shard <slug> | --config <json>] [--set day2] <workdir> — the codex image_gen jobs for one prompt set of a
|
|
3
|
+
shard's painted horizon (one job per capture heading), for run_codex.py.
|
|
4
|
+
|
|
5
|
+
<workdir> holds the in-game captures and references the set names (Driftwood day2: day-<h>.jpg + ref-hero.jpg); writes
|
|
6
|
+
<workdir>/jobs-<set>.json. The prompts live in src/shards/<shard>/art/horizon-matte.json under jobs.<set>: `common`
|
|
7
|
+
plus, per heading, [light, content]. Driftwood's day2 set = art/driftwood-isle/round-9-horizon (was mkjobs_day2.py).
|
|
8
|
+
"""
|
|
9
|
+
import argparse
|
|
10
|
+
import json
|
|
11
|
+
import os
|
|
12
|
+
|
|
13
|
+
import config
|
|
14
|
+
|
|
15
|
+
ap = config.add_args(argparse.ArgumentParser(description=__doc__.split('\n')[0]))
|
|
16
|
+
ap.add_argument('--set', default='day2', help='the prompt set in the config (default day2)')
|
|
17
|
+
ap.add_argument('workdir', nargs='?', default=None, help='captures in, jobs-<set>.json out (default: the cwd)')
|
|
18
|
+
a = ap.parse_args()
|
|
19
|
+
cfg = config.load(a)
|
|
20
|
+
S = cfg['jobs'][a.set]
|
|
21
|
+
H = os.path.abspath(a.workdir) if a.workdir else os.getcwd()
|
|
22
|
+
w, h = cfg['capture']['width'], cfg['capture']['height']
|
|
23
|
+
|
|
24
|
+
jobs = []
|
|
25
|
+
for d, (light, content) in ((int(k), v) for k, v in S['segments'].items()):
|
|
26
|
+
p = (S['common'] + f"\nTHIS SEGMENT: {light}. In the middle 40 %: {content}.\n\n"
|
|
27
|
+
"TASK FOR CODEX: Use the built-in image_gen tool to EDIT the FIRST attached reference image into exactly ONE "
|
|
28
|
+
f"landscape image, {w}x{h}, as described above (same framing, horizon exactly at the vertical middle). One generation only. "
|
|
29
|
+
"Do not write any code or files; just generate the image.")
|
|
30
|
+
jobs.append({"id": f"{a.set}-{d}", "inputs": [f"{H}/{i.format(d=d)}" for i in S['inputs']], "prompt": p, "out": f"{H}/{S['out'].format(d=d)}"})
|
|
31
|
+
with open(f'{H}/jobs-{a.set}.json', 'w') as f:
|
|
32
|
+
json.dump(jobs, f, indent=1)
|
|
33
|
+
print(len(jobs))
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""The day-segment prompts of art/driftwood-isle/round-9-horizon (codex image_gen, one run per heading).
|
|
2
|
+
|
|
3
|
+
Kept for the old command line: the prompts now live in src/shards/driftwood-isle/art/horizon-matte.json (jobs.day2) and this is
|
|
4
|
+
`mkjobs.py --shard driftwood-isle --set day2 <workdir>` (PINE-HOLLOW-REMASTER PH-0.3).
|
|
5
|
+
"""
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
10
|
+
# usage: mkjobs_day2.py <workdir> (holds day-<h>.jpg captures + ref-hero.jpg; writes jobs-day2.json there)
|
|
11
|
+
os.execv(sys.executable, [sys.executable, os.path.join(HERE, 'mkjobs.py'), '--shard', 'driftwood-isle', '--set', 'day2', *sys.argv[1:2]])
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""overlap.py [--shard <slug> | --config <json>] <capture-pattern> <painted-pattern> <heading> <out.jpg> --from <h> [--from <h2>] [--keep 0.35]
|
|
3
|
+
|
|
4
|
+
The chained edit (PINE-HOLLOW-REMASTER PH-L5): independent codex edits of neighbouring headings paint different land in their
|
|
5
|
+
overlap, so the stitch has nothing to agree on (a mountain range cut off by a vertical seam). Instead each segment after the
|
|
6
|
+
first is painted as a CONTINUATION: its reference is the capture at <heading> with the neighbouring painted segment(s)
|
|
7
|
+
reprojected into the side(s) they overlap — only the outer `--keep` fraction of the frame width on that side, so codex
|
|
8
|
+
keeps that strip and paints the rest to continue it. Order for six headings: the hero first, then its two neighbours, then
|
|
9
|
+
theirs, and the last segment closes the ring with both sides given.
|
|
10
|
+
|
|
11
|
+
<capture-pattern> / <painted-pattern>: paths with {d} = the heading. The camera model is the shard config's capture
|
|
12
|
+
(dir = (cos t, 0, sin t), level pitch, vfov, frame size): screen right = increasing t.
|
|
13
|
+
"""
|
|
14
|
+
import argparse
|
|
15
|
+
import numpy as np
|
|
16
|
+
from PIL import Image
|
|
17
|
+
|
|
18
|
+
import config
|
|
19
|
+
|
|
20
|
+
ap = config.add_args(argparse.ArgumentParser(description='a chained-edit reference: the capture + the painted neighbours'))
|
|
21
|
+
ap.add_argument('capture')
|
|
22
|
+
ap.add_argument('painted')
|
|
23
|
+
ap.add_argument('heading', type=float)
|
|
24
|
+
ap.add_argument('out')
|
|
25
|
+
ap.add_argument('--from', dest='src', type=float, action='append', required=True, help='a painted neighbour heading (repeatable)')
|
|
26
|
+
ap.add_argument('--keep', type=float, default=0.35, help='the frame-width fraction given on each neighbour side')
|
|
27
|
+
ap.add_argument('--feather', type=int, default=24, help='px the given strip fades into the capture over')
|
|
28
|
+
ap.add_argument('--onto', default=None, help='paste back: restore the neighbours\' strips onto this finished edit (codex drifts inside the strip it was told to keep), not onto the capture')
|
|
29
|
+
a = ap.parse_args()
|
|
30
|
+
cfg = config.load(a)
|
|
31
|
+
IW, IH, VFOV = cfg['capture']['width'], cfg['capture']['height'], cfg['capture']['vfov']
|
|
32
|
+
TV = np.tan(np.radians(VFOV / 2)); TH = TV * IW / IH
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def load(p):
|
|
36
|
+
return np.asarray(Image.open(p).convert('RGB').resize((IW, IH), Image.LANCZOS), dtype=np.float32) / 255
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def dirs(head):
|
|
40
|
+
"""world directions of every pixel of a frame at heading head (deg)"""
|
|
41
|
+
x = ((np.arange(IW) + 0.5) / IW * 2 - 1) * TH
|
|
42
|
+
y = (1 - (np.arange(IH) + 0.5) / IH * 2) * TV
|
|
43
|
+
X, Y = np.meshgrid(x, y)
|
|
44
|
+
t = np.radians(head)
|
|
45
|
+
f = np.array([np.cos(t), 0, np.sin(t)]); r = np.array([-np.sin(t), 0, np.cos(t)]); u = np.array([0, 1.0, 0])
|
|
46
|
+
d = f[None, None] + X[..., None] * r[None, None] + Y[..., None] * u[None, None]
|
|
47
|
+
return d
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def sample(img, head, d):
|
|
51
|
+
t = np.radians(head)
|
|
52
|
+
f = np.array([np.cos(t), 0, np.sin(t)]); r = np.array([-np.sin(t), 0, np.cos(t)])
|
|
53
|
+
zc = d @ f; xc = d @ r; yc = d[..., 1]
|
|
54
|
+
ok = zc > 0.05
|
|
55
|
+
zs = np.where(ok, zc, 1)
|
|
56
|
+
px = (xc / zs / TH + 1) / 2 * IW - 0.5
|
|
57
|
+
py = (1 - yc / zs / TV) / 2 * IH - 0.5
|
|
58
|
+
ok &= (px >= 0) & (px <= IW - 1) # rows past the neighbour's top / bottom edge clamp to it (sky above, far below the strip's range)
|
|
59
|
+
py = np.clip(py, 0, IH - 1)
|
|
60
|
+
x0 = np.clip(np.floor(px).astype(int), 0, IW - 2); y0 = np.clip(np.floor(py).astype(int), 0, IH - 2)
|
|
61
|
+
fx = np.clip(px - x0, 0, 1)[..., None]; fy = np.clip(py - y0, 0, 1)[..., None]
|
|
62
|
+
v = (img[y0, x0] * (1 - fx) + img[y0, x0 + 1] * fx) * (1 - fy) + (img[y0 + 1, x0] * (1 - fx) + img[y0 + 1, x0 + 1] * fx) * fy
|
|
63
|
+
return v, ok
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
base = load(a.onto if a.onto else a.capture.format(d=int(a.heading)))
|
|
67
|
+
d = dirs(a.heading)
|
|
68
|
+
out = base.copy()
|
|
69
|
+
cols = np.arange(IW)
|
|
70
|
+
for s in a.src:
|
|
71
|
+
rel = (s - a.heading + 180) % 360 - 180
|
|
72
|
+
img = load(a.painted.format(d=int(s)))
|
|
73
|
+
v, ok = sample(img, s, d)
|
|
74
|
+
# the side the neighbour sits on: right for rel > 0 (screen right = increasing t)
|
|
75
|
+
edge = IW * (1 - a.keep) if rel > 0 else IW * a.keep
|
|
76
|
+
w = np.clip((cols - edge) / a.feather + 0.5, 0, 1) if rel > 0 else np.clip((edge - cols) / a.feather + 0.5, 0, 1)
|
|
77
|
+
w = w[None, :] * ok
|
|
78
|
+
out = out * (1 - w[..., None]) + v * w[..., None]
|
|
79
|
+
Image.fromarray((np.clip(out, 0, 1) * 255 + 0.5).astype(np.uint8)).save(a.out, quality=92)
|
|
80
|
+
print('wrote', a.out, 'from', a.src)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""run_codex.py <jobs.json> [--timeout 1500] — one headless codex image_gen run per job, in parallel.
|
|
3
|
+
|
|
4
|
+
Shard-agnostic: the jobs (mkjobs.py --shard <slug>) carry the shard's prompts and paths. Each job: {"id", "inputs":
|
|
5
|
+
[paths], "prompt", "out"}. The runner reads `session id:` from each run's log, polls
|
|
6
|
+
~/.codex/generated_images/<session id>/ for the PNG, copies it to `out` and kills that codex (AGENTS.md).
|
|
7
|
+
"""
|
|
8
|
+
import json, os, re, subprocess, sys, time, shutil, signal
|
|
9
|
+
|
|
10
|
+
HERE = os.getcwd() # logs + -o files land in the working directory (run it from a scratch folder)
|
|
11
|
+
GEN = os.path.expanduser('~/.codex/generated_images')
|
|
12
|
+
|
|
13
|
+
jobs = json.load(open(sys.argv[1]))
|
|
14
|
+
TIMEOUT = float(sys.argv[sys.argv.index('--timeout') + 1]) if '--timeout' in sys.argv else 1500
|
|
15
|
+
procs = {}
|
|
16
|
+
for j in jobs:
|
|
17
|
+
if os.path.exists(j['out']):
|
|
18
|
+
print('skip (exists)', j['id']); continue
|
|
19
|
+
log = os.path.join(HERE, f"{j['id']}.log")
|
|
20
|
+
cmd = ['codex', 'exec', *(['-m', os.environ['CODEX_MODEL']] if os.environ.get('CODEX_MODEL') else []), '-s', 'workspace-write', '--skip-git-repo-check', '-C', HERE, '--add-dir', GEN]
|
|
21
|
+
for i in j['inputs']:
|
|
22
|
+
cmd += ['-i', i]
|
|
23
|
+
cmd += ['-o', os.path.join(HERE, f"{j['id']}.last.txt"), j['prompt']]
|
|
24
|
+
f = open(log, 'w')
|
|
25
|
+
p = subprocess.Popen(cmd, stdout=f, stderr=subprocess.STDOUT, stdin=subprocess.DEVNULL, start_new_session=True)
|
|
26
|
+
procs[j['id']] = (p, log, j)
|
|
27
|
+
print('started', j['id'], p.pid, flush=True)
|
|
28
|
+
|
|
29
|
+
t0 = time.time()
|
|
30
|
+
pending = dict(procs)
|
|
31
|
+
while pending and time.time() - t0 < TIMEOUT:
|
|
32
|
+
time.sleep(10)
|
|
33
|
+
for jid, (p, log, j) in list(pending.items()):
|
|
34
|
+
txt = open(log, errors='ignore').read()
|
|
35
|
+
m = re.search(r'session id:\s*([0-9a-f-]+)', txt)
|
|
36
|
+
if m:
|
|
37
|
+
d = os.path.join(GEN, m.group(1))
|
|
38
|
+
if os.path.isdir(d):
|
|
39
|
+
pngs = sorted([x for x in os.listdir(d) if x.endswith('.png')])
|
|
40
|
+
if pngs:
|
|
41
|
+
src = os.path.join(d, pngs[0])
|
|
42
|
+
# wait until the file size is stable
|
|
43
|
+
s1 = os.path.getsize(src); time.sleep(2)
|
|
44
|
+
if os.path.getsize(src) == s1 and s1 > 0:
|
|
45
|
+
shutil.copy(src, j['out'])
|
|
46
|
+
print(f'done {jid} {time.time()-t0:.0f}s -> {j["out"]}', flush=True)
|
|
47
|
+
try: os.killpg(p.pid, signal.SIGTERM)
|
|
48
|
+
except (ProcessLookupError, PermissionError): pass
|
|
49
|
+
del pending[jid]
|
|
50
|
+
continue
|
|
51
|
+
if p.poll() is not None and jid in pending:
|
|
52
|
+
print(f'EXITED without image: {jid} rc={p.returncode} (see {log})', flush=True)
|
|
53
|
+
del pending[jid]
|
|
54
|
+
for jid, (p, log, j) in pending.items():
|
|
55
|
+
print('TIMEOUT', jid, flush=True)
|
|
56
|
+
try: os.killpg(p.pid, signal.SIGTERM)
|
|
57
|
+
except (ProcessLookupError, PermissionError): pass
|