Co-Evolution
Bidirectional paint-to-geometry 3D co-evolution across arbitrary asset domains.
Co-Evolution pairs calibrated multi-view painting and homography registration with metric depth (MapAnything), InstanceRecon $N=4$ colored TSDF + non-coarsening Marching Cubes isosurface refinement, Next-Best-View (NBV) adaptive camera planning, local Meta SAM 3 domain-aware semantic lifting, watertight manifold3d CSG sculpting, CoACD + MuJoCo concave structural physics audits, and conformal xatlas + float32 sparse Screened-Poisson UV baking.
Using with an AI coding agent? Point your agent to this repo withllms.txtorSKILL.md— or simply say "use coevolution: https://github.com/wrong-nebula/coevolution". The unified CLI (python3 coevolution/cli.py doctor) auto-detects local backends and verifies the full stack at$0.
How the Loop Works
Coarse Blockout (Gen N)
└─ Calibrated Multi-View Capture + Next-Best-View (NBV) Camera Planning
└─ Multi-View Paint + Homography / Flow Sub-Pixel Registration
├─ Metric 3D Signal (MapAnything Metric Depth + MoGe Normals)
├─ InstanceRecon N=4 Colored TSDF + Marching Cubes + Local SAM 3
├─ Watertight Universal Sculptor (manifold3d CSG + Mesh Booleans)
├─ WorldMemory Morton Clearance Gate + CoACD / MuJoCo Concave Physics
└─ xatlas Conformal UVs + Float32 Sparse Screened-Poisson Bake
└─ Verified Asset (Gen N+1) + Machine-Readable certificate.json
Geometry & Paint Co-Evolution
A single autonomous sculpting round driven by calibrated depth residuals, surface normals, and MuJoCo contact checks transforms a plain parametric blockout into articulated Alpine stone architecture — adding the bell tower, cross finial, porch canopy, stepped plinth, and window reveals.
!Grisons Alpine Chapel clay geometry evolution from Gen 0 to Gen 1
Across subsequent generations, painted ornament is promoted into real 3D geometry while multi-view paint refines stone masonry, weathered slate, and timber joinery without silhouette drift.
!Geometry and multi-view paint co-evolution across Gen 0, Gen 1, and Gen 2
Gen 5 — Final 4-Corner Multi-View Paint Grid
!Gen 5 calibrated 4-corner painted grid
InstanceRecon ($N=4$ Colored TSDF) + Local SAM 3
coevolution/instancerecon_volumes.py and coevolution/sam3_masks.py lift per-view semantic masks into clean, separated 3D architectural volumes:
- Local Meta
SAM 3mask extraction — Appendix-B score, area, and>70%nested containment filtering with a0.24whole-building non-structural area guard. - Multi-view 2D → 3D lifting — calibrated reprojection matching across views with depth-jump unassigned borders (
tau = 0.08 m). - Exact proximity-weighted $N=4$ graph coloring — solved globally via SciPy HiGHS MILP so neighboring protrusions occupy distinct TSDF volumes.
- Per-volume colored TSDF +
5 cmshifted-seam refinement — other-volume free-space carving preserves sharp architectural silhouettes and thin features like finials and canopies.
3D Overhang Extraction ($N=4$ Colored TSDF)
!InstanceRecon N=4 colored TSDF orthographic projection sheet with volume legend
Grounded 3D Semantic Proposals
!InstanceRecon + SAM 3 grounded architectural proposals across 4 calibrated chapel views
Stage 3: Universal Blender 5.x → Marso 4K PBR Handoff
coevolution/marso_handoff.py (python3 coevolution/cli.py marso-handoff) turns any watertight Stage 2 .blend asset into production 4K measured PBR maps + .blend + .glb across arbitrary scales (0.4 m props to 15 m+ architecture):
!Multi-domain 4K PBR showcase across Architecture, Sub-Meter Prop, Vehicle, and Curved SDS Furniture
- Auto-Detected Multi-Domain Visibility (
visibility_mode="auto") — Geometrically classifies grounded structures (ground_overhang, 19-view rig with-20°overhang ring) vs. 360° assets (full_sphere, 26-view spherical rig with1.0xunderside texel preservation). - Backface-Enclosure Interior Face Culling (
cull_interior_faces=True) — 9-ray outward-hemisphere backface-enclosure test + 1-ring topological safety halo deletes strictly buried internal overlap triangles beforexatlaswhile preserving air cavities (wheel wells, slots, louvers) with zero holes. - Scale-Invariant Pre-
xatlasDual-Split Visibility Packing (xatlas_dual_vis) — Pre-normalizes geometry (radius -> 50.0) soxatlasnever collapses sub-meter micro-bevels (0degenerate UVs across a 10-asset multi-domain Pareto corpus spanning0.42 m–6.50 m), with adaptive 4K padding (6/5/4 px) andGlassisolate & restore. - Universal Semantic Albedo & Metallic/Roughness Drift Guards + Automated QA (
marso_qa_report.json) — Bakes Stage-2 semantic(R=Metallic, G=Roughness, B=Coat, A=w(x))in a single pass alongsidecoevo_basecolor_atlas.png; heals bleached wood/livery, collapsed mid-tones, neutral chroma bleed/blotches, dielectric-to-metal bleed, and matte/gloss inversions while preserving 4K high-frequency micro-grain. Tunable post-hoc at$0API cost viacoevolution/cli.py reapply-guard.
ground_overhang | — | 49.8% (dual-split) | 0.992 | 0 |
| Sub-Meter Prop | Tactical Modern Carbine | full_sphere | — | 54.5% (5,323 px/m) | 0.999 | 0 |
| Vehicle | 1980s Group B Rally Coupe | full_sphere | 6,209 tris (5.35%) | 59.4% (487 px/m) | 0.999 | 0 |
| Curved SDS Furniture | Molded-Walnut Lounge Chair | full_sphere | 7.01% area | 67.5% (1,932 px/m) | 1.000 | 0 |
| Real Street-View TSDF | NYPL Facade (74.6 m, 1440px v5 splat-to-marso watertight) | ground_overhang | 0 (watertight, 0 NM edges) | 58.6% (41.9 px/m, colored atlas) | 1.003 | 0 / 50k (0.000%) |
| Real Street-View TSDF | Flatiron Wedge (93.6 m, splat-to-marso watertight) | ground_overhang | 1 (watertight, 0 NM edges) | 54.4% (20.3 px/m, colored atlas) | 1.003 | 3 / 50k (0.006%) |
Quickstart
1. Install, Verify & Benchmark ($0, Pure CPU)
pip install -r requirements.txt
python3 coevolution/cli.py doctor
python3 coevolution/cli.py test
python3 coevolution/cli.py bench # $0 5-domain synthetic GT judge (architecture, mechanical, concave_interior, organic_rock, vehicle)
2. Run InstanceRecon + Local SAM 3 on Calibrated Views
# Optional: extract local SAM 3 per-view semantic masks ($0 local MPS/CUDA)
Supports --domain architecture|mechanical|concave_interior|organic_rock|vehicle|generic
python3 coevolution/cli.py sam3 \
--views-dir <gen_dir>/views \
--domain architecture \
--out <out_dir>/sam3_masks.npz
N=4 colored TSDF + non-coarsening Marching Cubes visual hull extraction
python3 coevolution/cli.py hull \
--views-dir <gen_dir>/views \
--out-dir <out_dir>/vh \
--sam3-masks <out_dir>/sam3_masks.npz
Grounded semantic proposal discovery (compatible with local_mapanything.py --mode guides)
python3 coevolution/cli.py proposals \
--views-dir <gen_dir>/views \
--out-dir <out_dir>/proposals \
--sam3-masks <out_dir>/sam3_masks.npz
3. Unified Offline DAG & Certificate ($0)
bash coevolution/setup_mapanything_env.sh # one-time Apache-2.0 MapAnything weights (~6.5 GB)
python3 coevolution/cli.py pipeline --views-dir <gen_dir>/views --glb <blockout.glb> --domain architecture
python3 coevolution/cli.py offline-v3 --views-dir <gen_dir>/views --glb <blockout.glb>
4. Stage 3 Blender 5.x → Marso 4K PBR Handoff & $0 Guard Re-Application
# $0 Stage-2 watertight + cross-material poke-through gate before Marso
python3 coevolution/cli.py stage2-audit --blend <stage2_asset.blend> --max-poke-throughs 0
$0 dry-run preflight (interior culling, dual-split xatlas UVs, 2K semantic + PBR mask bake)
python3 coevolution/cli.py marso-handoff \
--blend <stage2_asset.blend> \
--out-dir <out_dir>/stage3_4k \
--prompt "<material craft description>" \
--dry-run
Full live Marso 4K PBR retexture + 4-mode albedo & PBR guards + marso_qa_report.json
python3 coevolution/cli.py marso-handoff \
--blend <stage2_asset.blend> \
--out-dir <out_dir>/stage3_4k \
--prompt "<material craft description>"
Tune or re-apply albedo & PBR drift guards on saved marso_*_raw.png at $0 API cost
python3 coevolution/cli.py reapply-guard --out-dir <out_dir>/stage3_4k
$0 Colab-autoresearched 2DGS training recipe presets & anti-pattern guardrails (default: metric_lidar_v5)
python3 coevolution/cli.py splat-recipe --preset metric_lidar_v5 --out <out_dir>/train_recipe.json
$0 Colab-autoresearched 2DGS splat post-processing (pareto_v2: -21.2% WT, +0.4 cm LiDAR, +0.016 dB PSNR, -31.3% MB)
python3 coevolution/cli.py splat-clean --ply <in_2dgs.ply> --out-ply <clean.ply> --out-npz <clean_q.npz> --preset pareto_v2
$0 Colab-autoresearched Track #3 2DGS -> Colored Hole-Filled Mesh TSDF extraction (default: cohesive_wide_v2)
python3 coevolution/cli.py splat-mesh --depth-npz <views_depth.npz> --out-obj <mesh.obj> --out-ply <colored.ply> --fill-holes-max-diam 10.0 --preset cohesive_wide_v2
Turnkey $0 2DGS Splat -> pareto_v2 -> Colored Hole-Filled TSDF -> Watertight Stage-2 Blend -> Audit -> Marso Dry-Run
python3 coevolution/cli.py splat-to-marso \
--ply <in_2dgs.ply> \
--poses <calibrated_poses_metric.json> \
--out-dir <out_dir>/splat_to_marso \
--prompt "<architectural material description>"
Cinema-Grade $0 12 cm C++17 Sparse Block-Hashed TSDF + Watertight Exterior Shrinkwrap (score=1.0) + Direct 4K Soft-Max PBR
python3 coevolution/cli.py cinema-mesh \
--ply <in_2dgs.ply> \
--poses <calibrated_poses_metric.json> \
--out-dir <out_dir>/cinema_4k \
--asset-name NYPL_BeauxArts \
--voxel-size 0.12 --atlas-size 4096
Optional: floor-aligned periodic planar facade bay completion for street-occluded side wings (e.g. Flatiron Wedge)
python3 coevolution/cli.py cinema-mesh \
--ply <in_2dgs.ply> \
--poses <calibrated_poses_metric.json> \
--out-dir <out_dir>/flatiron_cinema_4k \
--asset-name Flatiron_Wedge \
--voxel-size 0.20 --complete-planar-facades --wing-max-len-m 40.0 --atlas-size 4096
2DGS Metric Splat Training, Post-Processing & Cinema-Grade Sparse TSDF → 4K PBR
Across 130+ Karpathy-style Colab GPU autoresearch experiments spanning 6 tracks on 8 diverse NYC architectural topologies (nyc-guggenheim curved rotunda, nyc-public-library classical facade, nyc-flatiron-wedge 87 m acute wedge, nyc-haughwout 90° cast-iron L-corner, plus 4 brand-new unseen landmarks: nyc-st-patricks-cathedral, nyc-dakota-apartments, nyc-met-museum, nyc-federal-hall — evaluated strictly on blind right-half held-out views and blind 20% spatial-block held-out LiDAR), Co-Evolution ships verified training recipes (coevolution/splat_train_recipe.py), pure-CPU $0 post-processing (coevolution/splat_postprocess.py), and pure-CPU $0 TSDF mesh extraction (coevolution/splat_mesh_extract.py):
| Track | Preset / Champion | Primary Blind Geometry | Blind Photometry / Topology | Footprint / Cohesion |
| --- | --- | --- | --- | --- |
| 1440px + SegFormer-B2 (NYPL + Flatiron L4 12k) | metric_lidar_v5 + pareto_v2 + Sim3Refine + cinema-mesh | NYPL 0.532 m (0.303 m lower-third, 1.666 m p90) · Flatiron 0.519 m (88.5 m) | NYPL 16.49 dB (v5), Flatiron 0.1368 LPIPS / 0.8066 SSIM · BOTH 1/1 watertight (0 NM, 1.0 audit) | 12–20 cm sparse TSDF + bay completion + 4K PBR (98.5% hit, 105k tris, 17.1 MB GLB) |
| 1440px + SegFormer-B2 (NYPL L4 12k) | metric_lidar_v5 + pareto_v2 (+ optional Train-LiDAR Sim3) | 0.622 m blind LiDAR (0.501 m w/ Sim3, -41.3 cm), 1.606 m p90 | 16.49 dB PSNR (+0.39 dB vs 12k base, +0.45 dB vs v3), 0.2994 LPIPS | -24.7% MB (3.41 MB), -9.9% WT (0.263), 92.4% colored TSDF |
| 1440px + SegFormer-B2 (NYPL L4 7.5k) | metric_lidar_v3_perceptual + pareto_v1 | 0.621 m blind LiDAR (-29.3 cm vs base, -1.6 cm vs v2) | 16.04 dB PSNR (+0.38 dB vs v2), -0.0203 LPIPS vs v2 | -24.3% MB (3.43 MB), 92.1% TSDF mesh |
| Track #8 (4-Unseen 5.5k) | metric_lidar_v5 (default verified across 8 NYC LMs) | 0.919 m unseen splat · 0.739 m v1 / 0.811 m v2 mesh | 11.59 dB PSNR · 0.5238 LPIPS · 64.2% cov (bila648 optional: -0.0054 LPIPS, -2.8 cm mesh, +4.2 cm splat) | 81.1% v2 main comp (+7.6% over v1 across all 4 unseen topologies) |
| Track #7-b (4-LM Verified) | metric_lidar_v5 (default, v4 + 3-scale MS-SSIM) | +1.61 raw / +0.54 clean Pareto · -1.35 cm clean p50 (-8.3 cm Gug), -11.1 cm raw / -8.8 cm clean p90 | +0.105 dB raw / +0.062 dB clean PSNR, +1.16% cov | +9.0% TSDF main comp (76.5% v1 / 78.7% v2; Gug +27.5% v1) |
| Track #7 (4-LM Verified) | metric_lidar_v4_perceptual + pareto_v2 (on v4) | +1.41 raw / +2.73 clean Pareto · 0.386 m Flatiron / 0.325 m Haughwout mesh | +0.126 dB PSNR (+0.321 dB Flatiron), -0.0047 LPIPS, +0.95% cov | -1.8% clean WT (0.310), v5 stays geometry/mesh default |
| Track #5-b (4-LM Verified) | metric_lidar_v4 + pareto_v2 (on top of v2) | +3.71 raw / +3.96 clean Pareto · 0.456 m 4-LM mesh (78.7% main) | +0.186 dB clean PSNR (+0.317 dB Flatiron), -13.7 cm NYPL p90 | -7.3% clean WT (0.316), -21.3% raw MB |
| Track #6 (4-Unseen L4 7.5k) | metric_lidar_v3_perceptual (on top of v2) | 0.798 m unseen mesh (-2.8 cm), 0.937 m splat | -0.0078 unseen LPIPS (-0.0141 sweep), -6.3% shadows | -20.2% raw SH0 MB, pure-math |
| Track #5 (4-LM Verified) | metric_lidar_v3 + pareto_v2 (mesh-priority) | 0.707 m clean splat (-2.9 cm) · 0.480 m mesh (-2.6 cm) | -12.3 cm LiDAR p90, +0.26% cov | -5.0% clean WT, 76.4% main comp |
| Track #4 (4-LM Verified) | metric_lidar_v2 (on top of v1) | 0.700 m splat (-32.7 cm) · 0.466 m mesh (-25.2 cm) | +0.11 dB PSNR, unseen Flatiron 0.400 m, Haughwout 0.354 m | -5.7% clean WT, 79.6% main comp |
| Track #2 (12k steps L4) | metric_lidar_v1 (vs Stage-A base) | -140.9 cm (-46.4%) LiDAR p50 | +0.43 dB PSNR, -0.0025 LPIPS, +3.1% cov | +0.4% WT |
| E2E (12k + splat-clean) | metric_lidar_v1 + pareto_v1 | -136.4 cm LiDAR p50 (+68.34 Pareto) | +0.29 dB PSNR, +2.4% cov | -9.8% WT, -31.5% MB |
| Track #1 v2 ($0 CPU) | pareto_v2 / pareto_v2_compact | +0.4 cm / +0.3 cm LiDAR (-2.5 cm vs v1) | +0.016 dB PSNR, 99.3% cov (+16.85 Pareto) | -21.2% WT, -31.3% / -37.0% MB |
| Track #3 v2 Mesh ($0 CPU) | cohesive_wide_v2 (6v + bridge gap-close) | -13.1 cm blind LiDAR vs v1 (1.674 -> 1.543 m) | 10.41% F1@50 (zero frustum dilation) | -198 fewer shards (75.6% main comp) |
| Track #3 Mesh ($0 CPU) | cohesive_wide_v1 (M17, 5v trunc) | -30.2 cm blind mesh LiDAR p50 (+10.10 Pareto) | NYPL 0.610 m · Guggenheim 0.498 m (w/ v2) | +27.5% main comp (79.6% w/ v2) |
| Track #3 Mesh ($0 CPU) | balanced_clean_v1 (M16 strict) | -3.1 cm recall, -9.2 cm precision | +1.0% F1@50, +0.3% F1@25 | +6.3% main comp |
| Track #3 Mesh ($0 CPU) | precision_cos_v1 (M06 alpha_cos) | -28.1 cm building precision | +1.9% F1@50, +1.0% F1@25 | Grazing-angle filtered |
For AI Agents
llms.txt— Machine-readable reference (CLI contracts, data schemas, coordinate conventions, cost guardrails, and engineering limits).SKILL.md— Drop-in Agent Skill instructions for Claude Code, OpenCode, and compatible harnesses.coevolution/cli.py— Unified entrypoint (doctor,test,bench,pipeline,sam3,hull,proposals,depth,bake,offline-v3,marso-handoff,reapply-guard) with$0offline defaults.
Repository Structure
llms.txt # Machine-readable agent index & CLI/data contracts
SKILL.md # Drop-in agent skill specification
coevolution/
cli.py # Unified agent & human CLI dispatcher
paths.py / paths.mjs # Zero-hardcoded-path environment & tool resolver
pipeline.py # Unified ClosedLoopController, offline DAG & certificate.json
instancerecon_volumes.py # Multi-view mask lifting, HiGHS MILP N=4 coloring, colored TSDF & Marching Cubes
nbv_planner.py # Next-Best-View adaptive camera planner
sculpt_backend.py # Universal watertight manifold3d CSG & mesh boolean sculptor
sam3_masks.py # Standalone local SAM 3 mask CLI (6 domain presets + whole-asset FP guard)
paint_registration.py # Coarse-to-fine similarity + ECC homography + DIS optical flow registration
bake_v2_mrf_poisson.py # Conformal xatlas UVs + float32 sparse Screened-Poisson UV baker
mujoco_support_audit.py # CoACD concave decomposition + MuJoCo 6-DOF gravity & cantilever physics audit
world_memory.py # Morton 3D occupancy & RESERVED_CLEAR collision memory
bench_multidomain_gt.py # Bundled $0 5-domain synthetic ground-truth benchmark
visual_hull_3d.py # 3D visual hull CLI (--backend instancerecon --num-volumes 4 --fine-refine)
discover_proposals.py # Grounded 3D proposal discovery (--clustering instancerecon --sam3-masks)
local_mapanything.py # Calibrated MapAnything metric depth, consistency & sculpting guides
blender_backend.py # Persistent Blender 5.x worker backend & Catmull-Clark SDS primitives
marso_handoff.py # Stage 3 Blender -> Marso 4K PBR handoff, interior culler & drift guards
splat_train_recipe.py # Colab-autoresearched 2DGS metric training recipes (metric_lidar_v5 default) & guardrails
splat_postprocess.py # Colab-autoresearched 2DGS planar manifold snapper (pareto_v2), SH1 denoiser & Morton quantizer
splat_mesh_extract.py # Colored multi-view TSDF (cohesive_wide_v2), interior hole-filling & binary colored PLY/OBJ export
splat_to_marso.py # Turnkey $0 2DGS -> C++17 RGB+depth -> Watertight Stage-2 Blend -> Stage-3 Marso bridge
sparse_tsdf_cinema.py # $0 C++17 10-22 cm sparse 8x8x8 TSDF + bilateral normal filter + direct 4K soft-max PBR & AgX showcase
agent_sculptor.py # Autonomous parametric mesh sculptor
run_coevolution_v3.mjs # End-to-end generation loop orchestrator
village_aerial/ # Multi-building alpine village generator & Fast-SDF GI baker
test_*.py # Pytest + Hypothesis unit, geometry, physics & parity test suites
src/coevolution/ # Three.js / WebGL capture & geometry harness
docs/assets/ # Curated renders & pipeline figures
Companion Texturer
For standalone multi-view PBR mesh texturing with view-aware atlases, silhouette bleed guarding, and real-time walkthroughs, see Potemkin3D.
License
Apache-2.0