Skip to content
forked from patch-gg/trompe

About

AI-painted 3D environments and real-time walkthroughs, extending Patch Trompe with view-aware atlases, geometry checks and surface relief.

Resources

Stars

45 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

51 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Potemkin 3D

AI-painted environments with view-aware texture atlases, surface relief, and real-time walkthroughs.

Potemkin 3D extends Trompe by Patch. Start with ordinary UV-mapped geometry, paint camera views with image models, project those images back onto the mesh, and explore the result under real-time lighting. Potemkin adds tools for texture density, geometry fidelity, material response, and close-up presentation, with a Luxor temple and a New York loft as included scenes.

Luxor temple rendered in Potemkin 3D: carved sandstone pylons, seated statues, and sunlight through dust

A screenshot of the included Luxor WebGL viewer, with the controls hidden. The geometry is a procedural interpretation of Luxor Temple; the painted inscriptions and relief are generated imagery, not an archaeological reconstruction.

Try the included scenes

No API key or image generation is needed to view the baked scenes. With Python 3 installed:

git clone https://github.com/wrong-nebula/potemkin3D.git
cd potemkin3D
python3 -m http.server 8080 --bind 127.0.0.1 --directory deploy/potemkin3d

Open http://localhost:8080/ for the loft or http://localhost:8080/luxor/ for the temple. Serve that directory as the website root so the shared scene menu works.

In Luxor, use WASD to walk, Shift to run, and click or drag to look. 1–5 select viewpoints. P toggles carved depth, J cavity shadows, O weathering, U sand and dust, R light shafts, and I (or ?) opens the contextual Field Notes & Provenance drawer. The on-screen controls list the other effects.

CLI, MCP and tutorial

The project includes a JSON/ANSI CLI (--json, --ansi, --markdown) and a stdio MCP server for agents. Both expose the same validated schemas, persistent background jobs, streaming Markdown + Pele Mermaid reports (potemkin report, potemkin docs), cancellation, artifact manifests, live Blender/Unreal MCP push (dcc-sync / potemkin_dcc_sync), and a budgeted Planner → Actor → Critic session loop (agent-plan → agent-approve → agent-act) with human spend gating, 3DGS outlier-view detection, episodic run traces and cross-session repair memory. Scene inspection, camera planning, screenshots, painting, consolidation, UV refinement, material maps, validation and PNG/KTX2 GLB export are available without browser clicking.

npm ci
npx playwright install chromium
node automation/cli.mjs doctor --json
node automation/cli.mjs screenshot --scene luxor --wait --json
node automation/cli.mjs job-start --input @examples/automation/free-luxor.json --wait --ansi
node automation/cli.mjs dcc-sync --target blender --glb samples/courtyard.glb --dry-run --json

Follow the tutorial for a free Luxor walkthrough, MCP client setup, custom geometry, and optional paid generation/resuming. The automation reference documents every command and the machine-readable contracts. Paid operations require explicit allowPaid:true; the free example uses clay renders to exercise the GPU pipeline.

What comes from Trompe, and what Potemkin adds

The foundation is Patch's work: walkable-camera planning, clay and geometry-buffer renders, material-aware prompts, sequential view painting, seam compositing, quality-weighted UV projection, relighting, and GLB export. Potemkin is a derivative of that engine, not an independently invented replacement.

This comparison is against public upstream ba9ef76, checked on 2026-11-17. Potemkin retains upstream Git history; subsequent local development is published as a consolidated commit under wrong-nebula. The following are implementation differences, not a claim of universal quality or speed improvements.

