@wildshard/sdk 0.0.0 → 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 +14 -4
- 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 +371 -4
- 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,568 @@
|
|
|
1
|
+
"""E289 finishing passes for the training dummies, used by rig_dummy.py (Blender's Python, numpy only).
|
|
2
|
+
|
|
3
|
+
- squeeze_atlas: the baked atlas is full; move its content up by STRIP of the height and free a strip at the bottom
|
|
4
|
+
for the parts built here (the cross-foot base's wood and iron).
|
|
5
|
+
- replace_base: TRELLIS's cross-foot bases came back blocky and speckled; cut the base, the post and the braces off
|
|
6
|
+
the figure and build the approved one instead (a square post, two crossed feet, four braces, iron end caps), its
|
|
7
|
+
wood and iron painted into the free strip.
|
|
8
|
+
- smooth_regions: pull in the flaky remesh fuzz (the straw neck and fists).
|
|
9
|
+
- flatten_face: smooth the dent at the centre of the painted face target.
|
|
10
|
+
- weather_steel: darken and rust the steel towards the approved dark iron, in the texture.
|
|
11
|
+
"""
|
|
12
|
+
import math
|
|
13
|
+
|
|
14
|
+
import bmesh
|
|
15
|
+
import numpy as np
|
|
16
|
+
from mathutils import Matrix, Vector
|
|
17
|
+
|
|
18
|
+
STRIP = 0.125 # the bottom eighth of the atlas
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def images(me):
|
|
22
|
+
nodes = me.materials[0].node_tree.nodes
|
|
23
|
+
base = next(n.image for n in nodes if n.type == "TEX_IMAGE" and any(
|
|
24
|
+
l.to_socket.name == "Base Color" for l in n.outputs["Color"].links))
|
|
25
|
+
mr = next((n.image for n in nodes if n.type == "TEX_IMAGE" and n.image is not base), None)
|
|
26
|
+
return base, mr
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def read_px(img):
|
|
30
|
+
w, h = img.size
|
|
31
|
+
px = np.empty(w * h * 4, np.float32)
|
|
32
|
+
img.pixels.foreach_get(px)
|
|
33
|
+
return px.reshape(h, w, 4)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def write_px(img, px):
|
|
37
|
+
img.pixels.foreach_set(px.ravel())
|
|
38
|
+
img.pack()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def squeeze_atlas(me):
|
|
42
|
+
"""Rows [0, STRIP) of both maps become free; every UV moves to v' = STRIP + v (1 - STRIP)."""
|
|
43
|
+
for img in images(me):
|
|
44
|
+
if img is None:
|
|
45
|
+
continue
|
|
46
|
+
px = read_px(img)
|
|
47
|
+
h = px.shape[0]
|
|
48
|
+
top = h - int(round(h * STRIP))
|
|
49
|
+
src = (np.arange(top) + 0.5) * h / top - 0.5
|
|
50
|
+
i0 = np.clip(np.floor(src).astype(int), 0, h - 1)
|
|
51
|
+
i1 = np.clip(i0 + 1, 0, h - 1)
|
|
52
|
+
t = (src - i0)[:, None, None]
|
|
53
|
+
out = px.copy()
|
|
54
|
+
out[h - top:] = px[i0] * (1 - t) + px[i1] * t
|
|
55
|
+
out[:h - top] = 0.0
|
|
56
|
+
out[:h - top, :, 3] = 1.0
|
|
57
|
+
write_px(img, out)
|
|
58
|
+
for d in me.uv_layers.active.data:
|
|
59
|
+
d.uv.y = STRIP + d.uv.y * (1 - STRIP)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def value_noise(shape, cells, rng):
|
|
63
|
+
"""Smooth 2D value noise in [0, 1], `cells` lattice cells across each axis."""
|
|
64
|
+
g = rng.random((cells[0] + 2, cells[1] + 2))
|
|
65
|
+
ys = np.linspace(0, cells[0], shape[0], endpoint=False)
|
|
66
|
+
xs = np.linspace(0, cells[1], shape[1], endpoint=False)
|
|
67
|
+
y0, x0 = ys.astype(int), xs.astype(int)
|
|
68
|
+
ty, tx = (ys - y0)[:, None], (xs - x0)[None, :]
|
|
69
|
+
ty, tx = ty * ty * (3 - 2 * ty), tx * tx * (3 - 2 * tx)
|
|
70
|
+
a = g[y0][:, x0]
|
|
71
|
+
b = g[y0][:, x0 + 1]
|
|
72
|
+
c = g[y0 + 1][:, x0]
|
|
73
|
+
d = g[y0 + 1][:, x0 + 1]
|
|
74
|
+
return (a * (1 - tx) + b * tx) * (1 - ty) + (c * (1 - tx) + d * tx) * ty
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def noise3(p, freq, seed):
|
|
78
|
+
"""Cheap smooth 3D noise in [0, 1] at points p (N, 3): a sum of offset sine products."""
|
|
79
|
+
rng = np.random.default_rng(seed)
|
|
80
|
+
acc = np.zeros(len(p))
|
|
81
|
+
amp_total = 0.0
|
|
82
|
+
for octave in range(3):
|
|
83
|
+
f = freq * (2 ** octave)
|
|
84
|
+
amp = 0.5 ** octave
|
|
85
|
+
for _ in range(3):
|
|
86
|
+
k = rng.normal(size=3)
|
|
87
|
+
k /= np.linalg.norm(k)
|
|
88
|
+
ph = rng.random() * 6.283
|
|
89
|
+
acc += amp * np.sin(p @ k * f * 6.283 + ph)
|
|
90
|
+
amp_total += amp
|
|
91
|
+
return 0.5 + 0.5 * acc / amp_total * 1.7
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# ---------------------------------------------------------------------------------------------- the cross-foot base
|
|
95
|
+
WOOD_BOX = (0.0, 0.004, 0.75, STRIP - 0.004) # u0, v0, u1, v1 of the wood tile
|
|
96
|
+
IRON_BOX = (0.77, 0.004, 0.995, STRIP - 0.004) # the iron tile
|
|
97
|
+
PX_PER_M = 0.7 # UV units per metre (the wood tile is 0.75 wide: 1.07 m of grain, 0.167 m across)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def paint_base_tiles(me, wood_rgb, seed=7):
|
|
101
|
+
base, mr = images(me)
|
|
102
|
+
rng = np.random.default_rng(seed)
|
|
103
|
+
for img, kind in ((base, "base"), (mr, "mr")):
|
|
104
|
+
if img is None:
|
|
105
|
+
continue
|
|
106
|
+
px = read_px(img)
|
|
107
|
+
h, w = px.shape[:2]
|
|
108
|
+
for box, mat in ((WOOD_BOX, "wood"), (IRON_BOX, "iron")):
|
|
109
|
+
x0, x1 = int(box[0] * w), int(box[2] * w)
|
|
110
|
+
y0, y1 = int(box[1] * h), int(box[3] * h)
|
|
111
|
+
H, Wd = y1 - y0, x1 - x0
|
|
112
|
+
if kind == "mr":
|
|
113
|
+
region = np.zeros((H, Wd, 4), np.float32)
|
|
114
|
+
region[..., 0] = 1.0
|
|
115
|
+
region[..., 3] = 1.0
|
|
116
|
+
if mat == "wood":
|
|
117
|
+
region[..., 1] = 0.82 + 0.1 * value_noise((H, Wd), (4, 16), rng)
|
|
118
|
+
region[..., 2] = 0.0
|
|
119
|
+
else:
|
|
120
|
+
rust = value_noise((H, Wd), (6, 10), rng)
|
|
121
|
+
region[..., 1] = 0.5 + 0.35 * rust
|
|
122
|
+
region[..., 2] = 0.75 - 0.55 * rust
|
|
123
|
+
elif mat == "wood":
|
|
124
|
+
# grain runs along u (the beam's length): stretched noise bands, darker seams, a few knots
|
|
125
|
+
warp = value_noise((H, Wd), (6, 5), rng) * 9.0
|
|
126
|
+
fine = value_noise((H, Wd), (60, 8), rng)
|
|
127
|
+
rows = np.arange(H)[:, None] * 0.55
|
|
128
|
+
grain = 0.5 + 0.5 * np.sin(rows + warp + fine * 2.5)
|
|
129
|
+
blotch = value_noise((H, Wd), (5, 24), rng)
|
|
130
|
+
tone = 0.72 + 0.22 * grain + 0.16 * (blotch - 0.5)
|
|
131
|
+
seam = (np.abs(((np.arange(H) / H * 3.0) % 1.0) - 0.5) > 0.485)[:, None]
|
|
132
|
+
tone = np.where(seam, tone * 0.55, tone)
|
|
133
|
+
rgb = np.clip(np.asarray(wood_rgb)[None, None, :] * tone[..., None], 0, 1)
|
|
134
|
+
region = np.concatenate([rgb, np.ones((H, Wd, 1))], -1).astype(np.float32)
|
|
135
|
+
else:
|
|
136
|
+
iron = np.array([0.15, 0.145, 0.14])
|
|
137
|
+
rust_c = np.array([0.34, 0.17, 0.08])
|
|
138
|
+
rust = np.clip((value_noise((H, Wd), (6, 10), rng) - 0.45) * 2.5, 0, 1)
|
|
139
|
+
speck = value_noise((H, Wd), (40, 60), rng)
|
|
140
|
+
rgb = iron[None, None] * (0.85 + 0.35 * speck[..., None])
|
|
141
|
+
rgb = rgb * (1 - rust[..., None]) + rust_c[None, None] * rust[..., None] * (0.8 + 0.4 * speck[..., None])
|
|
142
|
+
# rivets: a row of light dots along the middle
|
|
143
|
+
yy, xx = np.mgrid[0:H, 0:Wd]
|
|
144
|
+
for cx in np.linspace(Wd * 0.1, Wd * 0.9, 6):
|
|
145
|
+
for cy in (H * 0.3, H * 0.7):
|
|
146
|
+
d = np.hypot(xx - cx, yy - cy)
|
|
147
|
+
rgb = np.where((d < H * 0.05)[..., None], np.array([0.42, 0.40, 0.37]) * (1.2 - d[..., None] / (H * 0.05)), rgb)
|
|
148
|
+
region = np.concatenate([np.clip(rgb, 0, 1), np.ones((H, Wd, 1))], -1).astype(np.float32)
|
|
149
|
+
px[y0:y1, x0:x1] = region
|
|
150
|
+
write_px(img, px)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _box(bm, uvl, center, size, tile, rot=None, grain_axis=None):
|
|
154
|
+
"""A box of `size` at `center` (optionally rotated), UV-projected into `tile` by each face's normal."""
|
|
155
|
+
m = Matrix.Translation(center) @ (rot or Matrix.Identity(4)) @ Matrix.Diagonal((*size, 1.0))
|
|
156
|
+
geom = bmesh.ops.create_cube(bm, size=1.0, matrix=m)
|
|
157
|
+
faces = {f for v in geom["verts"] for f in v.link_faces}
|
|
158
|
+
u0, v0, u1, v1 = tile
|
|
159
|
+
local_inv = ((rot or Matrix.Identity(4)).to_3x3()).inverted()
|
|
160
|
+
for f in faces:
|
|
161
|
+
n = local_inv @ f.normal
|
|
162
|
+
ax = max(range(3), key=lambda i: abs(n[i]))
|
|
163
|
+
others = [i for i in range(3) if i != ax]
|
|
164
|
+
# u runs along the longer of the face's two axes (the grain follows the beam)
|
|
165
|
+
others.sort(key=lambda i: -size[i])
|
|
166
|
+
for loop in f.loops:
|
|
167
|
+
p = local_inv @ (loop.vert.co - Vector(center))
|
|
168
|
+
a = (p[others[0]] + size[others[0]] / 2) * PX_PER_M
|
|
169
|
+
b = (p[others[1]] + size[others[1]] / 2) * PX_PER_M
|
|
170
|
+
loop[uvl].uv = (u0 + min(a, u1 - u0 - 1e-3), v0 + min(b, v1 - v0 - 1e-3))
|
|
171
|
+
f.smooth = False
|
|
172
|
+
return faces
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def replace_base(me, J, depth_fn, report):
|
|
176
|
+
"""Cut the TRELLIS base, post and braces; build the approved cross-foot. Returns the new vertices' indices."""
|
|
177
|
+
bm = bmesh.new()
|
|
178
|
+
bm.from_mesh(me)
|
|
179
|
+
uvl = bm.loops.layers.uv.active
|
|
180
|
+
bt = J["base_top"]
|
|
181
|
+
hx, hz = J["hip"]
|
|
182
|
+
kx, kz = J["knee"]
|
|
183
|
+
ax_, az = J["ankle"]
|
|
184
|
+
|
|
185
|
+
def leg_axis(z, side):
|
|
186
|
+
pts = [(hx, hz), (kx, kz), (ax_, az)]
|
|
187
|
+
if z >= kz:
|
|
188
|
+
(x0, z0), (x1, z1) = pts[0], pts[1]
|
|
189
|
+
else:
|
|
190
|
+
(x0, z0), (x1, z1) = pts[1], pts[2]
|
|
191
|
+
t = min(1.0, max(0.0, (z - z0) / (z1 - z0)))
|
|
192
|
+
x = x0 + (x1 - x0) * t
|
|
193
|
+
return side * x
|
|
194
|
+
|
|
195
|
+
leg_y = {s: depth_fn(s * ax_, (az + kz) / 2, 0.08) for s in (-1, 1)}
|
|
196
|
+
py = (leg_y[-1] + leg_y[1]) / 2 # the post and both beams cross under the feet
|
|
197
|
+
old_post_y = depth_fn(0.0, 0.6, 0.1)
|
|
198
|
+
base_img, _ = images(me)
|
|
199
|
+
bpx = read_px(base_img)
|
|
200
|
+
H, Wd = bpx.shape[:2]
|
|
201
|
+
wood_samples = []
|
|
202
|
+
for f in bm.faces: # the old base's top: its wood colour
|
|
203
|
+
c = f.calc_center_median()
|
|
204
|
+
if c.z < bt and f.normal.z > 0.7 and abs(c.x) > 0.4:
|
|
205
|
+
u = f.loops[0][uvl].uv
|
|
206
|
+
wood_samples.append(bpx[min(H - 1, int(u.y * H)), min(Wd - 1, int(u.x * Wd)), :3])
|
|
207
|
+
# everything under the new beams' top goes, cut clean along the plane (the feet's soles end flat on the beam)
|
|
208
|
+
bmesh.ops.bisect_plane(bm, geom=bm.verts[:] + bm.edges[:] + bm.faces[:], dist=1e-5, plane_co=(0, 0, bt),
|
|
209
|
+
plane_no=(0, 0, 1), clear_inner=True)
|
|
210
|
+
cut = []
|
|
211
|
+
for f in bm.faces:
|
|
212
|
+
c = f.calc_center_median()
|
|
213
|
+
if c.z > 0.9:
|
|
214
|
+
continue
|
|
215
|
+
side = 1 if c.x >= 0 else -1
|
|
216
|
+
near_leg = abs(c.x - leg_axis(c.z, side)) < 0.15 and abs(c.y - leg_y[side]) < 0.17 and c.z > az + 0.04
|
|
217
|
+
foot = c.z < az + 0.1 and leg_y[side] - 0.32 < c.y < leg_y[side] + 0.14 \
|
|
218
|
+
and ax_ - 0.1 < side * c.x < ax_ + 0.14 # the old braces met the feet on their inner side: that side goes
|
|
219
|
+
post = abs(c.x) < J["post_r"] + 0.02 and abs(c.y - old_post_y) < J["post_r"] + 0.03
|
|
220
|
+
if (not near_leg and not foot) and (c.z < 0.62 or post):
|
|
221
|
+
cut.append(f)
|
|
222
|
+
bmesh.ops.delete(bm, geom=cut, context="FACES")
|
|
223
|
+
bmesh.ops.delete(bm, geom=[v for v in bm.verts if not v.link_faces], context="VERTS")
|
|
224
|
+
# crumbs the cut left behind
|
|
225
|
+
bm.faces.ensure_lookup_table()
|
|
226
|
+
seen, small = set(), []
|
|
227
|
+
for f in bm.faces:
|
|
228
|
+
if f.index in seen:
|
|
229
|
+
continue
|
|
230
|
+
stack, comp = [f], []
|
|
231
|
+
seen.add(f.index)
|
|
232
|
+
while stack:
|
|
233
|
+
g = stack.pop()
|
|
234
|
+
comp.append(g)
|
|
235
|
+
for e in g.edges:
|
|
236
|
+
for h in e.link_faces:
|
|
237
|
+
if h.index not in seen:
|
|
238
|
+
seen.add(h.index)
|
|
239
|
+
stack.append(h)
|
|
240
|
+
if len(comp) < 200 and max(v.co.z for g in comp for v in g.verts) < 0.9:
|
|
241
|
+
small += comp
|
|
242
|
+
bmesh.ops.delete(bm, geom=small, context="FACES")
|
|
243
|
+
bmesh.ops.delete(bm, geom=[v for v in bm.verts if not v.link_faces], context="VERTS")
|
|
244
|
+
# close the soles (flat, on the cut plane) and the small holes the old braces leave in the feet; each cap takes
|
|
245
|
+
# one texel of the surface next to it, so it reads as a plain sole instead of smeared texture
|
|
246
|
+
before = set(bm.faces)
|
|
247
|
+
bmesh.ops.holes_fill(bm, edges=[e for e in bm.edges if e.is_boundary and max(v.co.z for v in e.verts) < 1.0],
|
|
248
|
+
sides=200)
|
|
249
|
+
capped = [f for f in bm.faces if f not in before]
|
|
250
|
+
for f in capped:
|
|
251
|
+
one = None
|
|
252
|
+
for v in f.verts:
|
|
253
|
+
for other in v.link_loops:
|
|
254
|
+
if other.face not in capped and other.face.is_valid:
|
|
255
|
+
one = other[uvl].uv.copy()
|
|
256
|
+
break
|
|
257
|
+
if one is not None:
|
|
258
|
+
break
|
|
259
|
+
for loop in f.loops:
|
|
260
|
+
if one is not None:
|
|
261
|
+
loop[uvl].uv = one
|
|
262
|
+
bmesh.ops.triangulate(bm, faces=[f for f in capped if len(f.verts) > 3])
|
|
263
|
+
report["base_cut_capped"] = len(capped)
|
|
264
|
+
report["base_faces_cut"] = len(cut)
|
|
265
|
+
report["base_crumbs_cut"] = len(small)
|
|
266
|
+
|
|
267
|
+
wood = np.median(np.array(wood_samples), 0) if wood_samples else np.array([0.42, 0.27, 0.15])
|
|
268
|
+
wood = np.clip(wood * 0.78, 0.05, 0.9) # the approved bases are darker, oiled wood
|
|
269
|
+
report["base_wood_rgb"] = [round(float(c), 3) for c in wood]
|
|
270
|
+
|
|
271
|
+
n_before = len(bm.verts)
|
|
272
|
+
fy = py
|
|
273
|
+
L = 1.08 # the side beam (x)
|
|
274
|
+
F = 0.92 # the front-back beam (y)
|
|
275
|
+
bw, bh = 0.17, bt
|
|
276
|
+
cap = 0.075
|
|
277
|
+
new = set()
|
|
278
|
+
new |= _box(bm, uvl, (0, fy, bh / 2), (L - 2 * cap, bw, bh), WOOD_BOX)
|
|
279
|
+
new |= _box(bm, uvl, (0, py, bh / 2 - 0.004), (bw * 0.9, F - 2 * cap, bh - 0.008), WOOD_BOX)
|
|
280
|
+
for s in (-1, 1): # iron end caps, a little proud of the wood
|
|
281
|
+
new |= _box(bm, uvl, (s * (L / 2 - cap / 2), fy, (bh + 0.014) / 2), (cap, bw + 0.02, bh + 0.014), IRON_BOX)
|
|
282
|
+
new |= _box(bm, uvl, (0, py + s * (F / 2 - cap / 2), (bh + 0.01) / 2), (bw * 0.9 + 0.02, cap, bh + 0.01), IRON_BOX)
|
|
283
|
+
# the square post, up into the body (the skirt hides its top)
|
|
284
|
+
post_w = 0.085
|
|
285
|
+
top = J["pelvis"] + 0.05
|
|
286
|
+
new |= _box(bm, uvl, (0, py, bh + (top - bh) / 2), (post_w, post_w, top - bh), WOOD_BOX)
|
|
287
|
+
new |= _box(bm, uvl, (0, py, bh + 0.03), (post_w + 0.03, post_w + 0.03, 0.06), IRON_BOX) # the collar at its foot
|
|
288
|
+
# four braces from the beams up to the post
|
|
289
|
+
# the old braces landed under the feet' inner edges (the wood figure's fit: from x = 0.25 at the beam to the post at
|
|
290
|
+
# 0.37 m): the new ones follow the same line, so the stubs the feet kept end up inside them
|
|
291
|
+
reach, rise = 0.27, 0.30
|
|
292
|
+
run = reach - post_w / 2
|
|
293
|
+
blen = math.hypot(run, rise) + 0.03
|
|
294
|
+
ang = math.atan2(rise, run)
|
|
295
|
+
for s in (-1, 1):
|
|
296
|
+
mid = post_w / 2 + run / 2
|
|
297
|
+
new |= _box(bm, uvl, (s * mid, py, bh + rise / 2), (blen, 0.07, 0.07), WOOD_BOX,
|
|
298
|
+
Matrix.Rotation(s * ang, 4, "Y"))
|
|
299
|
+
new |= _box(bm, uvl, (0, py + s * mid, bh + rise / 2), (blen, 0.07, 0.07), WOOD_BOX,
|
|
300
|
+
Matrix.Rotation(math.pi / 2, 4, "Z") @ Matrix.Rotation(s * ang, 4, "Y"))
|
|
301
|
+
bmesh.ops.triangulate(bm, faces=list(new))
|
|
302
|
+
bm.verts.ensure_lookup_table()
|
|
303
|
+
n_after = len(bm.verts)
|
|
304
|
+
bm.to_mesh(me)
|
|
305
|
+
bm.free()
|
|
306
|
+
me.update()
|
|
307
|
+
paint_base_tiles(me, wood)
|
|
308
|
+
report["base_new_faces"] = len(new)
|
|
309
|
+
return set(range(n_before, n_after))
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
# ---------------------------------------------------------------------------------------------- geometry smoothing
|
|
313
|
+
def smooth_regions(me, spheres, repeat=6, factor=0.6):
|
|
314
|
+
"""Laplacian-smooth the vertices inside any (centre, radius) sphere: pulls the remesh's loose flakes in."""
|
|
315
|
+
bm = bmesh.new()
|
|
316
|
+
bm.from_mesh(me)
|
|
317
|
+
sel = [v for v in bm.verts if any((v.co - Vector(c)).length < r for c, r in spheres)]
|
|
318
|
+
for _ in range(repeat):
|
|
319
|
+
bmesh.ops.smooth_vert(bm, verts=sel, factor=factor, use_axis_x=True, use_axis_y=True, use_axis_z=True)
|
|
320
|
+
bm.to_mesh(me)
|
|
321
|
+
bm.free()
|
|
322
|
+
me.update()
|
|
323
|
+
return len(sel)
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
def flatten_face(me, cz, radius, front_y):
|
|
327
|
+
"""The face under the painted target: a quadratic fitted to the surface round it replaces its dents."""
|
|
328
|
+
V = np.array([v.co[:] for v in me.vertices])
|
|
329
|
+
r = np.hypot(V[:, 0], V[:, 2] - cz) / radius
|
|
330
|
+
front = V[:, 1] < front_y
|
|
331
|
+
ring = front & (r > 1.1) & (r < 1.7)
|
|
332
|
+
inner = front & (r < 1.15)
|
|
333
|
+
if ring.sum() < 12 or inner.sum() == 0:
|
|
334
|
+
return 0
|
|
335
|
+
x, z = V[ring, 0], V[ring, 2] - cz
|
|
336
|
+
A = np.stack([np.ones_like(x), x, z, x * x, z * z, x * z], 1)
|
|
337
|
+
coef, *_ = np.linalg.lstsq(A, V[ring, 1], rcond=None)
|
|
338
|
+
xi, zi = V[inner, 0], V[inner, 2] - cz
|
|
339
|
+
fit = np.stack([np.ones_like(xi), xi, zi, xi * xi, zi * zi, xi * zi], 1) @ coef
|
|
340
|
+
w = np.clip((1.15 - r[inner]) / 0.2, 0, 1)
|
|
341
|
+
V[inner, 1] = V[inner, 1] * (1 - w) + fit * w
|
|
342
|
+
me.vertices.foreach_set("co", V.ravel())
|
|
343
|
+
me.update()
|
|
344
|
+
return int(inner.sum())
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
# ---------------------------------------------------------------------------------------------- steel weathering
|
|
348
|
+
def rasterize(me, fn, box=None):
|
|
349
|
+
"""For every triangle: fn(sl, inside, l0, l1, l2, poly) over its texels (barycentrics in texture space)."""
|
|
350
|
+
base, _ = images(me)
|
|
351
|
+
W_, H_ = base.size
|
|
352
|
+
uv = me.uv_layers.active.data
|
|
353
|
+
for poly in me.polygons:
|
|
354
|
+
if len(poly.vertices) != 3:
|
|
355
|
+
continue
|
|
356
|
+
T2 = [uv[li].uv for li in poly.loop_indices]
|
|
357
|
+
xs = [t.x * W_ for t in T2]
|
|
358
|
+
ys = [t.y * H_ for t in T2]
|
|
359
|
+
x0, x1 = max(0, int(min(xs)) - 2), min(W_ - 1, int(max(xs)) + 2)
|
|
360
|
+
y0, y1 = max(0, int(min(ys)) - 2), min(H_ - 1, int(max(ys)) + 2)
|
|
361
|
+
if x1 < x0 or y1 < y0:
|
|
362
|
+
continue
|
|
363
|
+
gx, gy = np.meshgrid(np.arange(x0, x1 + 1) + 0.5, np.arange(y0, y1 + 1) + 0.5)
|
|
364
|
+
(ax, ay), (bx, by), (qx, qy) = zip(xs, ys)
|
|
365
|
+
den = (by - qy) * (ax - qx) + (qx - bx) * (ay - qy)
|
|
366
|
+
if abs(den) < 1e-9:
|
|
367
|
+
continue
|
|
368
|
+
l0 = ((by - qy) * (gx - qx) + (qx - bx) * (gy - qy)) / den
|
|
369
|
+
l1 = ((qy - ay) * (gx - qx) + (ax - qx) * (gy - qy)) / den
|
|
370
|
+
l2 = 1 - l0 - l1
|
|
371
|
+
inside = (l0 > -0.1) & (l1 > -0.1) & (l2 > -0.1)
|
|
372
|
+
if inside.any():
|
|
373
|
+
fn((slice(y0, y1 + 1), slice(x0, x1 + 1)), inside, l0, l1, l2, poly)
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
def weather_steel(me, report, darken=0.6):
|
|
377
|
+
"""Metal texels (the material map's blue > 0.35) darken to iron, gather grime, and rust in patches (3D noise)."""
|
|
378
|
+
base, mr = images(me)
|
|
379
|
+
bpx, mpx = read_px(base), read_px(mr)
|
|
380
|
+
V = np.array([v.co[:] for v in me.vertices])
|
|
381
|
+
grime_v = noise3(V, 4.0, 11)
|
|
382
|
+
rust_v = noise3(V, 11.0, 23)
|
|
383
|
+
done = np.zeros(bpx.shape[:2], bool)
|
|
384
|
+
rust_c = np.array([0.24, 0.14, 0.08]) # a brown, dry rust, not orange
|
|
385
|
+
count = [0]
|
|
386
|
+
|
|
387
|
+
def fn(sl, inside, l0, l1, l2, poly):
|
|
388
|
+
i0, i1, i2 = poly.vertices
|
|
389
|
+
region_b, region_m = bpx[sl], mpx[sl]
|
|
390
|
+
metal = (region_m[..., 2] > 0.35) & inside & ~done[sl]
|
|
391
|
+
if not metal.any():
|
|
392
|
+
return
|
|
393
|
+
g = l0 * grime_v[i0] + l1 * grime_v[i1] + l2 * grime_v[i2]
|
|
394
|
+
r = l0 * rust_v[i0] + l1 * rust_v[i1] + l2 * rust_v[i2]
|
|
395
|
+
rust = np.clip((r - 0.7) / 0.14, 0, 1) * 0.55
|
|
396
|
+
rgb = region_b[..., :3] * darken * (0.8 + 0.3 * g)[..., None]
|
|
397
|
+
lum = region_b[..., :3].mean(-1, keepdims=True)
|
|
398
|
+
rgb = rgb * (1 - rust[..., None]) + rust_c * (0.7 + 0.8 * lum) * rust[..., None]
|
|
399
|
+
m = metal[..., None]
|
|
400
|
+
bpx[sl][..., :3] = np.where(m, rgb, region_b[..., :3])
|
|
401
|
+
mpx[sl][..., 1] = np.where(metal, np.clip(region_m[..., 1] + 0.12 + 0.35 * rust, 0, 1), region_m[..., 1])
|
|
402
|
+
mpx[sl][..., 2] = np.where(metal, region_m[..., 2] * (1 - 0.7 * rust), region_m[..., 2])
|
|
403
|
+
done[sl] |= metal
|
|
404
|
+
count[0] += 1
|
|
405
|
+
|
|
406
|
+
rasterize(me, fn)
|
|
407
|
+
write_px(base, bpx)
|
|
408
|
+
write_px(mr, mpx)
|
|
409
|
+
report["steel_weathered_faces"] = count[0]
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
def despeckle(me, spheres, report):
|
|
413
|
+
"""Inside each (centre, radius) sphere, texels far off the sphere's own colour (the bake's blue-grey gaps and
|
|
414
|
+
black specks on the straw neck and fists, E289) take that colour back, keeping their light / dark grain."""
|
|
415
|
+
base, _ = images(me)
|
|
416
|
+
px = read_px(base)
|
|
417
|
+
V = np.array([v.co[:] for v in me.vertices])
|
|
418
|
+
fixed = [0]
|
|
419
|
+
for centre, radius in spheres:
|
|
420
|
+
c = np.asarray(centre)
|
|
421
|
+
polys = [p for p in me.polygons if np.linalg.norm(V[list(p.vertices)].mean(0) - c) < radius]
|
|
422
|
+
if not polys:
|
|
423
|
+
continue
|
|
424
|
+
samples = []
|
|
425
|
+
|
|
426
|
+
def collect(sl, inside, l0, l1, l2, poly):
|
|
427
|
+
samples.append(px[sl][..., :3][inside])
|
|
428
|
+
|
|
429
|
+
_raster_polys(me, polys, collect)
|
|
430
|
+
allpx = np.concatenate(samples)
|
|
431
|
+
lum = allpx.mean(1)
|
|
432
|
+
good = allpx[(allpx[:, 0] > allpx[:, 2] + 0.05) & (lum > np.percentile(lum, 25))]
|
|
433
|
+
if len(good) < 10:
|
|
434
|
+
continue
|
|
435
|
+
med = np.median(good, 0)
|
|
436
|
+
mlum = float(med.mean())
|
|
437
|
+
|
|
438
|
+
def fix(sl, inside, l0, l1, l2, poly):
|
|
439
|
+
reg = px[sl][..., :3]
|
|
440
|
+
lum_ = reg.mean(-1)
|
|
441
|
+
bad = inside & ((reg[..., 2] > reg[..., 0] - 0.02) | (lum_ < 0.55 * mlum))
|
|
442
|
+
if bad.any():
|
|
443
|
+
grain = np.clip(lum_ / max(mlum, 1e-3), 0.8, 1.1)[..., None]
|
|
444
|
+
px[sl][..., :3] = np.where(bad[..., None], med * grain, reg)
|
|
445
|
+
fixed[0] += int(bad.sum())
|
|
446
|
+
|
|
447
|
+
_raster_polys(me, polys, fix)
|
|
448
|
+
write_px(base, px)
|
|
449
|
+
report["despeckled_texels"] = fixed[0]
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
def _raster_polys(me, polys, fn):
|
|
453
|
+
base, _ = images(me)
|
|
454
|
+
W_, H_ = base.size
|
|
455
|
+
uv = me.uv_layers.active.data
|
|
456
|
+
for poly in polys:
|
|
457
|
+
if len(poly.vertices) != 3:
|
|
458
|
+
continue
|
|
459
|
+
T2 = [uv[li].uv for li in poly.loop_indices]
|
|
460
|
+
xs = [t.x * W_ for t in T2]
|
|
461
|
+
ys = [t.y * H_ for t in T2]
|
|
462
|
+
x0, x1 = max(0, int(min(xs)) - 1), min(W_ - 1, int(max(xs)) + 1)
|
|
463
|
+
y0, y1 = max(0, int(min(ys)) - 1), min(H_ - 1, int(max(ys)) + 1)
|
|
464
|
+
gx, gy = np.meshgrid(np.arange(x0, x1 + 1) + 0.5, np.arange(y0, y1 + 1) + 0.5)
|
|
465
|
+
(ax, ay), (bx, by), (qx, qy) = zip(xs, ys)
|
|
466
|
+
den = (by - qy) * (ax - qx) + (qx - bx) * (ay - qy)
|
|
467
|
+
if abs(den) < 1e-9:
|
|
468
|
+
continue
|
|
469
|
+
l0 = ((by - qy) * (gx - qx) + (qx - bx) * (gy - qy)) / den
|
|
470
|
+
l1 = ((qy - ay) * (gx - qx) + (ax - qx) * (gy - qy)) / den
|
|
471
|
+
l2 = 1 - l0 - l1
|
|
472
|
+
inside = (l0 > -0.05) & (l1 > -0.05) & (l2 > -0.05)
|
|
473
|
+
if inside.any():
|
|
474
|
+
fn((slice(y0, y1 + 1), slice(x0, x1 + 1)), inside, l0, l1, l2, poly)
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
def neck_plug(me, z0, z1, report, fists=()):
|
|
478
|
+
"""The straw collar's gaps (open straight through the body, E289): a straw-coloured tube just inside the neck's
|
|
479
|
+
wall, so a gap shows straw instead of the room."""
|
|
480
|
+
from mathutils.bvhtree import BVHTree
|
|
481
|
+
base, mr = images(me)
|
|
482
|
+
V = np.array([v.co[:] for v in me.vertices])
|
|
483
|
+
band = V[(V[:, 2] > z0 + 0.05) & (V[:, 2] < z1 - 0.03) & (np.abs(V[:, 0]) < 0.2)]
|
|
484
|
+
cx, cy = float(np.median(band[:, 0])), float(np.median(band[:, 1]))
|
|
485
|
+
# its colour: the median straw texel of the neck, painted into a cell of the free strip
|
|
486
|
+
px = read_px(base)
|
|
487
|
+
H, W = px.shape[:2]
|
|
488
|
+
uv = me.uv_layers.active.data
|
|
489
|
+
cols = []
|
|
490
|
+
for p in me.polygons:
|
|
491
|
+
c = p.center
|
|
492
|
+
if z0 + 0.05 < c.z < z1 - 0.03 and math.hypot(c.x - cx, c.y - cy) < 0.2:
|
|
493
|
+
u = uv[p.loop_indices[0]].uv
|
|
494
|
+
t = px[min(H - 1, int(u.y * H)), min(W - 1, int(u.x * W)), :3]
|
|
495
|
+
if t[0] > t[2] + 0.1:
|
|
496
|
+
cols.append(t)
|
|
497
|
+
straw = np.median(np.array(cols), 0) if cols else np.array([0.62, 0.48, 0.26])
|
|
498
|
+
x0, x1 = int(0.752 * W), int(0.768 * W)
|
|
499
|
+
y0, y1 = int(0.02 * H), int(0.05 * H)
|
|
500
|
+
px[y0:y1, x0:x1, :3] = straw
|
|
501
|
+
write_px(base, px)
|
|
502
|
+
if mr is not None:
|
|
503
|
+
mpx = read_px(mr)
|
|
504
|
+
mpx[y0:y1, x0:x1, 1] = 0.9
|
|
505
|
+
mpx[y0:y1, x0:x1, 2] = 0.0
|
|
506
|
+
write_px(mr, mpx)
|
|
507
|
+
cell = Vector(((x0 + x1) / 2 / W, (y0 + y1) / 2 / H))
|
|
508
|
+
|
|
509
|
+
# a tube that follows the neck's own wall 8 mm inside it: each vertex sits on its own ray from the neck's axis
|
|
510
|
+
# (hits closer than 4 cm are loose flakes inside and are skipped); where a ray leaves through a gap it takes its
|
|
511
|
+
# neighbours' distance, so the gap shows the tube
|
|
512
|
+
tree = BVHTree.FromPolygons([v.co for v in me.vertices], [p.vertices for p in me.polygons])
|
|
513
|
+
N, R = 48, 13
|
|
514
|
+
grid = []
|
|
515
|
+
for r in range(R):
|
|
516
|
+
z = z0 + (z1 - z0) * r / (R - 1)
|
|
517
|
+
row = []
|
|
518
|
+
for k in range(N):
|
|
519
|
+
a_ = 2 * math.pi * k / N
|
|
520
|
+
d = Vector((math.cos(a_), math.sin(a_), 0.0))
|
|
521
|
+
hit = tree.ray_cast(Vector((cx, cy, z)) + d * 0.04, d, 0.25)
|
|
522
|
+
row.append(hit[3] + 0.04 if hit[0] is not None else None)
|
|
523
|
+
for _ in range(N):
|
|
524
|
+
for k in range(N):
|
|
525
|
+
if row[k] is None:
|
|
526
|
+
nb = [t for t in (row[k - 1], row[(k + 1) % N]) if t is not None]
|
|
527
|
+
if nb:
|
|
528
|
+
row[k] = min(nb)
|
|
529
|
+
grid.append([min(0.15, t) if t is not None else 0.06 for t in row]) # never wider than the neck
|
|
530
|
+
bm = bmesh.new()
|
|
531
|
+
bm.from_mesh(me)
|
|
532
|
+
uvl = bm.loops.layers.uv.active
|
|
533
|
+
vr = []
|
|
534
|
+
for r in range(R):
|
|
535
|
+
z = z0 + (z1 - z0) * r / (R - 1)
|
|
536
|
+
vr.append([bm.verts.new((cx + math.cos(2 * math.pi * k / N) * max(0.03, grid[r][k] - 0.008),
|
|
537
|
+
cy + math.sin(2 * math.pi * k / N) * max(0.03, grid[r][k] - 0.008), z)) for k in range(N)])
|
|
538
|
+
faces = []
|
|
539
|
+
for r0, r1 in zip(vr, vr[1:]):
|
|
540
|
+
for k in range(N):
|
|
541
|
+
faces.append(bm.faces.new((r0[k], r0[(k + 1) % N], r1[(k + 1) % N], r1[k])))
|
|
542
|
+
for f in faces:
|
|
543
|
+
f.smooth = True
|
|
544
|
+
for loop in f.loops:
|
|
545
|
+
loop[uvl].uv = cell
|
|
546
|
+
bmesh.ops.triangulate(bm, faces=faces)
|
|
547
|
+
# the fists: a straw blob inside each, pushed out to 6 mm under its wall, so their gaps show straw too
|
|
548
|
+
Vn = np.array([v.co[:] for v in me.vertices])
|
|
549
|
+
for fc, fr in fists:
|
|
550
|
+
fc = np.asarray(fc)
|
|
551
|
+
near = Vn[np.linalg.norm(Vn - fc, axis=1) < fr]
|
|
552
|
+
if len(near) < 20:
|
|
553
|
+
continue
|
|
554
|
+
o = Vector(near.mean(0))
|
|
555
|
+
blob = bmesh.ops.create_icosphere(bm, subdivisions=2, radius=1.0, matrix=Matrix.Translation(o))
|
|
556
|
+
for v in blob["verts"]:
|
|
557
|
+
d = (v.co - o).normalized()
|
|
558
|
+
hit = tree.ray_cast(o, d, fr)
|
|
559
|
+
t = hit[3] if hit[0] is not None else fr * 0.5
|
|
560
|
+
v.co = o + d * max(0.015, t - 0.006)
|
|
561
|
+
for f in {f for v in blob["verts"] for f in v.link_faces}:
|
|
562
|
+
f.smooth = True
|
|
563
|
+
for loop in f.loops:
|
|
564
|
+
loop[uvl].uv = cell
|
|
565
|
+
bm.to_mesh(me)
|
|
566
|
+
bm.free()
|
|
567
|
+
me.update()
|
|
568
|
+
report["neck_tube_faces"] = len(faces) * 2
|