@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,95 @@
|
|
|
1
|
+
"""E304: a face close-up of one or more models (glb), for tuning a face remaster and the inventory sheet.
|
|
2
|
+
|
|
3
|
+
blender -b -P scripts/img2mesh/face_views.py -- <a.glb>[,<b.glb>…] <out.png> [--top 0.2] [--size 384] [--yaws 0,35]
|
|
4
|
+
[--flat] [--full]
|
|
5
|
+
|
|
6
|
+
Per model: an ortho view of the top --top of its height (the head), one tile per yaw (0 = its front, glTF +Z), and with
|
|
7
|
+
--full a whole-body tile first. Eevee, a sun from the front-left + a soft sky, grey backdrop; the textures as shipped.
|
|
8
|
+
--flat: flat shading (the toon shards' faceted look). Tiles left to right, models top to bottom.
|
|
9
|
+
"""
|
|
10
|
+
import math
|
|
11
|
+
import sys
|
|
12
|
+
|
|
13
|
+
import bpy
|
|
14
|
+
from mathutils import Vector
|
|
15
|
+
|
|
16
|
+
argv = sys.argv[sys.argv.index("--") + 1:]
|
|
17
|
+
srcs, out = argv[0].split(","), argv[1]
|
|
18
|
+
opt = lambda k, d: argv[argv.index(k) + 1] if k in argv else d
|
|
19
|
+
top = float(opt("--top", "0.2"))
|
|
20
|
+
size = int(opt("--size", "384"))
|
|
21
|
+
yaws = [float(y) for y in opt("--yaws", "0,35").split(",")]
|
|
22
|
+
flat = "--flat" in argv
|
|
23
|
+
full = "--full" in argv
|
|
24
|
+
|
|
25
|
+
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
26
|
+
sc = bpy.context.scene
|
|
27
|
+
sc.render.engine = "BLENDER_EEVEE"
|
|
28
|
+
sc.render.resolution_x = sc.render.resolution_y = size
|
|
29
|
+
sc.render.film_transparent = False
|
|
30
|
+
sc.view_settings.view_transform = "Standard"
|
|
31
|
+
world = bpy.data.worlds.new("w"); sc.world = world; world.use_nodes = True
|
|
32
|
+
world.node_tree.nodes["Background"].inputs[0].default_value = (0.55, 0.58, 0.62, 1)
|
|
33
|
+
world.node_tree.nodes["Background"].inputs[1].default_value = 0.9
|
|
34
|
+
sun = bpy.data.objects.new("sun", bpy.data.lights.new("sun", "SUN")); sun.data.energy = 3.2
|
|
35
|
+
sun.rotation_euler = (math.radians(50), 0, math.radians(-30)); sc.collection.objects.link(sun)
|
|
36
|
+
cam = bpy.data.objects.new("cam", bpy.data.cameras.new("cam")); cam.data.type = "ORTHO"; sc.collection.objects.link(cam); sc.camera = cam
|
|
37
|
+
|
|
38
|
+
tiles = []
|
|
39
|
+
for si, src in enumerate(srcs):
|
|
40
|
+
before = set(bpy.context.scene.objects)
|
|
41
|
+
bpy.ops.import_scene.gltf(filepath=src)
|
|
42
|
+
new = [o for o in bpy.context.scene.objects if o not in before]
|
|
43
|
+
meshes = [o for o in new if o.type == "MESH"]
|
|
44
|
+
bpy.context.view_layer.update()
|
|
45
|
+
pts = [o.matrix_world @ Vector(c) for o in meshes for c in o.bound_box]
|
|
46
|
+
lo = Vector((min(p.x for p in pts), min(p.y for p in pts), min(p.z for p in pts)))
|
|
47
|
+
hi = Vector((max(p.x for p in pts), max(p.y for p in pts), max(p.z for p in pts)))
|
|
48
|
+
H = hi.z - lo.z
|
|
49
|
+
for o in meshes:
|
|
50
|
+
if flat:
|
|
51
|
+
for p in o.data.polygons:
|
|
52
|
+
p.use_smooth = False
|
|
53
|
+
for ms in o.material_slots:
|
|
54
|
+
if ms.material:
|
|
55
|
+
ms.material.use_backface_culling = False
|
|
56
|
+
views = ([("full", 0.0)] if full else []) + [("head", y) for y in yaws]
|
|
57
|
+
row = []
|
|
58
|
+
for kind, yaw in views:
|
|
59
|
+
if kind == "full":
|
|
60
|
+
cz = lo.z + H / 2; scale = H * 1.08
|
|
61
|
+
else:
|
|
62
|
+
cz = hi.z - top * H / 2; scale = top * H * 1.05
|
|
63
|
+
cx, cy = (lo.x + hi.x) / 2, (lo.y + hi.y) / 2
|
|
64
|
+
r = 10.0
|
|
65
|
+
a = math.radians(yaw)
|
|
66
|
+
cam.data.ortho_scale = scale
|
|
67
|
+
# glTF +Z (the front) is Blender -Y
|
|
68
|
+
cam.location = (cx + r * math.sin(a), cy - r * math.cos(a), cz)
|
|
69
|
+
cam.rotation_euler = (math.pi / 2, 0, a)
|
|
70
|
+
for o in bpy.context.scene.objects:
|
|
71
|
+
if o.type == "MESH":
|
|
72
|
+
o.hide_render = o not in meshes
|
|
73
|
+
path = f"{out}.tile{si}_{len(row)}.png"
|
|
74
|
+
sc.render.filepath = path
|
|
75
|
+
bpy.ops.render.render(write_still=True)
|
|
76
|
+
row.append(path)
|
|
77
|
+
tiles.append(row)
|
|
78
|
+
for o in new:
|
|
79
|
+
o.hide_render = True
|
|
80
|
+
|
|
81
|
+
# compose
|
|
82
|
+
import numpy as np
|
|
83
|
+
cols = max(len(r) for r in tiles)
|
|
84
|
+
canvas = np.ones((len(tiles) * size, cols * size, 4), np.float32)
|
|
85
|
+
for ri, row in enumerate(tiles):
|
|
86
|
+
for ci, p in enumerate(row):
|
|
87
|
+
im = bpy.data.images.load(p)
|
|
88
|
+
px = np.array(im.pixels[:], np.float32).reshape(size, size, 4)[::-1]
|
|
89
|
+
canvas[ri * size:(ri + 1) * size, ci * size:(ci + 1) * size] = px
|
|
90
|
+
bpy.data.images.remove(im)
|
|
91
|
+
import os; os.remove(p)
|
|
92
|
+
img = bpy.data.images.new("sheet", cols * size, len(tiles) * size, alpha=True)
|
|
93
|
+
img.pixels.foreach_set(canvas[::-1].ravel())
|
|
94
|
+
img.filepath_raw = out; img.file_format = "PNG"; img.save()
|
|
95
|
+
print(f"[views] {out}: {len(tiles)} x {cols}")
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"about": "E304: the face remaster's knobs per model outside Nalati's camp (faces.json is theirs), driven by scripts/img2mesh/e304_faces.sh. body = the shipped file (decoded; a rigged one is stripped first), out = where the variant's files go (<dir>/faces-<variant>/<name>[.phone].glb), neck = its neck / height, the rest as face_remaster.py's flags (bust: the Hunyuan3D-2 bust from ~/ml/img2mesh/out/e304-faces/hy/<bust>.glb, its cutout projected). E339 graft fix (v2, the default): the bust is cut at its own measured neck, scaled by neck-to-top (fit box: the geometric mean with the old head's width), its neck ring blended onto the body's, fragments dropped; the old beard / collar knobs are gone.",
|
|
3
|
+
"models": {
|
|
4
|
+
"ranger": { "body": "public/assets/pine-hollow/npcs/ranger.glb", "phone": "public/assets/pine-hollow/npcs/ranger.phone.glb", "dir": "public/assets/pine-hollow/npcs", "pbr": true, "bust": "ranger-c", "neck": 0.85, "graft": { "neck": 0.6, "ptop": 0.53, "fit": "box", "beard": [0.06, 0.12]}},
|
|
5
|
+
"trader": { "body": "public/assets/pine-hollow/npcs/trader.glb", "phone": "public/assets/pine-hollow/npcs/trader.phone.glb", "dir": "public/assets/pine-hollow/npcs", "pbr": true, "bust": "trader-c", "neck": 0.85, "graft": { "neck": 0.62, "fit": "box", "beard": [0.05, 0.07]}},
|
|
6
|
+
"captain": { "body": "public/assets/models/driftwood-hero/captain/captain.glb", "phone": "public/assets/models/driftwood-hero/captain/captain.glb", "dir": "public/assets/models/driftwood-hero/captain", "bust": "captain", "neck": 0.82, "graft": { "neck": 0.66, "clip": 0.0, "collar": [0.03, 0.06], "beard": [0.07, 0.085]}},
|
|
7
|
+
"miller": { "body": "public/assets/pine-hollow/npcs/miller.glb", "phone": "public/assets/pine-hollow/npcs/miller.phone.glb", "dir": "public/assets/pine-hollow/npcs", "pbr": true, "bust": "miller-c", "neck": 0.86, "graft": { "neck": 0.6, "ptop": 0.58, "fit": "box" }}
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"about": "NALATI-FINISH B5 / E302: per camp person, the face remaster's knobs (scripts/img2mesh/face_remaster.py via build_faces.sh). neck = the procedural figure's neck / height (campPeople.ts). paint = the painted face in the --front render's pixels (768² ortho of the head). graft = the generated bust: neck (its neck, fraction of its height from the top), clip (how far under the cut it reaches, fraction of the figure's height), grow / dz / dy nudges. E339: the busts are cut at their own measured neck (neck_auto false: the cook's headscarf hides hers, graft.neck kept).",
|
|
3
|
+
"people": {
|
|
4
|
+
"elder": {
|
|
5
|
+
"neck": 0.769,
|
|
6
|
+
"paint": { "eyes": [295, 408, 470], "brow_y": 445, "nose_y": 525, "keep_y": 560, "face_y": 505, "top_y": 452, "face": [1.15, 0.8], "mouth": false, "brow": [0.92, 0.9, 0.86], "brow_t": 0.09 },
|
|
7
|
+
"graft": { "neck": 0.5, "clip": 0.015, "beard": [0.055, 0.2] }
|
|
8
|
+
},
|
|
9
|
+
"herder-dauren": {
|
|
10
|
+
"neck": 0.8,
|
|
11
|
+
"paint": { "eyes": [327, 447, 398], "brow_y": 376, "nose_y": 466, "mouth_y": 508, "face_y": 462, "top_y": 362, "face": [1.05, 0.95], "moustache": true, "moustache_w": 0.52 },
|
|
12
|
+
"graft": { "neck": 0.7, "clip": 0.012 }
|
|
13
|
+
},
|
|
14
|
+
"herder-erlan": {
|
|
15
|
+
"neck": 0.8,
|
|
16
|
+
"paint": { "eyes": [318, 460, 445], "brow_y": 418, "nose_y": 518, "mouth_y": 552, "face_y": 490, "top_y": 400, "face": [1.0, 0.8] },
|
|
17
|
+
"graft": { "neck": 0.67, "clip": 0.012 }
|
|
18
|
+
},
|
|
19
|
+
"child": {
|
|
20
|
+
"neck": 0.765,
|
|
21
|
+
"paint": { "eyes": [286, 488, 459], "brow_y": 410, "nose_y": 525, "mouth_y": 562, "face_y": 505, "top_y": 400, "face": [0.85, 0.7], "eye_r": [0.2, 0.13], "smooth": 0.5, "brow_t": 0.05 },
|
|
22
|
+
"graft": { "neck": 0.68, "clip": 0.012 }
|
|
23
|
+
},
|
|
24
|
+
"cook": {
|
|
25
|
+
"neck": 0.829,
|
|
26
|
+
"paint": { "eyes": [310, 425, 337], "brow_y": 308, "nose_y": 398, "mouth_y": 442, "face_y": 390, "top_y": 285, "face": [1.1, 1.05] },
|
|
27
|
+
"graft": { "neck": 0.53, "clip": 0.05, "neck_auto": false }
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"""E343: a generated head-and-shoulders bust → the head alone, for a code-built figure whose head is its own mesh (Driftwood's
|
|
2
|
+
Wendell and Drowned Sailor, Nine Dragon's brushed figures): the same neck rule as face_remaster.py --graft-v2 — the cut at
|
|
3
|
+
the bust's own neck (the narrowest section of its back half between chin and shoulders), dipping --tilt degrees under the
|
|
4
|
+
jaw in front, straight (bisect), floating crumbs dropped — then exported with its paint for scripts/img2mesh/driftwood_post.py
|
|
5
|
+
(the faceted, per-facet-colour toon post).
|
|
6
|
+
|
|
7
|
+
blender -b -P scripts/img2mesh/head_cut.py -- --in bust.glb --out head.glb [--neck-range 0.45 0.8] [--tilt 30]
|
|
8
|
+
Output: <out> (the head, metres as generated, +Y up in glTF, its neck ring on y = its lowest point).
|
|
9
|
+
"""
|
|
10
|
+
import argparse, math, sys
|
|
11
|
+
import bpy, bmesh
|
|
12
|
+
import numpy as np
|
|
13
|
+
|
|
14
|
+
argv = sys.argv[sys.argv.index("--") + 1:]
|
|
15
|
+
ap = argparse.ArgumentParser()
|
|
16
|
+
ap.add_argument("--in", dest="inp", required=True)
|
|
17
|
+
ap.add_argument("--out", required=True)
|
|
18
|
+
ap.add_argument("--neck-range", type=float, nargs=2, default=[0.45, 0.8])
|
|
19
|
+
ap.add_argument("--neck", type=float, default=None, help="the neck as a fraction of the bust's height from the top (no search)")
|
|
20
|
+
ap.add_argument("--tilt", type=float, default=30.0)
|
|
21
|
+
a = ap.parse_args(argv)
|
|
22
|
+
|
|
23
|
+
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
24
|
+
bpy.ops.import_scene.gltf(filepath=a.inp)
|
|
25
|
+
meshes = [o for o in bpy.context.scene.objects if o.type == "MESH"]
|
|
26
|
+
for o in bpy.context.scene.objects:
|
|
27
|
+
o.select_set(o in meshes)
|
|
28
|
+
bpy.context.view_layer.objects.active = meshes[0]
|
|
29
|
+
if len(meshes) > 1:
|
|
30
|
+
bpy.ops.object.join()
|
|
31
|
+
ob = bpy.context.view_layer.objects.active
|
|
32
|
+
ob.data.transform(ob.matrix_world); ob.parent = None; ob.matrix_world.identity()
|
|
33
|
+
for ms in ob.material_slots:
|
|
34
|
+
m = ms.material
|
|
35
|
+
if m and m.node_tree:
|
|
36
|
+
for n in m.node_tree.nodes:
|
|
37
|
+
if n.type == "BSDF_PRINCIPLED":
|
|
38
|
+
for l in list(n.inputs["Metallic"].links):
|
|
39
|
+
m.node_tree.links.remove(l)
|
|
40
|
+
n.inputs["Metallic"].default_value = 0.0
|
|
41
|
+
bm = bmesh.new(); bm.from_mesh(ob.data)
|
|
42
|
+
bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=1e-5 * max(ob.dimensions))
|
|
43
|
+
bm.to_mesh(ob.data); bm.free()
|
|
44
|
+
|
|
45
|
+
co = np.empty(len(ob.data.vertices) * 3); ob.data.vertices.foreach_get("co", co); B = co.reshape(-1, 3)
|
|
46
|
+
bt, bb = B[:, 2].max(), B[:, 2].min(); h = bt - bb
|
|
47
|
+
tp = B[B[:, 2] > bt - 0.3 * h]; cx, cy = tp[:, 0].mean(), tp[:, 1].mean()
|
|
48
|
+
if a.neck is None:
|
|
49
|
+
best, bf = 1e9, 0.6
|
|
50
|
+
for f in np.arange(a.neck_range[0], a.neck_range[1] + 1e-6, 0.0125):
|
|
51
|
+
z = bt - f * h
|
|
52
|
+
band = B[np.abs(B[:, 2] - z) < 0.006 * h]
|
|
53
|
+
back = band[band[:, 1] > cy - 0.02 * h]
|
|
54
|
+
if len(back) < 8:
|
|
55
|
+
continue
|
|
56
|
+
w = np.percentile(np.abs(back[:, 0] - cx), 95)
|
|
57
|
+
if w < best:
|
|
58
|
+
best, bf = w, f
|
|
59
|
+
else:
|
|
60
|
+
bf = a.neck
|
|
61
|
+
zc = bt - bf * h
|
|
62
|
+
print(f"[head] neck at {bf:.3f} of the bust's height from the top")
|
|
63
|
+
tk = math.tan(math.radians(a.tilt))
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def shear(sign):
|
|
67
|
+
c = np.empty(len(ob.data.vertices) * 3); ob.data.vertices.foreach_get("co", c); c = c.reshape(-1, 3)
|
|
68
|
+
c[:, 2] += sign * np.maximum(0.0, cy - c[:, 1]) * tk # the front (−Y in Blender) dips under the jaw
|
|
69
|
+
ob.data.vertices.foreach_set("co", c.ravel()); ob.data.update()
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
shear(1)
|
|
73
|
+
bm = bmesh.new(); bm.from_mesh(ob.data)
|
|
74
|
+
bmesh.ops.bisect_plane(bm, geom=bm.verts[:] + bm.edges[:] + bm.faces[:], dist=1e-6, plane_co=(0, 0, zc), plane_no=(0, 0, 1), clear_inner=True)
|
|
75
|
+
bm.to_mesh(ob.data); bm.free()
|
|
76
|
+
shear(-1)
|
|
77
|
+
# floating crumbs (< 2 % of the largest piece)
|
|
78
|
+
bm = bmesh.new(); bm.from_mesh(ob.data)
|
|
79
|
+
seen, isl = set(), []
|
|
80
|
+
for f in bm.faces:
|
|
81
|
+
if f in seen:
|
|
82
|
+
continue
|
|
83
|
+
st, cur = [f], []
|
|
84
|
+
seen.add(f)
|
|
85
|
+
while st:
|
|
86
|
+
g = st.pop(); cur.append(g)
|
|
87
|
+
for e in g.edges:
|
|
88
|
+
for k in e.link_faces:
|
|
89
|
+
if k not in seen:
|
|
90
|
+
seen.add(k); st.append(k)
|
|
91
|
+
isl.append((sum(x.calc_area() for x in cur), cur))
|
|
92
|
+
big = max(i[0] for i in isl)
|
|
93
|
+
bmesh.ops.delete(bm, geom=[f for ar, c in isl if ar < 0.02 * big for f in c], context="FACES")
|
|
94
|
+
bmesh.ops.delete(bm, geom=[v for v in bm.verts if not v.link_faces], context="VERTS")
|
|
95
|
+
bm.to_mesh(ob.data); bm.free()
|
|
96
|
+
c2 = np.empty(len(ob.data.vertices) * 3); ob.data.vertices.foreach_get("co", c2); c2 = c2.reshape(-1, 3)
|
|
97
|
+
top, bot = c2[:, 2].max(), c2[:, 2].min()
|
|
98
|
+
print(f"[head] neckFromTop {(top - zc) / max(top - bot, 1e-9):.4f} (the neck's height below the top, fraction of the head's height)")
|
|
99
|
+
bpy.ops.export_scene.gltf(filepath=a.out, export_format="GLB", use_selection=False, export_yup=True, export_apply=True)
|
|
100
|
+
print(f"[head] {a.out}: {len(ob.data.polygons)} faces")
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""hi3d_paint.py — Hunyuan3D-2 paint on Hi3D-refined meshes: a texture made for the new shape (HI3D-REFINE arm C, E494).
|
|
2
|
+
|
|
3
|
+
~/projects/localai/bin/img2mesh/run-locked.sh <log> ~/ml/img2mesh/Hunyuan3D-2/.venv/bin/python -I \
|
|
4
|
+
scripts/img2mesh/hi3d_paint.py [--faces 40000] [--tex 1024] <out dir> <refined.obj> <ref image> […]
|
|
5
|
+
|
|
6
|
+
Why: the refined geometry carves the reference's detail, which never lines up with the generator's own painted
|
|
7
|
+
texture (stone-a: Hi3D carved the reference's branches under TRELLIS's painted circles). Here each refined mesh
|
|
8
|
+
(hi3d_refine.py, in its generation's GLB frame, facing +Z like Hunyuan's own output) is reduced to --faces with
|
|
9
|
+
Hunyuan's FaceReducer, painted by hunyuan3d-paint-v2-0-turbo from the reference (cut out on white), and written as
|
|
10
|
+
<out>/<stem>.glb with <stem>.json. <stem> drops the .hi3d<res> suffix, so build_props.py can take <out> as GEN and the
|
|
11
|
+
refined dir as REFINE: colour from this paint, geometry and normal map from the 1 M-face mesh.
|
|
12
|
+
Uses localai's Hunyuan3D-2 install (hy3d-mac-setup.sh) and the same MPS float64 guard as its hy3d_batch.py.
|
|
13
|
+
"""
|
|
14
|
+
import argparse
|
|
15
|
+
import json
|
|
16
|
+
import os
|
|
17
|
+
import sys
|
|
18
|
+
import time
|
|
19
|
+
|
|
20
|
+
os.environ.setdefault("PYTORCH_ENABLE_MPS_FALLBACK", "1")
|
|
21
|
+
os.environ.setdefault("HY3DGEN_MODELS", os.path.expanduser("~/projects/weights/manual"))
|
|
22
|
+
sys.path.insert(0, os.path.expanduser(os.environ.get("HY3D_REPO", "~/ml/img2mesh/Hunyuan3D-2")))
|
|
23
|
+
|
|
24
|
+
import numpy as np # noqa: E402
|
|
25
|
+
import torch # noqa: E402
|
|
26
|
+
import trimesh # noqa: E402
|
|
27
|
+
from PIL import Image # noqa: E402
|
|
28
|
+
|
|
29
|
+
_orig_to = torch.Tensor.to
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _to_mps_safe(self, *args, **kw):
|
|
33
|
+
"""MPS has no float64: hy3dgen's texgen moves numpy float64 tensors to the device."""
|
|
34
|
+
tgt = kw.get("device", args[0] if args else None)
|
|
35
|
+
if self.dtype == torch.float64 and ((isinstance(tgt, str) and tgt.startswith("mps"))
|
|
36
|
+
or (isinstance(tgt, torch.device) and tgt.type == "mps")):
|
|
37
|
+
self = self.float()
|
|
38
|
+
return _orig_to(self, *args, **kw)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
torch.Tensor.to = _to_mps_safe
|
|
42
|
+
|
|
43
|
+
from hy3dgen.shapegen import FaceReducer # noqa: E402
|
|
44
|
+
from hy3dgen.texgen import Hunyuan3DPaintPipeline # noqa: E402
|
|
45
|
+
from hy3dgen.texgen.pipelines import Hunyuan3DTexGenConfig # noqa: E402
|
|
46
|
+
|
|
47
|
+
ap = argparse.ArgumentParser()
|
|
48
|
+
ap.add_argument("--faces", type=int, default=40000)
|
|
49
|
+
ap.add_argument("--tex", type=int, default=1024)
|
|
50
|
+
ap.add_argument("--render", type=int, default=1024)
|
|
51
|
+
ap.add_argument("out")
|
|
52
|
+
ap.add_argument("pairs", nargs="+", help="<refined.obj> <ref image> …")
|
|
53
|
+
a = ap.parse_args()
|
|
54
|
+
if len(a.pairs) % 2:
|
|
55
|
+
ap.error("pairs come as <refined.obj> <ref image>")
|
|
56
|
+
os.makedirs(a.out, exist_ok=True)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def cutout(path):
|
|
60
|
+
"""The reference with alpha: its own, else everything that is not near-white (as hi3d_refine.py)."""
|
|
61
|
+
im = Image.open(path)
|
|
62
|
+
if im.mode == "RGBA" and np.asarray(im)[..., 3].min() < 255:
|
|
63
|
+
return im
|
|
64
|
+
rgb = np.asarray(im.convert("RGB"))
|
|
65
|
+
alpha = ((255 - rgb.astype(np.int16)).max(axis=2) > 18).astype(np.uint8) * 255
|
|
66
|
+
return Image.fromarray(np.dstack([rgb, alpha]))
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
orig_init = Hunyuan3DTexGenConfig.__init__
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def config_init(self, *args, **kw):
|
|
73
|
+
orig_init(self, *args, **kw)
|
|
74
|
+
self.device = "mps"
|
|
75
|
+
self.render_size = a.render
|
|
76
|
+
self.texture_size = a.tex
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
Hunyuan3DTexGenConfig.__init__ = config_init
|
|
80
|
+
t0 = time.time()
|
|
81
|
+
paint = Hunyuan3DPaintPipeline.from_pretrained(os.path.join(os.environ["HY3DGEN_MODELS"], "tencent/Hunyuan3D-2"),
|
|
82
|
+
subfolder="hunyuan3d-paint-v2-0-turbo")
|
|
83
|
+
load_s = round(time.time() - t0, 1)
|
|
84
|
+
for obj, ref in zip(a.pairs[::2], a.pairs[1::2]):
|
|
85
|
+
stem = os.path.basename(obj).split(".hi3d")[0]
|
|
86
|
+
mesh = FaceReducer()(trimesh.load(os.path.expanduser(obj), force="mesh"), max_facenum=a.faces)
|
|
87
|
+
t1 = time.time()
|
|
88
|
+
painted = paint(mesh, image=cutout(os.path.expanduser(ref)))
|
|
89
|
+
painted.export(os.path.join(a.out, stem + ".glb"))
|
|
90
|
+
rec = {"refined": obj, "ref": ref, "faces": int(len(mesh.faces)), "tex": a.tex, "load_s": load_s,
|
|
91
|
+
"paint_s": round(time.time() - t1, 1)}
|
|
92
|
+
json.dump(rec, open(os.path.join(a.out, stem + ".json"), "w"), indent=1)
|
|
93
|
+
print(json.dumps(rec), flush=True)
|
|
94
|
+
torch.mps.empty_cache()
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"""hi3d_refine.py — Hi3D v1.0 refinement of TRELLIS.2 / Hunyuan3D generations (HI3D-REFINE, E494).
|
|
2
|
+
|
|
3
|
+
~/projects/localai/bin/img2mesh/run-locked.sh <log> ~/ml/img2mesh/hi3d-mlx/.venv/bin/python -I \
|
|
4
|
+
scripts/img2mesh/hi3d_refine.py [--res 1024] [--seed 0] <out dir> <gen.glb> <ref image> [<gen.glb> <ref image> …]
|
|
5
|
+
|
|
6
|
+
Runs in the MLX port's venv (cguldogan/mlx-vlm@hi3d, ~/ml/img2mesh/hi3d-mlx). The model loads once per batch. For each
|
|
7
|
+
pair it writes <out>/<stem>.hi3d<res>.obj and <stem>.hi3d<res>.json:
|
|
8
|
+
1. the coarse mesh is the generation's textured GLB itself (Hi3D re-voxelizes at 64³ on its first pass, so the raw
|
|
9
|
+
decoder mesh adds nothing), in the glTF frame (Y-up). The port conditions as if the reference were shot from +Z, but
|
|
10
|
+
each reference has its own camera (stone-a's glyph side is −Z, the bear and the ranger are 3/4 views), so the coarse
|
|
11
|
+
mesh is turned about Y going in and back coming out. --turn auto (the default) picks the turn whose coloured,
|
|
12
|
+
orthographic render best matches the reference (every 15°); a number forces it. A wrong turn carves the
|
|
13
|
+
reference's detail into the wrong side (stone-a, 2026-10-24);
|
|
14
|
+
2. the reference is cut out on its white background (the refs are one object on white) unless it carries alpha;
|
|
15
|
+
3. Hi3D's output (centred, unit radius) is moved back onto the GLB: bounding-box centre and the mean extent ratio, then
|
|
16
|
+
ICP with scale onto the GLB's surface, so driftwood_post.py --geo can bake the generated texture onto it (a loose
|
|
17
|
+
fit smears that texture: stone-a's painted glyphs, 2026-10-24). --reuse re-fits an existing output without Hi3D;
|
|
18
|
+
4. the JSON records the timings, the peak MLX memory and both meshes' health (loose parts, hole edges, non-manifold
|
|
19
|
+
edges) plus how far the refined surface strays from the coarse one (the mean nearest distance / the bbox diagonal).
|
|
20
|
+
"""
|
|
21
|
+
import argparse
|
|
22
|
+
import json
|
|
23
|
+
import os
|
|
24
|
+
import time
|
|
25
|
+
|
|
26
|
+
import mlx.core as mx
|
|
27
|
+
import numpy as np
|
|
28
|
+
import trimesh
|
|
29
|
+
from PIL import Image, ImageDraw
|
|
30
|
+
|
|
31
|
+
from mlx_vlm.models.hi3d import Model
|
|
32
|
+
|
|
33
|
+
MODEL = os.path.expanduser("~/projects/weights/manual/mlx-community/Hi3Dv1.0-mlx")
|
|
34
|
+
|
|
35
|
+
ap = argparse.ArgumentParser()
|
|
36
|
+
ap.add_argument("--res", type=int, default=1024, choices=(512, 1024, 1536))
|
|
37
|
+
ap.add_argument("--seed", type=int, default=0)
|
|
38
|
+
ap.add_argument("--turn", default="auto", help="degrees about Y that bring the reference's view to +Z, or auto")
|
|
39
|
+
ap.add_argument("--model", default=MODEL)
|
|
40
|
+
ap.add_argument("--reuse", action="store_true", help="re-fit <out>/<stem>.hi3d<res>.obj when it exists; no Hi3D run")
|
|
41
|
+
ap.add_argument("--dry", action="store_true", help="print each pair's turn and stop (no Hi3D)")
|
|
42
|
+
ap.add_argument("out")
|
|
43
|
+
ap.add_argument("pairs", nargs="+", help="<gen.glb> <ref image> …")
|
|
44
|
+
a = ap.parse_args()
|
|
45
|
+
if len(a.pairs) % 2:
|
|
46
|
+
ap.error("pairs come as <gen.glb> <ref image>")
|
|
47
|
+
os.makedirs(a.out, exist_ok=True)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def cutout(path):
|
|
51
|
+
"""The reference with alpha: its own, else everything that is not near-white."""
|
|
52
|
+
im = Image.open(path)
|
|
53
|
+
if im.mode == "RGBA" and np.asarray(im)[..., 3].min() < 255:
|
|
54
|
+
return im
|
|
55
|
+
rgb = np.asarray(im.convert("RGB"))
|
|
56
|
+
alpha = ((255 - rgb.astype(np.int16)).max(axis=2) > 18).astype(np.uint8) * 255
|
|
57
|
+
return Image.fromarray(np.dstack([rgb, alpha]))
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
SIDE = 96
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def crop_square(rgb, mask):
|
|
64
|
+
"""The masked subject on white, cropped to its bbox, padded square and resized to SIDE² (float RGB)."""
|
|
65
|
+
ys, xs = np.nonzero(mask)
|
|
66
|
+
rgb = np.where(mask[..., None], rgb, 255)[ys.min():ys.max() + 1, xs.min():xs.max() + 1]
|
|
67
|
+
h, w = rgb.shape[:2]
|
|
68
|
+
s = max(h, w)
|
|
69
|
+
sq = np.full((s, s, 3), 255, np.uint8)
|
|
70
|
+
sq[(s - h) // 2:(s - h) // 2 + h, (s - w) // 2:(s - w) // 2 + w] = rgb
|
|
71
|
+
return np.asarray(Image.fromarray(sq).resize((SIDE, SIDE), Image.BILINEAR), np.float32)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def view(mesh, colours, yaw):
|
|
75
|
+
"""Orthographic render from +Z of the mesh turned by yaw about Y: flat face colours, far faces first."""
|
|
76
|
+
v = mesh.vertices @ trimesh.transformations.rotation_matrix(np.radians(yaw), [0, 1, 0])[:3, :3].T
|
|
77
|
+
lo, span = v[:, :2].min(0), (v[:, :2].max(0) - v[:, :2].min(0)).max()
|
|
78
|
+
px = (v[:, :2] - lo) / span * (4 * SIDE - 1)
|
|
79
|
+
px[:, 1] = 4 * SIDE - 1 - px[:, 1]
|
|
80
|
+
tris = mesh.faces[np.argsort(v[mesh.faces, 2].mean(1))]
|
|
81
|
+
img = Image.new("RGB", (4 * SIDE, 4 * SIDE), (255, 255, 255))
|
|
82
|
+
mask = Image.new("L", img.size, 0)
|
|
83
|
+
draw, dm = ImageDraw.Draw(img), ImageDraw.Draw(mask)
|
|
84
|
+
for f in tris:
|
|
85
|
+
pts = [tuple(p) for p in px[f]]
|
|
86
|
+
draw.polygon(pts, fill=tuple(int(c) for c in colours[f].mean(0)[:3]))
|
|
87
|
+
dm.polygon(pts, fill=255)
|
|
88
|
+
return crop_square(np.asarray(img), np.asarray(mask) > 0)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def auto_turn(mesh, ref_rgba):
|
|
92
|
+
"""The yaw (every 15°) whose render is closest to the reference, with every yaw's score."""
|
|
93
|
+
ref = np.asarray(ref_rgba)
|
|
94
|
+
target = crop_square(ref[..., :3], ref[..., 3] > 127)
|
|
95
|
+
colours = mesh.visual.to_color().vertex_colors
|
|
96
|
+
scores = {yaw: float(np.abs(view(mesh, colours, yaw) - target).mean()) for yaw in range(0, 360, 15)}
|
|
97
|
+
return min(scores, key=scores.get), scores
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def health(m):
|
|
101
|
+
edges = np.sort(m.edges, axis=1)
|
|
102
|
+
_, counts = np.unique(edges, axis=0, return_counts=True)
|
|
103
|
+
return {"faces": int(len(m.faces)), "loose_parts": len(m.split(only_watertight=False)),
|
|
104
|
+
"hole_edges": int((counts == 1).sum()), "nonmanifold_edges": int((counts > 2).sum())}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def drift(fine, coarse, seed):
|
|
108
|
+
"""Mean distance from the coarse surface to the refined one, over the coarse bbox diagonal."""
|
|
109
|
+
_, dist, _ = trimesh.proximity.closest_point(fine, coarse.sample(20000, seed=seed))
|
|
110
|
+
return round(float(dist.mean()) / float(np.linalg.norm(coarse.extents)), 5)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
model, load_s = None, 0.0
|
|
114
|
+
for glb, ref in zip(a.pairs[::2], a.pairs[1::2]):
|
|
115
|
+
stem = os.path.basename(glb).removesuffix(".glb")
|
|
116
|
+
path = os.path.join(a.out, f"{stem}.hi3d{a.res}.obj")
|
|
117
|
+
coarse = trimesh.load(os.path.expanduser(glb), force="mesh")
|
|
118
|
+
coarse.merge_vertices()
|
|
119
|
+
rec = {"source": glb, "ref": ref, "res": a.res, "seed": a.seed, "turn": a.turn}
|
|
120
|
+
if a.reuse and os.path.exists(path):
|
|
121
|
+
fine = trimesh.load(path, force="mesh", process=False)
|
|
122
|
+
rec.update(json.load(open(path.removesuffix(".obj") + ".json")))
|
|
123
|
+
else:
|
|
124
|
+
if model is None:
|
|
125
|
+
t0 = time.perf_counter()
|
|
126
|
+
model = Model.from_pretrained(a.model)
|
|
127
|
+
load_s = time.perf_counter() - t0
|
|
128
|
+
image = cutout(os.path.expanduser(ref))
|
|
129
|
+
if a.turn == "auto":
|
|
130
|
+
yaw, scores = auto_turn(coarse, image.convert("RGBA"))
|
|
131
|
+
rec["turn_scores"] = {k: round(s, 2) for k, s in scores.items()}
|
|
132
|
+
else:
|
|
133
|
+
yaw = float(a.turn)
|
|
134
|
+
rec["turn"] = yaw
|
|
135
|
+
if a.dry:
|
|
136
|
+
print(stem, "turn", yaw, json.dumps(rec.get("turn_scores", {})), flush=True)
|
|
137
|
+
continue
|
|
138
|
+
turn = trimesh.transformations.rotation_matrix(np.radians(yaw), [0, 1, 0])
|
|
139
|
+
facing = coarse.copy()
|
|
140
|
+
facing.apply_transform(turn)
|
|
141
|
+
mx.reset_peak_memory()
|
|
142
|
+
t1 = time.perf_counter()
|
|
143
|
+
res = model(image, np.asarray(facing.vertices, np.float32),
|
|
144
|
+
np.asarray(facing.faces, np.int32), resolution=a.res, seed=a.seed)
|
|
145
|
+
fine = trimesh.Trimesh(np.asarray(res.vertices), np.asarray(res.faces), process=False)
|
|
146
|
+
fine.apply_transform(np.linalg.inv(turn))
|
|
147
|
+
scale = float(np.mean(coarse.extents / fine.extents))
|
|
148
|
+
fine.apply_scale(scale)
|
|
149
|
+
fine.apply_translation(coarse.bounds.mean(0) - fine.bounds.mean(0))
|
|
150
|
+
rec.update({"seconds": round(time.perf_counter() - t1, 1), "load_seconds": round(load_s, 1),
|
|
151
|
+
"timings": {k: round(v, 2) for k, v in res.timings.items()},
|
|
152
|
+
"peak_memory_gb": round(mx.get_peak_memory() / 1e9, 2), "scale_back": round(scale, 5)})
|
|
153
|
+
rec["drift_bbox"] = drift(fine, coarse, a.seed)
|
|
154
|
+
fit, _, _ = trimesh.registration.icp(fine.sample(8000, seed=a.seed), coarse, scale=True, max_iterations=40)
|
|
155
|
+
fine.apply_transform(fit)
|
|
156
|
+
rec["drift"] = drift(fine, coarse, a.seed)
|
|
157
|
+
rec.update({"coarse": health(coarse), "refined": health(fine)})
|
|
158
|
+
fine.export(path)
|
|
159
|
+
with open(path.removesuffix(".obj") + ".json", "w") as fh:
|
|
160
|
+
json.dump(rec, fh, indent=1)
|
|
161
|
+
print(json.dumps(rec), flush=True)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Build Hunyuan3D-2's custom_rasterizer WITHOUT CUDA (Apple Silicon): the kernel already has a CPU rasteriser
|
|
3
|
+
# (rasterize_image_cpu); this drops the .cu file + CUDA header, makes __host__/__device__ no-ops, and routes every
|
|
4
|
+
# call (MPS tensors included) through the CPU path, copying the result back to the caller's device.
|
|
5
|
+
# bash scripts/img2mesh/hunyuan_cpu_rasterizer.sh [~/ml/img2mesh/Hunyuan3D-2]
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
HY=${1:-$HOME/ml/img2mesh/Hunyuan3D-2}
|
|
8
|
+
K=$HY/hy3dgen/texgen/custom_rasterizer
|
|
9
|
+
cd "$K"
|
|
10
|
+
python3 - "$K" <<'EOF'
|
|
11
|
+
import pathlib, sys
|
|
12
|
+
k = pathlib.Path(sys.argv[1])
|
|
13
|
+
h = k / "lib/custom_rasterizer_kernel/rasterizer.h"
|
|
14
|
+
s = h.read_text()
|
|
15
|
+
s = s.replace("#include <ATen/cuda/CUDAContext.h> // For CUDA context",
|
|
16
|
+
"#ifndef __CUDACC__\n#define __host__\n#define __device__\n#endif")
|
|
17
|
+
h.write_text(s)
|
|
18
|
+
c = k / "lib/custom_rasterizer_kernel/rasterizer.cpp"
|
|
19
|
+
s = c.read_text()
|
|
20
|
+
old = """ int device_id = V.get_device();
|
|
21
|
+
if (device_id == -1)
|
|
22
|
+
return rasterize_image_cpu(V, F, D, width, height, occlusion_truncation, use_depth_prior);
|
|
23
|
+
else
|
|
24
|
+
return rasterize_image_gpu(V, F, D, width, height, occlusion_truncation, use_depth_prior);"""
|
|
25
|
+
new = """ auto dev = V.device();
|
|
26
|
+
auto r = rasterize_image_cpu(V.cpu().contiguous(), F.cpu().contiguous(), D.cpu().contiguous(),
|
|
27
|
+
width, height, occlusion_truncation, use_depth_prior);
|
|
28
|
+
return {r[0].to(dev), r[1].to(dev)};"""
|
|
29
|
+
if old in s:
|
|
30
|
+
c.write_text(s.replace(old, new))
|
|
31
|
+
p = k / "setup.py"
|
|
32
|
+
p.write_text("""from setuptools import setup, find_packages
|
|
33
|
+
from torch.utils.cpp_extension import BuildExtension, CppExtension
|
|
34
|
+
setup(packages=find_packages(), version='0.1', name='custom_rasterizer', include_package_data=True,
|
|
35
|
+
package_dir={'': '.'},
|
|
36
|
+
ext_modules=[CppExtension('custom_rasterizer_kernel', [
|
|
37
|
+
'lib/custom_rasterizer_kernel/rasterizer.cpp',
|
|
38
|
+
'lib/custom_rasterizer_kernel/grid_neighbor.cpp'], extra_compile_args=['-O3', '-std=c++20', '-Wno-c++11-narrowing'])],
|
|
39
|
+
cmdclass={'build_ext': BuildExtension})
|
|
40
|
+
""")
|
|
41
|
+
EOF
|
|
42
|
+
MACOSX_DEPLOYMENT_TARGET=12.0 uv pip install --python "$HY/.venv/bin/python" --no-build-isolation .
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# pine_hollow_phone.sh [dir] — after build_props.py: move each <ref>-phone/<ref>-phone.glb (the LOD0 mesh at 512²) to
|
|
3
|
+
# <ref>/<ref>.phone.glb, the phone tier's copy (src/client/engine/boot/bytes.ts tierUrl swaps it in for the phone), and drop the folder.
|
|
4
|
+
set -euo pipefail
|
|
5
|
+
D=${1:-public/assets/models/pine-hollow-hero}
|
|
6
|
+
for p in "$D"/*-phone; do
|
|
7
|
+
[ -d "$p" ] || continue
|
|
8
|
+
ref=$(basename "$p" -phone)
|
|
9
|
+
mkdir -p "$D/$ref"
|
|
10
|
+
mv "$p/$ref-phone.glb" "$D/$ref/$ref.phone.glb"
|
|
11
|
+
rm -rf "$p"
|
|
12
|
+
echo "$ref.phone.glb $(stat -f %z "$D/$ref/$ref.phone.glb") B"
|
|
13
|
+
done
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"about": "Coral Drift's coral arch (open-plots build-out OB5, art/coral-drift/round-2-landmark): Hunyuan3D 2.1 (seed 42) on a BiRefNet cutout of the codex image_gen reference ref-arch.jpg (from the look loop's plaza and under-the-arch targets), picked over TRELLIS.2 and the retired Blender script (coral.py, in git history). Flat shaded (--smooth-angle 0) to keep the plot's faceted look. Near 15k triangles on a 512 WebP atlas, far 2.5k smooth at 256, no normal map; layouts/coral-drift.json stands it 25 m tall, turn 0.",
|
|
3
|
+
"gen": "~/ml/img2mesh/out/coral-arch-hy21",
|
|
4
|
+
"stage": "~/ml/img2mesh/out/coral-arch-hy21-post-15k",
|
|
5
|
+
"args": [
|
|
6
|
+
"--keep-texture",
|
|
7
|
+
"--atlas",
|
|
8
|
+
"512",
|
|
9
|
+
"--normal-map",
|
|
10
|
+
"0",
|
|
11
|
+
"--fit",
|
|
12
|
+
"height",
|
|
13
|
+
"--size",
|
|
14
|
+
"25",
|
|
15
|
+
"--simplifier",
|
|
16
|
+
"blender",
|
|
17
|
+
"--up",
|
|
18
|
+
"x180",
|
|
19
|
+
"--smooth-angle",
|
|
20
|
+
"0"
|
|
21
|
+
],
|
|
22
|
+
"props": [
|
|
23
|
+
{
|
|
24
|
+
"ref": "model",
|
|
25
|
+
"args": "--name landmark --tris 15000"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"ref": "model",
|
|
29
|
+
"args": "--name landmark-far --tris 2500 --atlas 256 --smooth-angle 40"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"about": "Ember Forge's furnace hall (open-plots build-out OB4, art/ember-forge/round-3-landmark): Hunyuan3D 2.1 (seed 42) on a BiRefNet cutout of the codex image_gen reference ref-furnace.jpg (from round 62's road-entry crop), picked over TRELLIS.2 and the retired Blender script (furnace.py, in git history). Near 20k triangles on a 512 WebP atlas (1024 cost the phone 1.28 MB), far 2.5k at 256, no normal map; layouts/ember-forge.json stands it 35 m tall, turn 2.",
|
|
3
|
+
"gen": "~/ml/img2mesh/out/ember-furnace-hy21",
|
|
4
|
+
"stage": "~/ml/img2mesh/out/ember-furnace-hy21-post-512",
|
|
5
|
+
"args": [
|
|
6
|
+
"--keep-texture",
|
|
7
|
+
"--atlas",
|
|
8
|
+
"512",
|
|
9
|
+
"--normal-map",
|
|
10
|
+
"0",
|
|
11
|
+
"--fit",
|
|
12
|
+
"height",
|
|
13
|
+
"--size",
|
|
14
|
+
"35",
|
|
15
|
+
"--simplifier",
|
|
16
|
+
"blender",
|
|
17
|
+
"--up",
|
|
18
|
+
"x180"
|
|
19
|
+
],
|
|
20
|
+
"props": [
|
|
21
|
+
{
|
|
22
|
+
"ref": "model",
|
|
23
|
+
"args": "--name landmark --tris 20000"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"ref": "model",
|
|
27
|
+
"args": "--name landmark-far --tris 2500 --atlas 256"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"about": "Night Market's gate (night-market-remaster RM9, art/grid/round-68-night-market-gate): Hunyuan3D 2.1 from ref-gate.jpg (r7's three-bay gate), picked over TRELLIS.2 at the shipped budget (TRELLIS's gold trim and plinths went dark in the 15k re-bake). The take comes out upside down (--up x180). Near 18k triangles (OB10: the build-out bar is 15-25k near; was 12k under the plaza tiles' then pinned resident rows) and far 2.5k, both on one 1024 WebP atlas and no normal map; layouts/night-market.json scales it to its height.",
|
|
3
|
+
"gen": "~/ml/img2mesh/out/nm-gate-hy21",
|
|
4
|
+
"stage": "~/ml/img2mesh/out/nm-gate-hy21-post",
|
|
5
|
+
"args": ["--keep-texture", "--atlas", "1024", "--normal-map", "0", "--fit", "height", "--size", "14", "--simplifier", "blender", "--up", "x180"],
|
|
6
|
+
"props": [
|
|
7
|
+
{"ref": "model", "args": "--name landmark --tris 18000"},
|
|
8
|
+
{"ref": "model", "args": "--name landmark-far --tris 2500"}
|
|
9
|
+
]
|
|
10
|
+
}
|