Area Public Trompe baseline Potemkin additions and intended benefit
Texture allocation Uses the model's existing UV layout Automatic xatlas unwrap with hand-authored UV seam preservation (partitionUvCharts); visibility-, distance-, cavity- and bot-path-weighted repacking; multi-page atlases and island splitting.
Camera selection Greedy coverage of reachable surfaces, roofs, aerial views and holes Geodesic + Fisher adaptive probe-and-select (--adaptive), AVM-style hero-first autoregressive 3D reprojection rings + single-image pixel lock (--autoregressive), walkable nav-graph bot gaze importance (--paths), and discrete-asset Fibonacci/turntable --mode object.
Geometry & seam fidelity Prompts constrain the image model to the blockout; hard winner projection SAM + MoGe fidelity checks, cavity/ridge wear conditioning, MRF view-label cuts, tangent-flow + Screened-Poisson stitching (--consolidate), Joint Bilateral Upsampling (jbu.ts), 3D-seam UV inpainting & delighting (--uv-refine), plus optional local --texfusion, gaussianField and --sds-polish.
Repairs Fill unpainted holes Multi-metric Critic (critic.ts) with 3DGS outlier-view gating, AVM pose-ranked co-visibility cleanup for unpainted/grazing reveals (--covis-cleanup / covisCleanup), targeted 3D repair boxes, isolated part/prop passes, and local same-part sliver fills.
Floors Ground mainly painted through scene views Dedicated overhead passes, world-space material tiling and an optional protected detail layer address grazing-angle blur and inconsistent scale.
Materials & AO Painted color with real-time scene lighting Intrinsic $0 or PATINA height/normal/roughness/metallic/edge-wear maps, hybrid Fast-SDF-AO (fast-sdf-ao.ts) with bent_normal.png directional sky & Jimenez cone specular occlusion, and 8 material presets.
Export & DCC Uncompressed PNG glTF export Optional UASTC + RFC 8878 Zstandard KHR_texture_basisu KTX2 GLBs (format: 'ktx2', 4× lower GPU VRAM, >3× smaller disk size) streamed via KTX2Loader, plus live blender-mcp / unreal-mcp push (dcc-sync).
Providers & cost Cloud fal image endpoints Pluggable fal + $0 loopback local router (ComfyUI, diffusers, Hunyuan3D-Paint), hybrid --local-tail routing, and human-gated dollar budgets.
Reliability Saves a run when it completes Incremental per-view saves, resumable runs and browser crash recovery retain completed generation work.
Automation & reports Browser API and individual scripts Shared CLI/MCP schemas, persistent jobs, budgeted Planner → Actor → Critic loop, and streaming @pierre/words Markdown, Pele Mermaid, HTML & ANSI reports.
Presentation Authoring viewer and export @ui-sdk Studio with 3D click-to-pin notes & live Monitor dock, capsule-based walking, contextual Notes · I walkthrough drawer, and the Luxor POM/weathering/camera-effects viewer.

Some options trade quality for memory, cost, or complexity. Surface-directed camera planning is experimental and is not always better. More atlas pages cannot recover detail absent from the generated views. The earlier measured examples in ENGINE.md are historical experiments, not a fresh benchmark against today's upstream or current model pricing.

How the techniques fit together

1. Plan from where the scene will be seen

The engine samples walkable ground, places eye-height cameras, checks visibility, and selects overlapping views. Geometry buffers record surface position, normals, UVs and part identity. Additional cameras can cover roofs, ground and holes. The optional sharpness objective favors cameras that improve projected sampling density instead of simply covering more texels, while --adaptive (adaptive-plan.ts) runs iterative probe-and-select refinement weighted by surface geodesic distance from player spots and the geometry prepasses, using a concave Fisher-style resolution objective, adaptive camera lenses (62°–86°) and a spend/bottleneck report. For standalone props, weapons, characters and vehicles without a walkable floor (--mode object, or automatic under --mode auto), object-plan.ts switches to an enclosing Fibonacci sphere, an oblique turntable ring, and close-up probes on high convex curvature, pockets and user-tagged parts (--focus), paired with hard-surface, metal, fabric and organic material presets.

2. Spend texture resolution on useful surfaces

unwrap.ts checks a file's UVs before anything else. When they are missing, collapsed, tiling or overlapping (any of these on over 2% of the surface or texture), it makes new ones with xatlas in a worker. Each part becomes charts of its own at one texel density across the level. --unwrap always unwraps regardless and --unwrap off keeps the file's UVs. layout.ts then repacks the UV islands, whichever made them. The seen layout reduces the allocation for hidden surfaces. The near layout also weights islands by player distance and joins compatible faces into strips. With --cavity (for instance --cavity 0.7), surface-weights.ts estimates each face's short-range openness and shrinks islands tucked into creases, slots or recesses; --weights runs all four geometry prepasses (openness, convex normal-cycle curvature, static light and semantic class) and --paths (player-paths.ts) bakes a walkable nav-graph and simulates bot walks + frustum gaze rays to weight UV island sizing, camera selection and repair priority, with false-colour debug overlays in the viewer. Multi-page packing divides a large scene among several atlases, keeping same-class islands together and cutting oversized islands when necessary while retaining a consistent scale across pages.

3. Paint views, preserve structure, and project

Image models receive a clay/state render, material instructions, part names and optional reference images — routed per job through either hosted fal endpoints or --provider local (local.ts / router.ts: ComfyUI FLUX multi-view/inpaint workflows, diffusers HTTP servers and Hunyuan3D-Paint at $0 paint cost, with optional cloud fallback, --local-tail hybrid tail routing, and --texfusion Sequential Interlaced Multiview Sampling across shared UV latents). Earlier paint supplies context for later views. Compositing preserves known pixels and adjusts color drift at seams. Geometry checks reject or retry regions where the model replaces a surface. Projection favors views with better angle and distance, while --consolidate (consolidate.ts) back-projects overlapping views with cosθ/d × depth-continuity confidence (and optional tangent-plane bilateral soft back-projection), solves an MRF view-label assignment along low-discrepancy contours, registers shifted surface detail along a high-pass tangent flow field, and runs a multigrid Screened-Poisson stitch with Geometry-Guided Joint Bilateral Upsampling (jbu.ts) to remove --parallel view seams without extra model calls. --uv-refine (uv-refine.ts) then performs Paint3D-style coarse-to-fine UV-space inpainting conditioned on the 3D position/normal atlases across UV chart cuts, removes residual baked directional shading so textures relight cleanly, and gates bilateral HD sharpening (and optional --sds-polish hero Score Distillation) by surface and player-path importance. Cleanup and part-specific passes concentrate additional calls on remaining defects, and a final local color fill covers otherwise unreachable slivers.

4. Separate painted color from surface response

The pipeline aims for approximately unlit color by painting under overcast lighting (or stripping residual shading via --uv-refine). pbr.ts and aligned-maps.ts produce aligned height (for POM), refined tangent normals, roughness, metallic and convex-edge wear channels — either via a $0 albedo-and-geometry intrinsic decomposition (--pbr-mode intrinsic, automatic under --provider local) or fused with hosted PATINA predictions — and export both packed glTF ORM (Joint-Bilateral-Upsampled across creases when AO is baked at reduced resolution) and separate linear maps alongside hybrid Fast-SDF-AO (fast-sdf-ao.ts, Contact BVH + 1-Lipschitz R16F SDF + bent_normal.png directional sky & specular occlusion in viewer.ts). export.ts writes standard PNG GLBs or UASTC + Zstandard KHR_texture_basisu KTX2 GLBs (format: 'ktx2', 4× lower GPU VRAM and >3× smaller disk payloads), with one-click live Blender/Unreal push via dcc-sync. Presets leave the painted atlas intact. See material maps for data conventions, persistence and limitations.

5. Make Luxor's carving read at close range

The Luxor viewer uses parallax occlusion mapping (POM): the shader traces through a dedicated height texture to offset the apparent surface intersection. Color and material channels use the same displaced UVs. A second trace adds self-shadowing inside recesses. Island-boundary masks keep traces from sampling a neighboring packed surface; relief fades with distance and extreme grazing angles. This changes surface appearance, not mesh silhouettes, collision or cast-shadow geometry.

Low-resolution geometry/textures load first, then high-resolution material pages stream in. Color, normals and height switch together. Procedural edge wear, stone weathering, sand, airborne dust and light shafts build on the same scene. Camera effects include exposure adaptation, bloom, lens artifacts, depth of field, motion blur and color grading. These are adjustable presentation effects, not evidence of recovered physical detail.

The editable implementation is in experiments/luxor-view/, including POM and height-map details.

Author a scene

Use a current Node.js version supported by the pinned Vite dependencies, npm, and a browser with WebGL. GPU acceleration is recommended; the geometry checker can also use WebGPU.

npm ci
npx playwright install chromium  # needed for headless scripts
cp .env.example .env.local       # add your own FAL_KEY for generation
npm run dev

Open the URL printed by Vite, normally http://localhost:5178. Choose a sample or import a Y-up GLB (missing or stacked UVs unwrap automatically while preserving valid hand-authored charts), describe its materials, optionally click 3D surfaces with Pin note (Look tab) to attach localized art-direction instructions, plan cameras, and paint textures. On the Critic and Material tabs you can run multi-view seam consolidation, UV delighting/inpainting, 3DGS consistency checks, SDS hero polish, Fast-SDF-AO + intrinsic/PATINA PBR baking, export PNG or compressed KTX2 (BasisU) GLBs, and push PBR bundles directly to Blender or Unreal (Sync to DCC). Named material parts improve prompts. The local fal proxy reads FAL_KEY server-side, while --provider local routes to loopback ComfyUI/diffusers/Hunyuan3D-Paint at $0.

A Luxor planning example (or add --consolidate --uv-refine --ao --pbr when running):

node scripts/texture.mjs --look samples/luxor.look.json --id luxor-new \
  --first h3 --fill h3 --views 64 --cleanup 8 --consolidate --uv-refine --finish \
  --layout near --weights --paths --pages 4 --atlas 4096 --plan-only

Review the plan before removing --plan-only to start paid generation. The public look file uses only the reference photos included with known licenses. It therefore differs from the historical input set used for the bundled scene. See ENGINE.md for all CLI options and generation workflows.

Build and check

npm test
npm run build          # type-check and build the authoring application into dist/
npm run build:scenes   # rebuild both viewers using the included baked assets into dist-potemkin/
python3 -m http.server 8080 --bind 127.0.0.1 --directory dist-potemkin

The scene build uses existing GLBs and textures and makes no model calls. It keeps the source assets in deploy/potemkin3d/. Editing Luxor's viewer code is independent of regenerating its painted textures.

Height-processing tests additionally require NumPy and Pillow:

python3 -m unittest discover -s test -p 'height_maps_test.py'

Project map

Location Contents
src/core/ Planning (planner.ts, adaptive-plan.ts, object-plan.ts, player-paths.ts), geometry prepasses (surface-weights.ts), fidelity checks, UV unwrap/layout, MRF/Poisson/JBU consolidation (consolidate.ts, jbu.ts, uv-refine.ts), Fast-SDF-AO (fast-sdf-ao.ts, ao.ts), PBR maps, local spikes (texfusion.ts, gaussian-field.ts), and PNG/KTX2+Zstd export (export.ts, ktx2.ts, zstd.ts)
src/providers/ fal + loopback local (ComfyUI, diffusers, Hunyuan3D-Paint) model router and in-browser SAM segmentation
src/ui/, src/session.ts, src/api.ts @ui-sdk Studio workspace, streaming @pierre/words + Pele Mermaid views, session state, and window.trompe / window.agent APIs
automation/ Shared Zod CLI/MCP schemas, detached job worker, budgeted Planner → Actor → Critic agent (agent.mjs), Blender/Unreal MCP sync (dcc.mjs), and streaming Markdown/HTML/ANSI reports (words.mjs)
src/demo/ Loft walkthrough (loftwalk.js), contextual Notes · I drawer (walk-notes.js), and shared camera-effect shaders
experiments/luxor-view/ Editable temple viewer, POM, KTX2Loader + texture LOD streaming, weathering and height processing
experiments/material-lab/, experiments/benchmark/ Material experiments and comparison tooling
samples/, references/ Procedural geometry, look files and attributed photo references
deploy/potemkin3d/ Complete baked loft/Luxor site and its shared menu
scripts/, test/ CLI runners, measurement/validation scripts, scene builder, and unit/E2E tests

Limitations and provenance

  • Automatic unwrapping (unwrap.ts) preserves valid hand-authored UV charts (partitionUvCharts, $\sigma_{\max}/\sigma_{\min} \le 2.5$) on partially unwrapped GLBs while running xatlas on missing, tiling or stacked parts; chart importance scaling happens in the subsequent seen / near repacking stage.
  • Generated textures can contain hallucinated inscriptions, inconsistent details, residual lighting and seams. A fidelity check reduces mistakes without guaranteeing accuracy.
  • Atlas size, page count, POM and post-processing all consume GPU resources. Performance depends on resolution, hardware and enabled effects.
  • Some runtime detail layers are shader effects and are not baked into a plain GLB export.
  • The original full generation runs are not included. Finished assets are available, but exact texture regeneration is not reproducible from this repository alone. The viewer source was recovered from retained local Git trees; PROVENANCE.md records the source hashes.
  • Experimental tools may require separately generated runs or additional Python dependencies. The README quick-start uses the self-contained baked scenes.

License and credits

The code is Apache-2.0, retaining Trompe's license. See LICENSE, NOTICE, and THIRD_PARTY_NOTICES.md. Modified upstream source files identify the Potemkin changes. Patch's trademarks and branding remain Patch's; this project is not an official Patch release.

Trompe was made by Patch. Potemkin's additions are maintained here by wrong-nebula. The engine uses Three.js, three-mesh-bvh, xatlas, @ui-sdk, @pierre/words, Pele, Vite, Playwright, Transformers.js, Fast-SDF-AO, and model services through fal or local loopback backends. Individual models and services retain their own terms.

Photographs and fonts have separate licenses and attribution. The Luxor reference credits identify the included CC BY-SA photos, cropping and tone adjustments. A photo whose source/license was unknown and the hangar's film-reference images are excluded. Scene media and screenshot licensing are described in ASSET_LICENSES.md; the code license does not relicense third-party material.

About

AI-painted 3D environments and real-time walkthroughs, extending Patch Trompe with view-aware atlases, geometry checks and surface relief.

Resources

Stars

45 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages