Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Image to 3D: Refine detail with Hi3D 1.0 on your GPU, and a print-ready STL / 3MF export

Claude975b2ea5b73a
diff --git a/docs/research/hi3d-refine.json b/docs/research/hi3d-refine.json
new file mode 100644
index 00000000..fd5f5b1f
--- /dev/null
+++ b/docs/research/hi3d-refine.json
@@ -0,0 +1,111 @@
+{
+ "asOf": "2026-11-02",
+ "scope": "Hi3D v1.0 (Sparc3D's refinement stage, released open): what it is, its weights, licence, hardware, ComfyUI support and hosting, read for package hi3d-refine.",
+ "sources": {
+ "readme": "https://github.com/hi3d-official/Hi3Dv1.0 README.md (copy read as data: /home/user/ext/hi3d/README.md)",
+ "licence": "https://github.com/hi3d-official/Hi3Dv1.0 LICENSE (copy read as data: /home/user/ext/hi3d/LICENSE)",
+ "weights": "https://huggingface.co/hi3d-official/Hi3Dv1.0 (API read 2026-11-02)",
+ "site": "https://www.hi3d.ai/hi3d-1-0-open-source"
+ },
+ "model": {
+ "name": "Hi3D v1.0",
+ "released": "2026-10-23",
+ "releasedNote": "The README says 'Released on October 23, 2026'; the weights' last commit is 2026-10-23T16:04:31Z. new-models-10 had 10-16 (corrected here).",
+ "what": "Refines a coarse mesh into high-resolution geometry, conditioned on a reference image of the same object (README L15). It does not make a mesh from nothing: the README's end-to-end demo makes the coarse mesh with Hunyuan3D-2 mini (L170-185).",
+ "output": "Geometry only, batch size one: no textures, materials or vertex colours; recentred and normalised to unit maximum radius, so input world coordinates and absolute scale are not preserved (L189). Not guaranteed watertight or printable.",
+ "resolutions": [512, 1024, 1536],
+ "passes": { "512": 1, "1024": 2, "1536": 3 },
+ "passesNote": "Pass 1: 64^3 structure / 512^3 extraction grid with transformer_512; pass 2: 128^3 / 1024^3 with transformer_1024; pass 3: 192^3 / 1536^3 with transformer_1024 (L27-33). Nominal sparse grids, not a triangle count.",
+ "stepsPerPass": 25,
+ "encoders": "facebook/dinov2-large and openai/clip-vit-large-patch14, loaded separately on first use (L96).",
+ "cpuPath": false,
+ "offload": "Optional Accelerate sequential CPU offload (enable_sequential_cpu_offload); it does not establish a minimum GPU memory (L121-130).",
+ "failure": "A request that cannot reach the target resolution raises instead of silently returning a lower one (L191)."
+ },
+ "weights": {
+ "repo": "hi3d-official/Hi3Dv1.0",
+ "revision": "d502e938cbedc6e87aba8884614c5ca6d177a4b6",
+ "format": "safetensors + JSON; the loader neither executes repository Python nor unpickles (L94)",
+ "files": [
+ { "path": "transformer_512/model.safetensors", "bytes": 3675679280, "sha256": "8ba88311dccf23463c6e10dd0d3bd5e0c5c35d1608c6f466413b6428b5ad8e56" },
+ { "path": "transformer_1024/model.safetensors", "bytes": 3675679280, "sha256": "a2ca5e44dde51cacecd59b42fceeb5f14e75d55e6dd047337752c4e6f281008c" },
+ { "path": "vae/model.safetensors", "bytes": 376629712, "sha256": "605d207c77f8db0b33c567a5861252f0090cf3c3604dfda1cfee09e8f0b53f3e" },
+ { "path": "model_index.json", "bytes": 224 },
+ { "path": "scheduler/scheduler_config.json", "bytes": 127 },
+ { "path": "vae/config.json", "bytes": 131 },
+ { "path": "transformer_512/config.json", "bytes": 1336 },
+ { "path": "transformer_1024/config.json", "bytes": 1337 }
+ ],
+ "totalBytes": 7727990432,
+ "encoders": [
+ { "repo": "facebook/dinov2-large", "revision": "47b73eefe95e8d44ec3623f8890bd894b6ea2d6c", "path": "model.safetensors", "bytes": 1217522888, "sha256": "399fba97a95f22c36834418bc69373364a99af3a1153da1c0fb31db567c92e23", "licence": "Apache-2.0" },
+ { "repo": "openai/clip-vit-large-patch14", "revision": "32bd64288804d66eefd0ccbe215aa642df71cc41", "path": "model.safetensors", "bytes": 1710540580, "sha256": "a2bf730a0c7debf160f7a6b50b3aaf3703e7e88ac73de7a314903141db026dcb", "licence": "MIT (OpenAI CLIP)" }
+ ],
+ "totalWithEncodersBytes": 10656053900,
+ "note": "The brief's 7.74 GB is the three safetensors (7.728 GB); with the two encoders the open route downloads 10.66 GB. t8star/Hi3d-Comfy at 6ae7235d5f03857713ccdcb717a22b16f483aa43 repackages the same files (identical SHA-256) under hi3d/, dino/ and clip/."
+ },
+ "requirements": {
+ "official": "Linux, Python 3.10, an NVIDIA GPU of compute capability 8.0+ (Ampere or newer), a CUDA toolkit 12.0-12.5 matching torch; measured with torch 2.5.0+cu124, CUDA 12.4.131, flash-attn 2.7.4.post1, spconv-cu120 2.3.6, on a 96 GB H20. 1536 validated only on that GPU; smaller cards not established (README L60, L75).",
+ "flashAttn": "flash-attn has no fallback attention path in the official code (L191).",
+ "comfyPack": "T8's pack (below) keeps ComfyUI's own torch and adds an SDPA attention adapter (the Hi3D Model Loader's attention: sdpa | flash); its requirements pin spconv-cu126 2.3.8 and triton 3.3-3.x. Tested by its author on Windows, RTX 5090 Laptop 24 GB, 512 to 1536; lower-VRAM GPUs not validated."
+ },
+ "licence": {
+ "name": "Hi3D Open License Agreement Version 1.0",
+ "licensor": "OCEANO HK HOLDING LIMITED",
+ "commercial": "Permitted (Section 2.1), subject to Sections 5-8.",
+ "scale": "If a related product or service exceeds 200,000 monthly active users or reaches USD 1,000,000 monthly revenue, notify the licensor and apply for a separate written licence within 60 days (Sections 5.1-5.2).",
+ "branding": "Commercial integrations must display 'Powered by Hi3D 1.0' with reasonable prominence, in the interface, on an About page or in acknowledgements, linking to http://hi3d.ai/ where a link is possible (Section 7, Schedule 2).",
+ "brandingUrl": "http://hi3d.ai/",
+ "outputs": "Outputs that contain no Hi3D Materials can be used, sold and distributed without the branding, NOTICE or scale obligations (Section 8; README).",
+ "distribution": "Recipients of the weights get the Agreement's full text or a link to it, and the NOTICE text (Sections 3, 9).",
+ "aup": "Schedule 1 Acceptable Use Policy applies.",
+ "class": "conditions"
+ },
+ "comfyui": {
+ "nativeSupport": false,
+ "note": "comfyui-oss-4 (2026-10-22) found no ComfyUI support; community packs appeared from 2026-10-23.",
+ "packs": [
+ {
+ "name": "Comfyui-Hi3d-T8",
+ "repo": "https://github.com/T8mars/Comfyui-Hi3d-T8",
+ "commit": "73848490976e6a9b0c735ce02984c03866a495e7",
+ "version": "0.5.1",
+ "registry": "hi3d-t8 (publisher t8star)",
+ "licence": "MIT integration code; vendored Hi3D code and weights under the Hi3D Open License 1.0",
+ "nodes": {
+ "Hi3DModelLoader": "model_root (empty: ComfyUI/models/Hi3D with hi3d/, dino/, clip/), cpu_offload, attention sdpa | flash, keep_model_loaded, download_missing -> HI3D_MODEL",
+ "Hi3DLoadMesh": "mesh_file: a .glb / .ply / .stl / .npz under ComfyUI's input folder -> MESH",
+ "Hi3DRefine": "model, image, mesh, resolution 512 | 1024 | 1536, steps 1-100 (25), seed, optional mask -> refined_mesh MESH, report_json STRING"
+ },
+ "output": "Core SaveGLB saves the refined MESH as a self-contained binary GLB.",
+ "chosen": true,
+ "why": "In the ComfyUI Registry, native MESH in and out (core SaveGLB writes the GLB, so Fuobe's finish takes it), mesh input from ComfyUI's input folder (Fuobe uploads the coarse GLB like any input), official source pinned inside, pinned core weights with SHA-256. Its separate Windows workbench is not used."
+ },
+ { "name": "ComfyUI-Hi3D-Refinement", "repo": "https://github.com/wadi-k/ComfyUI-Hi3D-Refinement", "commit": "2c77b8d6b8f3a91a8d32be6f37fb2d44b6c1f53d", "licence": "Apache-2.0 code", "chosen": false, "note": "One node with model pickers from diffusion_models/vae; can run Hi3D in a separate venv (HI3D_PYTHON). Its example shows TRELLIS.2's texture stage baked onto the refined mesh with a TRELLIS.2 pack (BakeTextureFromVoxel), not core." },
+ { "name": "Rizzlord/ComfyUI-Hi3D", "repo": "https://github.com/Rizzlord/ComfyUI-Hi3D", "chosen": false },
+ { "name": "thatname/ComfyUI-Hi3D", "repo": "https://github.com/thatname/ComfyUI-Hi3D", "chosen": false }
+ ]
+ },
+ "texture": {
+ "verdict": "No texture-on-an-outside-mesh step is possible with what Fuobe installs: the refined mesh ships as geometry only, labelled so.",
+ "checked": [
+ "Core ComfyUI's TRELLIS.2 texture stage (template 3d_pixal3d_trellis2_image_to_model) textures the shape latent the same graph decoded: its texture sampler takes the sparse structure of its own shape, not a mesh; core has no mesh-to-voxel encoder for an outside mesh.",
+ "Pixal3D's graph is the same TRELLIS.2 pipeline with Pixal3D conditioning: same limit.",
+ "Hunyuan3D 2.1 in core is shape only (no Hunyuan3D-Paint nodes)."
+ ],
+ "ownerStep": "To texture the refined mesh, install a mesh-conditioned texture pack: Hunyuan3D-Paint 2.1 (e.g. visualbruno's ComfyUI-Hunyuan3d-2-1 or kijai's ComfyUI-Hunyuan3DWrapper), or a TRELLIS.2 pack with an outside-mesh voxel bake (the wadi-k example uses one). Each needs its own review and licence record (Hunyuan3D-Paint 2.1 excludes the EU, UK and South Korea)."
+ },
+ "hosted": {
+ "open": [],
+ "checked": "2026-11-02: fal model search for 'hi3d', 'sparc3d', 'mesh refine': only hitem3d/hi3d/* (Hitem3D's own closed API: image-to-3d, multi-view-to-3d v3.0, texture, split, relief, multicolor; proxy, none takes a coarse mesh). Replicate search: nothing.",
+ "verdict": "Nobody hosts the open Hi3D v1.0 refine. Hitem3D's API is a different, closed product (v2/v3) and is not used. Hi3D refine is open-engine only."
+ },
+ "fuobe": {
+ "workflow": "mesh-refine-hi3d",
+ "model": "oss-hi3d-refine",
+ "op": "refine-3d",
+ "graph": "LoadImage -> core RemoveBackground (BiRefNet) mask; Hi3DLoadMesh (the coarse GLB, uploaded as an input) ; Hi3DModelLoader (models/Hi3D, cpu_offload on, flash attention) -> Hi3DRefine (resolution, 25 steps, seed, mask) -> SaveGLB",
+ "chain": "Image to 3D's 'Refine detail' runs the picked open model, then the refine step on its GLB (chain slot model3d) with the same photo.",
+ "print": "The Print-ready export (STL / 3MF) is made in the browser from the finished GLB: watertight check, scaled to the height the user sets (Hi3D normalises size)."
+ }
+}
diff --git a/scripts/comfy/build-library.mjs b/scripts/comfy/build-library.mjs
index 77fe5d6b..d67c7619 100644
--- a/scripts/comfy/build-library.mjs
+++ b/scripts/comfy/build-library.mjs
@@ -132,6 +132,8 @@ export const BINDING_KEYS = new Set([
'maskPrompt', 'maskGrow', 'skipPass2', 'supersample', 'zoomStart', 'zoomEnd', 'panStartX', 'panStartY', 'panEndX', 'panEndY',
'easeInOut', 'chunkFrames', 'crossfade', 'headroomDb', 'fadeCurve', 'format', 'profile', 'peakNits', 'resolutionLevel', 'fovX',
'decimation', 'cutout', 'numGaussians', 'splatFormat', 'orbitFrames', 'frameWidth',
+ // hi3d-refine (see library.spec.mjs header)
+ 'model3d', 'meshResolution', 'cpuOffload',
// round 4 (engine seams, see library.spec.mjs header)
'curveMode', 'filterSpeckle', 'colorPrecision',
// remove-object package (round 4)
@@ -327,7 +329,7 @@ async function main() {
}
// Every media input must be bound, otherwise the workflow references a template example asset.
- const FILE_INPUTS = { LoadImage: 'image', LoadImageMask: 'image', LoadVideo: 'file', VHS_LoadVideo: 'video', LoadAudio: 'audio', VHS_LoadAudioUpload: 'audio', AUSBOSS_NODES_ImageCropRotatePad: 'image' };
+ const FILE_INPUTS = { LoadImage: 'image', LoadImageMask: 'image', LoadVideo: 'file', VHS_LoadVideo: 'video', LoadAudio: 'audio', VHS_LoadAudioUpload: 'audio', AUSBOSS_NODES_ImageCropRotatePad: 'image', Hi3DLoadMesh: 'mesh_file' };
const boundTargets = new Set(Object.values(bindings).flat().map((t) => `${t.node}.${t.input}`));
for (const [nid, n] of Object.entries(graph)) {
const inp = FILE_INPUTS[n.class_type];
diff --git a/scripts/comfy/hand-built/mesh-refine-hi3d.json b/scripts/comfy/hand-built/mesh-refine-hi3d.json
new file mode 100644
index 00000000..ad9f2b14
--- /dev/null
+++ b/scripts/comfy/hand-built/mesh-refine-hi3d.json
@@ -0,0 +1,98 @@
+{
+ "1": {
+ "inputs": {
+ "model_root": "",
+ "cpu_offload": true,
+ "attention": "flash",
+ "keep_model_loaded": false,
+ "download_missing": false
+ },
+ "class_type": "Hi3DModelLoader",
+ "_meta": {
+ "title": "Hi3D Model Loader"
+ }
+ },
+ "2": {
+ "inputs": {
+ "image": "product.png"
+ },
+ "class_type": "LoadImage",
+ "_meta": {
+ "title": "Load Image"
+ }
+ },
+ "3": {
+ "inputs": {
+ "bg_removal_name": "birefnet.safetensors"
+ },
+ "class_type": "LoadBackgroundRemovalModel",
+ "_meta": {
+ "title": "Load Background Removal Model"
+ }
+ },
+ "4": {
+ "inputs": {
+ "bg_removal_model": [
+ "3",
+ 0
+ ],
+ "image": [
+ "2",
+ 0
+ ]
+ },
+ "class_type": "RemoveBackground",
+ "_meta": {
+ "title": "Remove Background"
+ }
+ },
+ "5": {
+ "inputs": {
+ "mesh_file": "coarse.glb"
+ },
+ "class_type": "Hi3DLoadMesh",
+ "_meta": {
+ "title": "Hi3D Load Mesh"
+ }
+ },
+ "6": {
+ "inputs": {
+ "resolution": 1024,
+ "steps": 25,
+ "seed": 0,
+ "model": [
+ "1",
+ 0
+ ],
+ "image": [
+ "2",
+ 0
+ ],
+ "mesh": [
+ "5",
+ 0
+ ],
+ "mask": [
+ "4",
+ 0
+ ]
+ },
+ "class_type": "Hi3DRefine",
+ "_meta": {
+ "title": "Hi3D Refine"
+ }
+ },
+ "7": {
+ "inputs": {
+ "filename_prefix": "fuobe/mesh-refine-hi3d",
+ "mesh": [
+ "6",
+ 0
+ ]
+ },
+ "class_type": "SaveGLB",
+ "_meta": {
+ "title": "Save GLB"
+ }
+ }
+}
diff --git a/scripts/comfy/install-comfyui.sh b/scripts/comfy/install-comfyui.sh
index 24afa21b..3ab8a1ad 100755
--- a/scripts/comfy/install-comfyui.sh
+++ b/scripts/comfy/install-comfyui.sh
@@ -127,6 +127,50 @@ if [ "${OPEN_H3_REGEN:-0}" = "1" ]; then
done
fi
+# Hi3D 1.0 mesh refinement (Image to 3D's "Refine detail", the mesh-refine-hi3d workflow; docs/research/hi3d-refine.json):
+# T8star's Comfyui-Hi3d-T8 (MIT code; the Hi3D code it vendors and the weights are under the Hi3D Open License 1.0, which
+# asks for "Powered by Hi3D 1.0" wherever its results show). Opt-in: HI3D=1. It needs an NVIDIA GPU of compute capability
+# 8.0+ (RTX 30 series / A-series or newer) and CUDA 12: its requirements.txt pins spconv-cu126 2.3.8 and triton, and keeps
+# ComfyUI's own torch. There is no CPU path. The weights (10.66 GB: Hi3D 7.73 GB, DINOv2-L 1.22 GB, CLIP ViT-L/14 1.71 GB)
+# go into models/Hi3D/{hi3d,dino,clip}/ at pinned revisions, each checked with sha256sum -c; HI3D_WEIGHTS=0 skips them.
+HI3D_REF="${HI3D_REF:-73848490976e6a9b0c735ce02984c03866a495e7}" # v0.5.1, 2026-10-26
+if [ "${HI3D:-0}" = "1" ]; then
+ dest="$COMFYUI_DIR/custom_nodes/Comfyui-Hi3d-T8"
+ if [ -d "$dest/.git" ] || git clone -q https://github.com/T8mars/Comfyui-Hi3d-T8 "$dest"; then
+ git -C "$dest" fetch -q --depth 1 origin "$HI3D_REF" 2>/dev/null || true
+ git -C "$dest" checkout -q "$HI3D_REF" 2>/dev/null || echo "warn: could not pin Comfyui-Hi3d-T8 to $HI3D_REF"
+ uv pip install --python "$PY" -r "$dest/requirements.txt" || echo "warn: Comfyui-Hi3d-T8's requirements did not install (it needs an NVIDIA GPU with CUDA 12)"
+ else
+ echo "warn: could not fetch Comfyui-Hi3d-T8"
+ fi
+ if [ "${HI3D_WEIGHTS:-1}" = "1" ]; then
+ HI3D_DIR="$COMFYUI_DIR/models/Hi3D"
+ for spec in "hi3d hi3d-official/Hi3Dv1.0 d502e938cbedc6e87aba8884614c5ca6d177a4b6 model_index.json scheduler/scheduler_config.json vae/config.json vae/model.safetensors transformer_512/config.json transformer_512/model.safetensors transformer_1024/config.json transformer_1024/model.safetensors" \
+ "dino facebook/dinov2-large 47b73eefe95e8d44ec3623f8890bd894b6ea2d6c config.json model.safetensors" \
+ "clip openai/clip-vit-large-patch14 32bd64288804d66eefd0ccbe215aa642df71cc41 config.json model.safetensors"; do
+ read -r sub repo rev files <<<"$spec"
+ for f in $files; do
+ [ -s "$HI3D_DIR/$sub/$f" ] && continue
+ mkdir -p "$(dirname "$HI3D_DIR/$sub/$f")"
+ if curl -fsSL --retry 3 -o "$HI3D_DIR/$sub/$f.part" "https://huggingface.co/$repo/resolve/$rev/$f"; then
+ mv "$HI3D_DIR/$sub/$f.part" "$HI3D_DIR/$sub/$f"
+ else
+ rm -f "$HI3D_DIR/$sub/$f.part"
+ echo "warn: could not download $repo/$f at $rev"
+ fi
+ done
+ done
+ (cd "$HI3D_DIR" && sha256sum -c --quiet <<'SHA'
+8ba88311dccf23463c6e10dd0d3bd5e0c5c35d1608c6f466413b6428b5ad8e56 hi3d/transformer_512/model.safetensors
+a2ca5e44dde51cacecd59b42fceeb5f14e75d55e6dd047337752c4e6f281008c hi3d/transformer_1024/model.safetensors
+605d207c77f8db0b33c567a5861252f0090cf3c3604dfda1cfee09e8f0b53f3e hi3d/vae/model.safetensors
+399fba97a95f22c36834418bc69373364a99af3a1153da1c0fb31db567c92e23 dino/model.safetensors
+a2bf730a0c7debf160f7a6b50b3aaf3703e7e88ac73de7a314903141db026dcb clip/model.safetensors
+SHA
+ ) || echo "warn: a Hi3D weight file is missing or failed its SHA-256 check (delete it from models/Hi3D and re-run)"
+ fi
+fi
+
# Fuobe's live edit nodes (fuobe_live.py, one file Fuobe ships, MIT): Live edit's loader, cached reference encode,
# crop, paste-back and socket save. Written from the copy in this checkout (src/lib/comfy-live-nodes.ts).
if command -v node >/dev/null 2>&1; then
diff --git a/scripts/comfy/library.spec.mjs b/scripts/comfy/library.spec.mjs
index 7029fe0f..5e07046f 100644
--- a/scripts/comfy/library.spec.mjs
+++ b/scripts/comfy/library.spec.mjs
@@ -120,6 +120,10 @@
// voiceDescription* (the voice in words: params.voiceDescription, op voice-design)
// voiceTranscript* (what the voice sample says: params.voiceTranscript, or a saved voice's line)
// device* (VoxCPM2's device combo: the server's first torch device, cuda | mps | cpu)
+// Keys added with Hi3D mesh refinement (hi3d-refine). * = the provider fills it:
+// model3d* (Hi3DLoadMesh: the coarse GLB, uploaded like any input: inputs.model3d)
+// meshResolution (Hi3DRefine resolution 512 | 1024 | 1536: params.extra.meshResolution)
+// cpuOffload (Hi3DModelLoader sequential CPU offload, on by default)
// Entry field requiredModels: files a loader reads by a name with no extension (DBSLoader's model folder), listed in the
// manifest like any model (KNOWN_MODELS keys are the path under the folder, e.g. 'DBS-BSRNN-DnR/model.safetensors'), so the
// Workflows page's presence check and its install commands cover them.
@@ -192,6 +196,10 @@ export const CUSTOM_NODE_REPOS = {
// Clean up voice (NVIDIA RE-USE): Fuobe's own pack, in this repository (comfy-nodes/ComfyUI-RE-USE), pinned at the commit
// that last changed it (tests/reuse-pack-pin.test.ts checks it). install-comfyui.sh copies it from the checkout.
'ComfyUI-RE-USE': 'https://github.com/workingprototype/Fuobe/tree/8cc0417b5cb8a603f06502d97d5c6d8c6035ea0d/comfy-nodes/ComfyUI-RE-USE',
+ // Hi3D 1.0 mesh refinement (hi3d-refine, docs/research/hi3d-refine.json): T8star's nodes (MIT code, vendored Hi3D code under
+ // the Hi3D Open License 1.0), v0.5.1. Opt-in in install-comfyui.sh (HI3D=1): it needs an Ampere-or-newer NVIDIA GPU and
+ // CUDA kernels (spconv, triton), so it is not on the validation server (mesh-refine-hi3d lists it with `packs`).
+ 'Comfyui-Hi3d-T8': 'https://github.com/T8mars/Comfyui-Hi3d-T8/tree/73848490976e6a9b0c735ce02984c03866a495e7',
// Live edit: Fuobe's own node file (src/lib/comfy-live-nodes.ts), shipped with Fuobe rather than cloned from a repo.
'fuobe-live': 'https://github.com/workingprototype/Fuobe',
// nm10-qwen21-fast: Qwen-Image 2.1 on a 16 GB card: recoilme's Zen Image Edit nodes (Qwen3.5-0.8B encoder + fusion adapter),
@@ -219,6 +227,7 @@ export const PACK_CLASSES = {
// MiniMax H3 video. The turbo classes need naming here: a ComfyUI with comfyui-workflow-encrypt reports that pack as their module.
'ComfyUI-MiniMax-H3-Turbo': /^MiniMaxH3Turbo(LoRA|Sampler)$/,
'plaguekind-nodes': /^H3(SLAAttention|AdaLNLoRAFix)$/,
+ 'Comfyui-Hi3d-T8': /^Hi3D(ModelLoader|LoadMesh|Refine)$/,
'ComfyUI-Open-H3-Regenerate': /^OpenH3(Regen(Lora|Sigmas|PrepareDraft|Upscale|RefineLatent|FastVAEDecode|Finish)|SaveRefinedLatent|LoadRefinedLatent|VideoToPrompt)$/,
Comfyui_Minimax_h3_latent_Upscaler: /^(MinimaxH3LatentUpscaler(3D|Node2D)|MMH3(TemporalSplitParamsV10|SpatialSplitParamsV10|SplitUpscale))$/,
'ComfyUI-RE-USE': /^REUSE(Loader|Enhance)$/,
@@ -386,6 +395,21 @@ export const KNOWN_MODELS = {
'DBS-BSRNN-DnR/config.json': { folder: 'dbs', url: 'https://huggingface.co/JusperLee/DBS-BSRNN-DnR/resolve/5af343f57f106fbb95efe8a60f1a3999eeb0aef8/config.json' },
'DBS-TIGER-DnR/model.safetensors': { folder: 'dbs', url: 'https://huggingface.co/JusperLee/DBS-TIGER-DnR/resolve/22da7d4cd3ea63f9365181008bff1c0d2ab6fb2b/model.safetensors' },
'DBS-TIGER-DnR/config.json': { folder: 'dbs', url: 'https://huggingface.co/JusperLee/DBS-TIGER-DnR/resolve/22da7d4cd3ea63f9365181008bff1c0d2ab6fb2b/config.json' },
+ // Hi3D 1.0 (hi3d-refine): T8's Hi3DModelLoader reads models/Hi3D/{hi3d,dino,clip}/ (the official layout, plus the two image
+ // encoders Hi3D loads on first use), so the keys are paths under that folder. Pinned revisions; the same files (identical SHA-256)
+ // as t8star/Hi3d-Comfy at 6ae7235d. install-comfyui.sh (HI3D=1) downloads them.
+ 'hi3d/model_index.json': { folder: 'Hi3D', url: 'https://huggingface.co/hi3d-official/Hi3Dv1.0/resolve/d502e938cbedc6e87aba8884614c5ca6d177a4b6/model_index.json' },
+ 'hi3d/scheduler/scheduler_config.json': { folder: 'Hi3D', url: 'https://huggingface.co/hi3d-official/Hi3Dv1.0/resolve/d502e938cbedc6e87aba8884614c5ca6d177a4b6/scheduler/scheduler_config.json' },
+ 'hi3d/vae/config.json': { folder: 'Hi3D', url: 'https://huggingface.co/hi3d-official/Hi3Dv1.0/resolve/d502e938cbedc6e87aba8884614c5ca6d177a4b6/vae/config.json' },
+ 'hi3d/vae/model.safetensors': { folder: 'Hi3D', url: 'https://huggingface.co/hi3d-official/Hi3Dv1.0/resolve/d502e938cbedc6e87aba8884614c5ca6d177a4b6/vae/model.safetensors' },
+ 'hi3d/transformer_512/config.json': { folder: 'Hi3D', url: 'https://huggingface.co/hi3d-official/Hi3Dv1.0/resolve/d502e938cbedc6e87aba8884614c5ca6d177a4b6/transformer_512/config.json' },
+ 'hi3d/transformer_512/model.safetensors': { folder: 'Hi3D', url: 'https://huggingface.co/hi3d-official/Hi3Dv1.0/resolve/d502e938cbedc6e87aba8884614c5ca6d177a4b6/transformer_512/model.safetensors' },
+ 'hi3d/transformer_1024/config.json': { folder: 'Hi3D', url: 'https://huggingface.co/hi3d-official/Hi3Dv1.0/resolve/d502e938cbedc6e87aba8884614c5ca6d177a4b6/transformer_1024/config.json' },
+ 'hi3d/transformer_1024/model.safetensors': { folder: 'Hi3D', url: 'https://huggingface.co/hi3d-official/Hi3Dv1.0/resolve/d502e938cbedc6e87aba8884614c5ca6d177a4b6/transformer_1024/model.safetensors' },
+ 'dino/config.json': { folder: 'Hi3D', url: 'https://huggingface.co/facebook/dinov2-large/resolve/47b73eefe95e8d44ec3623f8890bd894b6ea2d6c/config.json' },
+ 'dino/model.safetensors': { folder: 'Hi3D', url: 'https://huggingface.co/facebook/dinov2-large/resolve/47b73eefe95e8d44ec3623f8890bd894b6ea2d6c/model.safetensors' },
+ 'clip/config.json': { folder: 'Hi3D', url: 'https://huggingface.co/openai/clip-vit-large-patch14/resolve/32bd64288804d66eefd0ccbe215aa642df71cc41/config.json' },
+ 'clip/model.safetensors': { folder: 'Hi3D', url: 'https://huggingface.co/openai/clip-vit-large-patch14/resolve/32bd64288804d66eefd0ccbe215aa642df71cc41/model.safetensors' },
// RE-USE (Clean up voice): the NemotronLabs repositories only (OpenMDW-1.1; the older nvidia/RE-USE is non-commercial), at
// pinned revisions, named so both fit in models/reuse. install-comfyui.sh checks the SHA-256.
'NemotronLabs-RE-USE.safetensors': { folder: 'reuse', url: 'https://huggingface.co/nvidia/NVIDIA-NemotronLabs-RE-USE/resolve/31f82f2efad1095034492f236e8dac9239ba713b/model.safetensors' },
@@ -3813,6 +3837,36 @@ export const SPEC = [
license: 'Tencent Hunyuan 3D 2.1 Community License (territory EXCLUDES the EU, UK and South Korea)',
notes: 'Template 3d_hunyuan3d-v2.1. Shape only (no Hunyuan3D-Paint in the native nodes): clay previews or a separate texture step. Feed a background-removed image (bg-remove-birefnet).',
},
+ {
+ id: 'mesh-refine-hi3d',
+ title: 'Refine a 3D model\'s geometry from its photo (Hi3D 1.0, 512 / 1024 / 1536; geometry-only GLB)',
+ capability: 'refine-3d',
+ handBuilt: 'hand-built/mesh-refine-hi3d.json',
+ packs: ['Comfyui-Hi3d-T8'],
+ requiredModels: [
+ 'hi3d/model_index.json', 'hi3d/scheduler/scheduler_config.json', 'hi3d/vae/config.json', 'hi3d/vae/model.safetensors',
+ 'hi3d/transformer_512/config.json', 'hi3d/transformer_512/model.safetensors', 'hi3d/transformer_1024/config.json', 'hi3d/transformer_1024/model.safetensors',
+ 'dino/config.json', 'dino/model.safetensors', 'clip/config.json', 'clip/model.safetensors',
+ ],
+ bindings: {
+ image: [b('2', 'image')], model3d: [b('5', 'mesh_file')], meshResolution: [b('6', 'resolution')], steps: [b('6', 'steps')], seed: [b('6', 'seed')],
+ cpuOffload: [b('1', 'cpu_offload')],
+ },
+ outputs: [{ node: '7', kind: 'model3d' }],
+ vramGb: 24,
+ license:
+ 'Hi3D Open License Agreement 1.0 (Hi3D v1.0 weights and vendored code by OCEANO HK HOLDING LIMITED: commercial use permitted; above 200,000 monthly active users or USD 1,000,000 monthly revenue, ' +
+ 'notify the licensor and apply for a separate licence within 60 days; the app must show "Powered by Hi3D 1.0" linking to http://hi3d.ai/); T8star\'s ComfyUI nodes MIT; ' +
+ 'DINOv2-L Apache-2.0, CLIP ViT-L/14 MIT (OpenAI); BiRefNet MIT',
+ notes:
+ 'Hi3D v1.0 (Sparc3D\'s refinement stage; docs/research/hi3d-refine.json) through T8star\'s Comfyui-Hi3d-T8 0.5.1: LoadImage -> core BiRefNet RemoveBackground (the mask frames the subject) ' +
+ '-> Hi3DRefine with the coarse GLB (Hi3DLoadMesh reads it from ComfyUI\'s input folder, where Fuobe uploads it) and Hi3DModelLoader (models/Hi3D with hi3d/, dino/, clip/; sequential CPU offload on, flash attention) ' +
+ '-> SaveGLB. Resolution 512 runs one pass (transformer_512), 1024 two and 1536 three (transformer_1024), 25 scheduler steps each. Output: geometry only (no texture, material or vertex colour), ' +
+ 'recentred at unit radius, not guaranteed watertight; the Fuobe server finishes it like any image-to-3D GLB (web GLB + CPU turntable). Needs Linux or Windows with an NVIDIA GPU of compute capability 8.0+ ' +
+ 'and CUDA 12 (official stack: CUDA 12.0-12.5, torch 2.5.0+cu124, flash-attn 2.7.4.post1, spconv-cu120 2.3.6; the pack keeps ComfyUI\'s torch and pins spconv-cu126 2.3.8, with an SDPA attention option). ' +
+ 'No CPU path. 1536 is validated upstream only on a 96 GB H20; the pack\'s author ran 512-1536 on a 24 GB laptop RTX 5090 with offload (vramGb is an estimate). Not run by Fuobe yet (no GPU here). ' +
+ 'Weights: 7.73 GB Hi3D + 1.22 GB DINOv2-L + 1.71 GB CLIP ViT-L/14 at pinned revisions.',
+ },
{
id: 'tryon-flux2-klein-4b',
title: 'Virtual try-on: FLUX.2 [klein] 4B + try-on LoRA (person + top + bottom)',
diff --git a/src/app/(studio)/image-to-3d/page.tsx b/src/app/(studio)/image-to-3d/page.tsx
index d83a4db2..3db2faa5 100644
--- a/src/app/(studio)/image-to-3d/page.tsx
+++ b/src/app/(studio)/image-to-3d/page.tsx
@@ -3,6 +3,7 @@ import path from "node:path";
import type { Metadata } from "next";
import { Model3dStudio, type Model3dInfo } from "@/components/model3d/model3d-studio";
import { ALL_MODELS_3D, CLOUD_NOTICES, RIG_MODEL } from "@/lib/av/model3d";
+import { HI3D_MODEL } from "@/lib/av/hi3d";
import { getModel } from "@/lib/catalog";
import type { Manifest } from "@/lib/comfy";
import { buildLicenceList, FLAG_LABEL } from "@/lib/licences";
@@ -21,7 +22,7 @@ async function readLicences(): Promise<Record<string, NonNullable<Model3dInfo["l
} catch {
return {};
}
- const models = ALL_MODELS_3D.flatMap((c) => {
+ const models = [...ALL_MODELS_3D, { id: HI3D_MODEL }].flatMap((c) => {
const m = getModel(c.id);
return m?.engine === "open" ? [m] : [];
});
@@ -54,7 +55,7 @@ async function readLicences(): Promise<Record<string, NonNullable<Model3dInfo["l
export default async function Page() {
const licences = await readLicences();
const info: Record<string, Model3dInfo> = Object.fromEntries(
- [...ALL_MODELS_3D.map((m) => m.id), RIG_MODEL].map((id) => [
+ [...ALL_MODELS_3D.map((m) => m.id), RIG_MODEL, HI3D_MODEL].map((id) => [
id,
{ name: getModel(id)?.name ?? id, notices: licences[id]?.notices ?? CLOUD_NOTICES[id] ?? [], ...(licences[id] && { licence: licences[id] }) },
]),
diff --git a/src/components/model3d/glb-triangles.ts b/src/components/model3d/glb-triangles.ts
new file mode 100644
index 00000000..627d2e54
--- /dev/null
+++ b/src/components/model3d/glb-triangles.ts
@@ -0,0 +1,37 @@
+"use client";
+
+import type { TriMesh } from "@/lib/print3d";
+
+/**
+ * Every triangle of a GLB in world space (each mesh's transform applied), read with three.js in the browser. Loaded
+ * only when the Print-ready dialog asks for it, so the page doesn't carry three.js.
+ */
+export async function glbTriangles(url: string): Promise<TriMesh> {
+ const [THREE, { GLTFLoader }, { MeshoptDecoder }] = await Promise.all([
+ import("three"),
+ import("three/examples/jsm/loaders/GLTFLoader.js"),
+ import("three/examples/jsm/libs/meshopt_decoder.module.js"),
+ ]);
+ const loader = new GLTFLoader();
+ loader.setMeshoptDecoder(MeshoptDecoder);
+ const gltf = await loader.loadAsync(url);
+ gltf.scene.updateMatrixWorld(true);
+ const positions: number[] = [];
+ const indices: number[] = [];
+ const v = new THREE.Vector3();
+ gltf.scene.traverse((o) => {
+ const mesh = o as InstanceType<typeof THREE.Mesh>;
+ if (!mesh.isMesh || !mesh.geometry) return;
+ const pos = mesh.geometry.getAttribute("position");
+ if (!pos) return;
+ const base = positions.length / 3;
+ for (let i = 0; i < pos.count; i++) {
+ v.fromBufferAttribute(pos, i).applyMatrix4(mesh.matrixWorld);
+ positions.push(v.x, v.y, v.z);
+ }
+ const index = mesh.geometry.getIndex();
+ if (index) for (let i = 0; i < index.count; i++) indices.push(base + index.getX(i));
+ else for (let i = 0; i < pos.count; i++) indices.push(base + i);
+ });
+ return { positions: Float32Array.from(positions), indices: Uint32Array.from(indices) };
+}
diff --git a/src/components/model3d/model-card.tsx b/src/components/model3d/model-card.tsx
index 3f18663a..d1d7c4a1 100644
--- a/src/components/model3d/model-card.tsx
+++ b/src/components/model3d/model-card.tsx
@@ -1,6 +1,6 @@
"use client";
-import { Box, Clapperboard, Download, ImageIcon, Loader2, Pause, PersonStanding, Play, Rotate3d, Sparkles, Video } from "lucide-react";
+import { Box, Clapperboard, Download, ImageIcon, Loader2, Pause, PersonStanding, Play, Printer, Rotate3d, Sparkles, Video, Wand2 } from "lucide-react";
import Link from "next/link";
import { createElement, useCallback, useEffect, useRef, useState, useSyncExternalStore } from "react";
import { toast } from "sonner";
@@ -13,6 +13,9 @@ import { toastError } from "@/lib/refusals";
import { loadModelViewer, TURNTABLE_BACKDROP, useViewerSrc, viewerLook } from "./model-viewer";
import type { Model3dInfo } from "./model3d-studio";
import { RigDialog } from "./rig-dialog";
+import { PrintDialog } from "./print-dialog";
+import { PoweredByHi3d, RefineDialog } from "./refine-option";
+import { HI3D_NOTICE, canRefine, isRefined } from "@/lib/av/hi3d";
import { PlaceholderChip } from "@/components/demo-mode";
import { recordableType, recordTurntable } from "./turntable";
@@ -37,7 +40,7 @@ function rigClips(g: Generation, view: Model3dView): { key: string; label: strin
* plays its animation). A splat shows its orbit video or picture with the file to download. Then the turntable,
* Animate the spin and Rig & animate.
*/
-export function ModelCard({ g, info, cloudAllowed }: { g: Generation; info: Record<string, Model3dInfo>; cloudAllowed: boolean }) {
+export function ModelCard({ g, info, cloudAllowed, refineAllowed = false }: { g: Generation; info: Record<string, Model3dInfo>; cloudAllowed: boolean; refineAllowed?: boolean }) {
const view = model3dView(g);
// "preview": the turntable or the still (a splat with an orbit video: the video). "3d": the viewer (a splat: its picture).
const [show, setShow] = useState<"preview" | "3d">("preview");
@@ -49,6 +52,8 @@ export function ModelCard({ g, info, cloudAllowed }: { g: Generation; info: Reco
const [recording, setRecording] = useState<number | null>(null);
const [recorded, setRecorded] = useState<{ url: string; saved?: string } | null>(null);
const [rigging, setRigging] = useState(false);
+ const [refining, setRefining] = useState(false);
+ const [printing, setPrinting] = useState(false);
const pendingRecord = useRef(false);
// "View in 3D" unmounts itself: focus moves to the viewer once it's there.
const focusViewer = useRef(false);
@@ -144,7 +149,12 @@ export function ModelCard({ g, info, cloudAllowed }: { g: Generation; info: Reco
setShow("3d");
};
const spin = view.rigged ? null : animateSpinHref(view, recorded?.saved);
- const notices = info[g.modelId]?.notices ?? [];
+ // Hi3D's results: geometry only, and "Powered by Hi3D 1.0" (linked, as its licence asks) instead of the plain notice.
+ const refined = isRefined(g);
+ const notices = (info[g.modelId]?.notices ?? []).filter((n) => !(refined && n === HI3D_NOTICE));
+ // "Refine this mesh": a finished mesh (not a splat or a rig) with the photo, or the drawn still, it was made from.
+ const refineFrom = view.photo ?? drawn;
+ const refinable = canRefine({ glb: view.glb, photo: refineFrom, splat: view.splat, rigged: view.rigged, refined, openAllowed: refineAllowed }) && g.op !== "splat";
// A rigged result rigs its source model again with another animation.
const rigSource = view.rigged ? (g.request.inputs?.model3d ?? view.glb) : view.glb;
// The radio buttons in the corner: the preview and the 3D view, a rig's clips, or a splat's video and picture.
@@ -326,6 +336,16 @@ export function ModelCard({ g, info, cloudAllowed }: { g: Generation; info: Reco
<PersonStanding className="size-3.5" /> {view.rigged ? "Another animation" : "Rig & animate"}
</Button>
)}
+ {refinable && (
+ <Button variant="outline" size="sm" className="rounded-full" onClick={() => setRefining(true)}>
+ <Wand2 className="size-3.5" /> Refine this mesh
+ </Button>
+ )}
+ {view.glb && !view.splat && g.op !== "splat" && !view.rigged && (
+ <Button variant="outline" size="sm" className="rounded-full" onClick={() => setPrinting(true)}>
+ <Printer className="size-3.5" /> Print-ready
+ </Button>
+ )}
{spin && (
<Button asChild size="sm" className="rounded-full">
<Link href={spin} prefetch={false}>
@@ -334,8 +354,21 @@ export function ModelCard({ g, info, cloudAllowed }: { g: Generation; info: Reco
</Button>
)}
</div>
- {notices.length > 0 && <p className="text-[11px] text-muted-foreground">{notices.join(" · ")}</p>}
+ {refined && <p className="text-[12px] text-muted-foreground">Geometry only: no colour or texture. Set its real size in Print-ready.</p>}
+ {(notices.length > 0 || refined) && (
+ <p className="text-[11px] text-muted-foreground">
+ {notices.join(" · ")}
+ {refined && (
+ <>
+ {notices.length > 0 && " · "}
+ <PoweredByHi3d />
+ </>
+ )}
+ </p>
+ )}
</div>
+ {refinable && refining && view.glb && refineFrom && <RefineDialog glb={view.glb} photo={refineFrom} open={refining} onOpenChange={setRefining} feature={g.feature} />}
+ {printing && view.glb && <PrintDialog glb={view.glb} name={name} open={printing} onOpenChange={setPrinting} refined={refined} />}
{rigSource && rigging && g.op !== "splat" && <RigDialog glb={rigSource} open={rigging} onOpenChange={setRigging} cloudAllowed={cloudAllowed} />}
</article>
);
diff --git a/src/components/model3d/model3d-studio.tsx b/src/components/model3d/model3d-studio.tsx
index 0f94f30a..2cd1e68a 100644
--- a/src/components/model3d/model3d-studio.tsx
+++ b/src/components/model3d/model3d-studio.tsx
@@ -39,6 +39,8 @@ import { cn } from "@/lib/utils";
import { toastError } from "@/lib/refusals";
import { priceLine, useRunPreview } from "./hooks";
import { ModelCard } from "./model-card";
+import { RefineOption } from "./refine-option";
+import { HI3D_MODEL, withRefine, type Hi3dResolution } from "@/lib/av/hi3d";
/**
* A model's name, the notices its results carry ("Built with DINOv3") and, for open models, the licence the
@@ -147,6 +149,8 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
const [object, setObject] = useState("");
const [picked, setPicked] = useState<Record<string, string>>({});
const [rigHint, setRigHint] = useState(false);
+ // Refine detail · Hi3D 1.0 (open engine, From an image and From several images): the resolution, or off.
+ const [refine, setRefine] = useState<Hi3dResolution | null>(null);
const showRigHint = useCallback(() => setRigHint(true), []);
const fromUrl = useCallback(
(m: Model3dMode, e: Engine, id: string) => {
@@ -174,11 +178,17 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
const free = !!preview.data && !preview.data.demo && (preview.data.engine === "open" || preview.data.costUsd === 0);
const price = visitor && free ? "Not available here" : priceLine(preview.data);
const cloudAllowed = engineMode !== "open";
+ // Hi3D runs on your GPU only: offered while the install runs open models and the model is switched on.
+ const refineAllowed = !visitor && engineMode !== "cloud" && offered(access, HI3D_MODEL, "open");
+ const refining = refineAllowed && engine === "open" && (mode === "image" || mode === "multi") && refine !== null ? refine : null;
const go = () => {
if (visitor) return;
if (blocker) return void toast(blocker, { id: "3d-blocker" });
- create.mutate(model3dRequest(input), {
- onSuccess: () => toast.success(mode === "splat" ? "Making your splat" : mode === "text" && engine === "open" ? "Drawing the object, then building it in 3D" : "Building your 3D model"),
+ create.mutate(withRefine(model3dRequest(input), engine, refining), {
+ onSuccess: () =>
+ toast.success(
+ mode === "splat" ? "Making your splat" : mode === "text" && engine === "open" ? "Drawing the object, then building it in 3D" : refining ? "Building your 3D model, then refining its detail" : "Building your 3D model",
+ ),
onError: (e) => toastError(e),
});
};
@@ -318,6 +328,7 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
{!licence && info[modelId]?.notices.length > 0 && <p className="text-[12px] font-medium">{info[modelId].notices.join(" · ")}</p>}
{licence && licence.notices.length > 0 && <p className="text-[12px] text-muted-foreground">{licence.notices.join(" · ")}</p>}
</div>
+ {(mode === "image" || mode === "multi") && <RefineOption engine={engine} value={refine} onChange={setRefine} openAllowed={refineAllowed} onUseGpu={() => setEngine("open")} />}
<Button size="lg" className={cn("mt-4 w-full rounded-full", blocker && "bg-muted text-muted-foreground hover:bg-muted")} onClick={go} disabled={create.isPending || visitor}>
{create.isPending ? <Loader2 className="size-4 animate-spin" /> : <Box className="size-4" />} {mode === "splat" ? "Make the splat" : "Make it 3D"}
</Button>
@@ -351,7 +362,7 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
) : (
<div className="grid gap-3 sm:grid-cols-2">
{items.map((g) => (
- <ResultCard key={g.id} g={g} info={info} cloudAllowed={cloudAllowed} />
+ <ResultCard key={g.id} g={g} info={info} cloudAllowed={cloudAllowed} refineAllowed={refineAllowed} />
))}
</div>
)}
@@ -369,9 +380,9 @@ function retryOf(g: Generation): GenerationRequest {
return r;
}
-function ResultCard({ g, info, cloudAllowed }: { g: Generation; info: Record<string, Model3dInfo>; cloudAllowed: boolean }) {
+function ResultCard({ g, info, cloudAllowed, refineAllowed }: { g: Generation; info: Record<string, Model3dInfo>; cloudAllowed: boolean; refineAllowed: boolean }) {
const create = useCreateGeneration();
if (g.status === "queued" || g.status === "running") return <PendingTile g={g} ratio={4 / 3} />;
if (g.status !== "succeeded") return <FailedTile g={g} ratio={4 / 3} onRetry={() => create.mutate(retryOf(g), { onError: (e) => toastError(e) })} />;
- return <ModelCard g={g} info={info} cloudAllowed={cloudAllowed} />;
+ return <ModelCard g={g} info={info} cloudAllowed={cloudAllowed} refineAllowed={refineAllowed} />;
}
diff --git a/src/components/model3d/print-dialog.tsx b/src/components/model3d/print-dialog.tsx
new file mode 100644
index 00000000..62385a40
--- /dev/null
+++ b/src/components/model3d/print-dialog.tsx
@@ -0,0 +1,109 @@
+"use client";
+
+import { Download, Loader2 } from "lucide-react";
+import { useEffect, useState } from "react";
+import { Button } from "@/components/ui/button";
+import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
+import { Input } from "@/components/ui/input";
+import { Label } from "@/components/ui/label";
+import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
+import { DEFAULT_HEIGHT_MM, MAX_HEIGHT_MM, MIN_HEIGHT_MM, PRINT_FORMATS, printExport, printHeight, type PrintFormat, type TriMesh, watertightCheck, watertightLine, weld } from "@/lib/print3d";
+import { toastError } from "@/lib/refusals";
+import { glbTriangles } from "./glb-triangles";
+
+/**
+ * Print-ready: the model as an STL or 3MF in millimetres, at the height the user sets (the model itself has no real
+ * size: Hi3D's refine comes out at a standard size), with a watertight check before the download. All in the browser.
+ */
+export function PrintDialog({ glb, name, open, onOpenChange, refined }: { glb: string; name: string; open: boolean; onOpenChange: (v: boolean) => void; refined?: boolean }) {
+ const [mesh, setMesh] = useState<{ url: string; tri: TriMesh; check: ReturnType<typeof watertightCheck> } | { url: string; error: string } | null>(null);
+ const [height, setHeight] = useState(String(DEFAULT_HEIGHT_MM));
+ const [format, setFormat] = useState<PrintFormat>("stl");
+ const [busy, setBusy] = useState(false);
+ useEffect(() => {
+ if (!open || mesh?.url === glb) return;
+ let live = true;
+ glbTriangles(glb).then(
+ (tri) => live && setMesh({ url: glb, tri, check: watertightCheck(weld(tri)) }),
+ () => live && setMesh({ url: glb, error: "Couldn't read this model. Download the .glb and convert it in your slicer." }),
+ );
+ return () => {
+ live = false;
+ };
+ }, [open, glb, mesh?.url]);
+ const ready = mesh && mesh.url === glb && "tri" in mesh ? mesh : null;
+ const failed = mesh && mesh.url === glb && "error" in mesh ? mesh.error : null;
+ const typed = Number(height);
+ const badHeight = !height.trim() || !Number.isFinite(typed) || typed < MIN_HEIGHT_MM || typed > MAX_HEIGHT_MM;
+ const save = () => {
+ if (!ready || badHeight) return;
+ setBusy(true);
+ try {
+ const out = printExport(ready.tri, { heightMm: printHeight(typed), format, name });
+ const url = URL.createObjectURL(new Blob([out.data.slice().buffer], { type: out.mime }));
+ const a = document.createElement("a");
+ a.href = url;
+ a.download = `${name} ${Math.round(out.sizeMm[2])}mm.${out.ext}`;
+ a.click();
+ setTimeout(() => URL.revokeObjectURL(url), 10_000);
+ onOpenChange(false);
+ } catch (e) {
+ toastError(e);
+ } finally {
+ setBusy(false);
+ }
+ };
+ return (
+ <Dialog open={open} onOpenChange={onOpenChange}>
+ <DialogContent className="sm:max-w-md">
+ <DialogHeader>
+ <DialogTitle>Print-ready</DialogTitle>
+ <DialogDescription>
+ {refined ? "The refined model comes out at a standard size, not its real one" : "A 3D model has no real size of its own"}: set how tall the print should be. It stands on the bed, Z up, in millimetres.
+ </DialogDescription>
+ </DialogHeader>
+ <div className="grid gap-3">
+ <div className="grid gap-1.5">
+ <Label htmlFor="print-height">Height (mm)</Label>
+ <Input
+ id="print-height"
+ inputMode="decimal"
+ value={height}
+ onChange={(e) => setHeight(e.target.value.replace(/[^\d.]/g, "").slice(0, 7))}
+ aria-invalid={badHeight}
+ aria-describedby="print-height-hint"
+ className="h-9 rounded-full"
+ />
+ <p id="print-height-hint" className="text-[12px] text-muted-foreground">
+ {MIN_HEIGHT_MM} mm to {MAX_HEIGHT_MM / 1000} m; the width and depth follow the model&apos;s shape.
+ </p>
+ </div>
+ <div className="grid gap-1.5">
+ <span className="text-sm font-medium" id="print-format">
+ Format
+ </span>
+ <ToggleGroup type="single" variant="outline" value={format} onValueChange={(v) => v && setFormat(v as PrintFormat)} aria-labelledby="print-format" className="w-full">
+ {PRINT_FORMATS.map((f) => (
+ <ToggleGroupItem key={f.id} value={f.id} className="flex-1" aria-label={`${f.label}: ${f.hint}`}>
+ {f.label}
+ </ToggleGroupItem>
+ ))}
+ </ToggleGroup>
+ <p className="text-[12px] text-muted-foreground">{PRINT_FORMATS.find((f) => f.id === format)?.hint}. Shape only: colours and textures stay in the .glb.</p>
+ </div>
+ <p className="rounded-xl bg-muted p-3 text-[13px]" role="status" aria-live="polite">
+ {failed ?? (ready ? watertightLine(ready.check) : "Checking the model…")}
+ </p>
+ </div>
+ <DialogFooter>
+ <Button variant="ghost" className="rounded-full" onClick={() => onOpenChange(false)}>
+ Cancel
+ </Button>
+ <Button className="rounded-full" onClick={save} disabled={!ready || badHeight || busy}>
+ {!ready && !failed ? <Loader2 className="size-4 animate-spin" /> : <Download className="size-4" />} Download .{format}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ );
+}
diff --git a/src/components/model3d/refine-option.tsx b/src/components/model3d/refine-option.tsx
new file mode 100644
index 00000000..675f8201
--- /dev/null
+++ b/src/components/model3d/refine-option.tsx
@@ -0,0 +1,154 @@
+"use client";
+
+import { Loader2, Sparkles } from "lucide-react";
+import { useState } from "react";
+import { toast } from "sonner";
+import { Button } from "@/components/ui/button";
+import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
+import { Label } from "@/components/ui/label";
+import { Switch } from "@/components/ui/switch";
+import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
+import { useCreateGeneration } from "@/lib/api";
+import {
+ HI3D_CLOUD_NOTE,
+ HI3D_DEFAULT,
+ HI3D_GEOMETRY_NOTE,
+ HI3D_HARDWARE,
+ HI3D_LABEL,
+ HI3D_NOTICE,
+ HI3D_RESOLUTIONS,
+ HI3D_URL,
+ refineRequest,
+ type Hi3dResolution,
+} from "@/lib/av/hi3d";
+import type { Engine } from "@/lib/catalog/types";
+import { toastError } from "@/lib/refusals";
+import { priceLine, useRunPreview } from "./hooks";
+
+/** "Powered by Hi3D 1.0", linked to Hi3D's site as its licence asks, wherever its results or its switch show. */
+export function PoweredByHi3d({ className }: { className?: string }) {
+ return (
+ <a href={HI3D_URL} target="_blank" rel="noreferrer" className={className ?? "text-[11px] text-muted-foreground underline-offset-2 hover:underline"}>
+ {HI3D_NOTICE}
+ </a>
+ );
+}
+
+function Resolutions({ value, onChange, id }: { value: Hi3dResolution; onChange: (v: Hi3dResolution) => void; id: string }) {
+ return (
+ <div className="grid gap-1">
+ <span id={id} className="text-[12px] font-medium">
+ Detail
+ </span>
+ <ToggleGroup type="single" variant="outline" size="sm" value={String(value)} onValueChange={(v) => v && onChange(Number(v) as Hi3dResolution)} aria-labelledby={id} className="w-full">
+ {HI3D_RESOLUTIONS.map((r) => (
+ <ToggleGroupItem key={r.value} value={String(r.value)} className="flex-1" aria-label={`${r.label}: ${r.hint}`}>
+ {r.label}
+ </ToggleGroupItem>
+ ))}
+ </ToggleGroup>
+ <p className="text-[12px] text-muted-foreground">{HI3D_RESOLUTIONS.find((r) => r.value === value)?.hint}</p>
+ </div>
+ );
+}
+
+/**
+ * Image to 3D's "Refine detail · Hi3D 1.0": after the model is built, Hi3D sharpens its geometry from the same photo.
+ * On your GPU only; the cloud engine says so (and offers the switch back when the install runs open models), and an
+ * install on paid APIs only doesn't show it.
+ */
+export function RefineOption({
+ engine,
+ value,
+ onChange,
+ openAllowed,
+ onUseGpu,
+}: {
+ engine: Engine;
+ value: Hi3dResolution | null;
+ onChange: (v: Hi3dResolution | null) => void;
+ openAllowed: boolean;
+ onUseGpu: () => void;
+}) {
+ const [last, setLast] = useState<Hi3dResolution>(value ?? HI3D_DEFAULT);
+ if (!openAllowed) return null;
+ if (engine !== "open") {
+ return (
+ <div className="mt-3 flex flex-wrap items-center justify-between gap-2 rounded-xl border border-dashed p-2.5 text-[12px] text-muted-foreground">
+ <span>{HI3D_CLOUD_NOTE}</span>
+ <Button size="sm" variant="ghost" className="h-7 rounded-full px-2.5 text-[12px]" onClick={onUseGpu}>
+ Use your GPU
+ </Button>
+ </div>
+ );
+ }
+ const on = value !== null;
+ return (
+ <div className="mt-3 rounded-xl border p-2.5">
+ <div className="flex items-center justify-between gap-2">
+ <Label htmlFor="m3d-refine" className="text-[13px]">
+ {HI3D_LABEL}
+ </Label>
+ <Switch id="m3d-refine" checked={on} onCheckedChange={(v) => onChange(v ? last : null)} aria-describedby="m3d-refine-hint" />
+ </div>
+ <p id="m3d-refine-hint" className="mt-1 text-[12px] text-muted-foreground">
+ Sharper edges, engravings and fine relief. {HI3D_GEOMETRY_NOTE} You keep both models.
+ </p>
+ {on && (
+ <div className="mt-2 grid gap-2">
+ <Resolutions
+ id="m3d-refine-res"
+ value={value}
+ onChange={(v) => {
+ setLast(v);
+ onChange(v);
+ }}
+ />
+ <p className="text-[11px] text-muted-foreground">{HI3D_HARDWARE}</p>
+ <PoweredByHi3d />
+ </div>
+ )}
+ </div>
+ );
+}
+
+/** "Refine this mesh" on a finished model: Hi3D refines its geometry from the photo it was made from. */
+export function RefineDialog({ glb, photo, open, onOpenChange, feature }: { glb: string; photo: string; open: boolean; onOpenChange: (v: boolean) => void; feature?: string }) {
+ const create = useCreateGeneration();
+ const [resolution, setResolution] = useState<Hi3dResolution>(HI3D_DEFAULT);
+ const req = refineRequest({ glb, photo, resolution, feature });
+ const preview = useRunPreview(open ? req : null);
+ const go = () =>
+ create.mutate(req, {
+ onSuccess: () => {
+ toast.success("Refining the detail on your GPU");
+ onOpenChange(false);
+ },
+ onError: (e) => toastError(e),
+ });
+ return (
+ <Dialog open={open} onOpenChange={onOpenChange}>
+ <DialogContent className="sm:max-w-md">
+ <DialogHeader>
+ <DialogTitle>Refine this mesh</DialogTitle>
+ <DialogDescription>Hi3D 1.0 sharpens the model&apos;s geometry, guided by the photo it was made from. {HI3D_GEOMETRY_NOTE}</DialogDescription>
+ </DialogHeader>
+ <div className="grid gap-3">
+ <Resolutions id="refine-res" value={resolution} onChange={setResolution} />
+ <p className="text-[12px] text-muted-foreground" aria-live="polite">
+ {preview.isError ? (preview.error as Error).message : (priceLine(preview.data) ?? "Working out the price…")} · {HI3D_HARDWARE}
+ </p>
+ <PoweredByHi3d />
+ </div>
+ <DialogFooter>
+ <Button variant="ghost" className="rounded-full" onClick={() => onOpenChange(false)}>
+ Cancel
+ </Button>
+ <Button className="rounded-full" onClick={go} disabled={create.isPending}>
+ {create.isPending ? <Loader2 className="size-4 animate-spin" /> : <Sparkles className="size-4" />} Refine
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ );
+}
diff --git a/src/lib/av/hi3d.ts b/src/lib/av/hi3d.ts
new file mode 100644
index 00000000..29833a16
--- /dev/null
+++ b/src/lib/av/hi3d.ts
@@ -0,0 +1,76 @@
+import type { Engine, Generation, GenerationRequest } from "@/lib/catalog/types";
+import { MODEL3D_FEATURE } from "./model3d";
+
+/**
+ * Hi3D 1.0 (Sparc3D's refinement stage, released open; docs/research/hi3d-refine.json): it refines a coarse mesh into
+ * high-resolution geometry, guided by a photo of the same object. Geometry only (no colour or texture), recentred and
+ * scaled to a unit radius, so a print needs its real size set again. Nobody hosts the open model, so it runs on the
+ * open engine only (the user's ComfyUI with T8's Hi3D pack): the cloud engine says so, and "Paid APIs only" hides it.
+ */
+export const HI3D_MODEL = "oss-hi3d-refine";
+export const HI3D_OP = "refine-3d";
+/** The graph's setting for the resolution (params.extra), and the Image to 3D request's ask for a refine step after the model. */
+export const HI3D_PARAM = "meshResolution";
+export const HI3D_CHAIN_PARAM = "hi3dRefine";
+
+export type Hi3dResolution = 512 | 1024 | 1536;
+export const HI3D_RESOLUTIONS: { value: Hi3dResolution; label: string; hint: string }[] = [
+ { value: 512, label: "512", hint: "Quickest: one pass" },
+ { value: 1024, label: "1024", hint: "Sharper detail: two passes" },
+ { value: 1536, label: "1536", hint: "Finest detail: three passes, needs the most GPU memory" },
+];
+export const HI3D_DEFAULT: Hi3dResolution = 1024;
+
+/** The licence asks for this, linking to Hi3D's site, wherever its results are shown (Hi3D Open License 1.0, Section 7). */
+export const HI3D_NOTICE = "Powered by Hi3D 1.0";
+export const HI3D_URL = "http://hi3d.ai/";
+
+export const HI3D_LABEL = "Refine detail · Hi3D 1.0";
+export const HI3D_GEOMETRY_NOTE = "Geometry only: the refined model has no colour or texture, and comes out centred at a standard size.";
+/** What it needs (README: compute capability 8.0+, CUDA 12, flash-attn or the pack's SDPA path; no CPU inference). */
+export const HI3D_HARDWARE = "Runs on your GPU: an NVIDIA card from the RTX 30 series (Ampere) or newer with CUDA 12. There is no CPU mode. About 11 GB of model files.";
+export const HI3D_CLOUD_NOTE = "Refine detail runs on your GPU only: no cloud service offers it.";
+
+/** A resolution Hi3D takes, else the default. */
+export function hi3dResolution(v: unknown): Hi3dResolution {
+ const n = typeof v === "number" ? v : typeof v === "string" ? Number(v) : NaN;
+ return HI3D_RESOLUTIONS.some((r) => r.value === n) ? (n as Hi3dResolution) : HI3D_DEFAULT;
+}
+
+/** A value the graph can take as it is (null: not one of 512, 1024, 1536). */
+export function strictHi3dResolution(v: unknown): Hi3dResolution | null {
+ const n = typeof v === "number" ? v : typeof v === "string" && v.trim() ? Number(v) : NaN;
+ return HI3D_RESOLUTIONS.some((r) => r.value === n) ? (n as Hi3dResolution) : null;
+}
+
+/** "Refine this mesh": a finished model's GLB and the photo it was made from, refined at a resolution. */
+export function refineRequest(o: { glb: string; photo: string; resolution?: unknown; seed?: number; feature?: string }): GenerationRequest {
+ return {
+ feature: o.feature ?? MODEL3D_FEATURE,
+ modelId: HI3D_MODEL,
+ op: HI3D_OP,
+ engine: "open",
+ inputs: { model3d: o.glb, images: [o.photo] },
+ params: { extra: { [HI3D_PARAM]: hi3dResolution(o.resolution) }, ...(o.seed !== undefined && { seed: o.seed }) },
+ };
+}
+
+/** The refine step Image to 3D asked for after its model (params.extra.hi3dRefine), else null. */
+export function chainedRefine(r: Pick<GenerationRequest, "params">): Hi3dResolution | null {
+ const v = r.params?.extra?.[HI3D_CHAIN_PARAM];
+ return v === undefined || v === null || v === false || v === "off" ? null : hi3dResolution(v);
+}
+
+/** Image to 3D's request with the refine step asked for (open engine only; the cloud never gets it). */
+export function withRefine(req: GenerationRequest, engine: Engine, resolution: Hi3dResolution | null): GenerationRequest {
+ if (engine !== "open" || resolution === null || req.op === "splat") return req;
+ return { ...req, params: { ...req.params, extra: { ...req.params?.extra, [HI3D_CHAIN_PARAM]: resolution } } };
+}
+
+/** A Hi3D result (its card says it is geometry only and carries the notice). */
+export const isRefined = (g: Pick<Generation, "modelId">) => g.modelId === HI3D_MODEL;
+
+/** Whether a finished model can be refined here: a mesh (not a splat or a rig), with the photo it came from, on an install that runs open models. */
+export function canRefine(o: { glb?: string; photo?: string; splat?: unknown; rigged?: boolean; refined?: boolean; openAllowed: boolean }): boolean {
+ return !!o.glb && !!o.photo && !o.splat && !o.rigged && !o.refined && o.openAllowed;
+}
diff --git a/src/lib/catalog/models.ts b/src/lib/catalog/models.ts
index 399e6e39..fb69d768 100644
--- a/src/lib/catalog/models.ts
+++ b/src/lib/catalog/models.ts
@@ -1,4 +1,5 @@
import { CLOUD_MODELS, ORIGINAL_CLOUD } from "./cloud-models.generated";
+import { HI3D_CHAIN_PARAM } from "@/lib/av/hi3d";
import { DEFAULT_FPS_TARGET, FPS_TARGETS, SLOW_MOTION } from "@/lib/av/fps";
import { ASR_LANGUAGES, WHISPER_LANGUAGES } from "../speech-languages";
import { PROMPT_HELPER_PARAM } from "@/lib/comfy";
@@ -20,6 +21,18 @@ import { LAST_FRAME_CHAIN, type ModelDef, type ModelOptions, type ModelRoute, ty
*/
const comfy = (op: Operation, workflow: string, note?: string): ModelRoute => ({ op, provider: "comfyui", endpoint: workflow, note });
+/**
+ * "Refine detail · Hi3D 1.0" on the open image-to-3D models (hi3d-refine): after the model is built, Hi3D refines its
+ * geometry from the same photo (src/server/chains.ts createRefinedModel). Off unless picked; the Canvas 3D node and
+ * the composer show it as a control, Image to 3D as a switch.
+ */
+const HI3D_REFINE_CONTROL = {
+ param: HI3D_CHAIN_PARAM,
+ label: "Refine detail · Hi3D 1.0",
+ values: ["off", 512, 1024, 1536],
+ default: "off",
+ labels: { off: "Off", 512: "Hi3D 512 (one pass)", 1024: "Hi3D 1024 (two passes)", 1536: "Hi3D 1536 (three passes)" },
+};
/** Chatterbox Multilingual's language list (FL_ChatterboxMultilingualTTS). */
const CHATTERBOX_LANGUAGES = [
@@ -1856,7 +1869,7 @@ const open: ModelDef[] = [
tagline: "A textured 3D model (.glb) that stays true to your photo (camera-aware), plus a turntable video · 16 GB GPU",
badges: ["new", "top"],
routes: [comfy("image-to-3d", "image-to-3d-pixal3d", "MoGe-2 camera → Pixal3D; ~250k triangles; web GLB + turntable made after the job")],
- options: { seed: true },
+ options: { seed: true, controls: [HI3D_REFINE_CONTROL] },
}),
o({
id: "oss-trellis2",
@@ -1867,7 +1880,7 @@ const open: ModelDef[] = [
tagline: "A textured 3D model (.glb) from one product photo, plus a turntable video; the fallback to Pixal3D · 16 GB GPU · MIT",
badges: ["new"],
routes: [comfy("image-to-3d", "image-to-3d-trellis2", "~250k triangles; web GLB + turntable made after the job")],
- options: { seed: true },
+ options: { seed: true, controls: [HI3D_REFINE_CONTROL] },
}),
o({
id: "oss-hunyuan3d-21",
@@ -1877,7 +1890,22 @@ const open: ModelDef[] = [
kind: "model3d",
tagline: "Untextured 3D shape from a photo · 10 GB GPU · licence excludes the EU, UK and South Korea",
routes: [comfy("image-to-3d", "image-to-3d-hunyuan3d-21")],
- options: { seed: true },
+ options: { seed: true, controls: [HI3D_REFINE_CONTROL] },
+ }),
+ // hi3d-refine (docs/research/hi3d-refine.json): Hi3D 1.0 refines a finished model's geometry from the photo it came from.
+ // Nobody hosts the open model, so it is open-engine only. Geometry only; its results carry "Powered by Hi3D 1.0".
+ o({
+ id: "oss-hi3d-refine",
+ name: "Hi3D 1.0",
+ vendor: "Hi3D (Sparc3D)",
+ family: "hi3d",
+ kind: "model3d",
+ tagline: "Refines a 3D model's geometry at 512, 1024 or 1536 from the photo it was made from; geometry only, no colour · Ampere GPU or newer, CUDA 12 · Powered by Hi3D 1.0",
+ badges: ["new"],
+ routes: [comfy("refine-3d", "mesh-refine-hi3d", "coarse GLB + photo → BiRefNet mask → Hi3D refine (25 steps a pass) → GLB, recentred at unit radius")],
+ options: { seed: true, minImages: 1, maxImages: 1, promptless: true },
+ engineNote: "Runs on your GPU only: no cloud service hosts the open Hi3D model.",
+ hidden: true,
}),
// Round 4 (r4/3d-plus): Image to 3D's other modes on the open engine.
o({
@@ -1890,7 +1918,7 @@ const open: ModelDef[] = [
badges: ["new"],
// params.extra.views names each photo's side ("front", "left", "back", "right"); the front is needed.
routes: [comfy("image-to-3d", "image-to-3d-trellis2-multiview", "Pixal3D multi-view on TRELLIS.2; the front, then any of left, back and right")],
- options: { seed: true, minImages: 2, maxImages: 4 },
+ options: { seed: true, minImages: 2, maxImages: 4, controls: [HI3D_REFINE_CONTROL] },
}),
o({
id: "oss-text-trellis2",
diff --git a/src/lib/catalog/plan.ts b/src/lib/catalog/plan.ts
index 79998352..f3f90e9d 100644
--- a/src/lib/catalog/plan.ts
+++ b/src/lib/catalog/plan.ts
@@ -60,6 +60,7 @@ export function inferOperation(model: ModelDef, req: Pick<GenerationRequest, "op
}
if (model.kind === "model3d") {
if (req.inputs?.model3d && has("rig-3d")) return "rig-3d";
+ if (req.inputs?.model3d && has("refine-3d")) return "refine-3d";
if (imgs && has("image-to-3d")) return "image-to-3d";
if (!imgs && has("text-to-3d")) return "text-to-3d";
}
@@ -238,7 +239,7 @@ const PROMPTLESS = new Set<Operation>([
// av-tools: the dub voice track (clips placed on the video's timeline)
"timeline",
// round 4: tools that work from their inputs (removing an object needs a prompt only on models that read one)
- "sdr-to-hdr", "export-video", "ocr", "still-motion", "audio-loop", "audio-join", "scene-3d", "splat", "rig-3d", "extract-frames", "images-to-video", "overlay", "composite",
+ "sdr-to-hdr", "export-video", "ocr", "still-motion", "audio-loop", "audio-join", "scene-3d", "splat", "rig-3d", "refine-3d", "extract-frames", "images-to-video", "overlay", "composite",
// round 5 (O11): the face mosaic names the faces itself ("face")
"face-mosaic",
// archive-restore: the scene's words help (period, place, light) but a run without them gets a neutral one
@@ -789,6 +790,7 @@ const NEEDS: Partial<
"scene-3d": { images: 1, msg: "Add the image to build the scene from" },
splat: { images: 1, msg: "Add a photo of the subject" },
"rig-3d": { model3d: true, msg: "Add the 3D model to rig" },
+ "refine-3d": { model3d: true, images: 1, msg: "Add the 3D model to refine and the photo it was made from" },
"extract-frames": { video: true, msg: "Add the video to take frames from" },
"images-to-video": { images: 1, msg: "Add the images, in order" },
overlay: { images: 2, msg: "Add the picture and the overlay to put on it" },
diff --git a/src/lib/catalog/types.ts b/src/lib/catalog/types.ts
index fc2efd1c..99823e89 100644
--- a/src/lib/catalog/types.ts
+++ b/src/lib/catalog/types.ts
@@ -79,6 +79,7 @@ export type Operation =
| "splat" // image → a Gaussian splat of the subject (meta.format "ply" | "spz")
| "text-to-3d" // prompt → 3D model
| "rig-3d" // 3D model (+ params.animation) → rigged / animated model
+ | "refine-3d" // 3D model + the photo it was made from (+ params.extra.meshResolution) → the same model with finer geometry (Hi3D)
| "extract-frames" // video → an image every params.frameInterval frames (meta.index)
| "images-to-video" // images in order → a video at params.fps
| "overlay" // image + a second image (logo) → composited (params.position, params.scale)
@@ -156,6 +157,7 @@ export const OPERATION_LABELS: Record<Operation, string> = {
splat: "Gaussian splat",
"text-to-3d": "Text to 3D",
"rig-3d": "Rig 3D model",
+ "refine-3d": "Refine 3D model",
"extract-frames": "Extract frames",
"images-to-video": "Images to video",
overlay: "Overlay image",
@@ -230,6 +232,7 @@ export const OPERATION_OUTPUT: Record<Operation, MediaKind> = {
splat: "model3d",
"text-to-3d": "model3d",
"rig-3d": "model3d",
+ "refine-3d": "model3d",
"extract-frames": "image",
"images-to-video": "video",
overlay: "image",
@@ -1040,7 +1043,7 @@ export interface GenerationRequest {
videos?: string[];
/** Reference audio clips (reference-to-video: voices, music or sound the clip should follow). */
audios?: string[];
- /** A 3D model file (.glb) to work on (rig-3d). */
+ /** A 3D model file (.glb) to work on (rig-3d, refine-3d). */
model3d?: string;
};
params?: GenParams;
diff --git a/src/lib/licences.ts b/src/lib/licences.ts
index c7a9494b..0e5fd08a 100644
--- a/src/lib/licences.ts
+++ b/src/lib/licences.ts
@@ -292,6 +292,9 @@ const KNOWN: { re: RegExp; name: string; class: LicenceClass; url?: string }[] =
{ re: /IndexTTS-2 Model Use License/, name: "bilibili IndexTTS-2 Model Use License", class: "conditions" },
{ re: /Llama 3\.1 Community License/, name: "Llama 3.1 Community License", class: "conditions", url: "https://www.llama.com/llama3_1/license/" },
{ re: /DINOv3 License/, name: "DINOv3 License", class: "conditions" },
+ // Hi3D 1.0 (hi3d-refine): commercial use; above 200,000 monthly users or US$1M monthly revenue a separate licence, and
+ // "Powered by Hi3D 1.0" shown with its results.
+ { re: /Hi3D Open License/, name: "Hi3D Open License Agreement 1.0", class: "conditions", url: "https://huggingface.co/hi3d-official/Hi3Dv1.0/blob/d502e938cbedc6e87aba8884614c5ca6d177a4b6/LICENSE" },
// Before SAM's: the H3 workflows' text names both, and the territory catch is the one that counts.
{ re: /MiniMax H3 Community License/, name: "MiniMax H3 Community License", class: "regions", url: "https://huggingface.co/MiniMaxAI/MiniMax-H3/blob/42ed227ee7df40d41602854ae760620d6eb651fe/LICENSE" },
{ re: /SAM License/, name: "Meta SAM License", class: "conditions" },
@@ -535,6 +538,13 @@ export const NODE_PACKS: NodePack[] = [
url: SPDX("MIT"),
note: "LBH-123-AI's H3 latent upscaler nodes (the Open-H3 Regenerate nodes call them by name); MIT code, copyright (c) 2026 LBH-123-AI. Its upscaler weights are Apache-2.0",
}),
+ // Hi3D 1.0 mesh refinement (hi3d-refine), opt-in in install-comfyui.sh (HI3D=1).
+ pack("Comfyui-Hi3d-T8", "https://github.com/T8mars/Comfyui-Hi3d-T8/tree/73848490976e6a9b0c735ce02984c03866a495e7", {
+ name: "MIT",
+ class: "conditions",
+ url: SPDX("MIT"),
+ note: "T8star's Hi3D nodes (model loader, mesh loader, refine); MIT code. The Hi3D code it vendors and the Hi3D weights are under the Hi3D Open License Agreement 1.0: commercial use, a separate licence above 200,000 monthly users or US$1M monthly revenue, and \"Powered by Hi3D 1.0\" shown with its results",
+ }),
// Clean up voice: Fuobe's own pack, in this repository at its pinned commit (comfy-nodes/ComfyUI-RE-USE).
pack("ComfyUI-RE-USE", "https://github.com/workingprototype/Fuobe/tree/8cc0417b5cb8a603f06502d97d5c6d8c6035ea0d/comfy-nodes/ComfyUI-RE-USE", {
name: "MIT",
diff --git a/src/lib/print3d.ts b/src/lib/print3d.ts
new file mode 100644
index 00000000..b6d7bcd6
--- /dev/null
+++ b/src/lib/print3d.ts
@@ -0,0 +1,288 @@
+/**
+ * Print-ready export (Image to 3D): a model's triangles as a binary STL or a 3MF, in millimetres, Z up, standing on the
+ * bed, scaled to the height the user sets. Hi3D (and most image-to-3D models) give a model at no real size (Hi3D centres
+ * it at a unit radius), so the height is the print's. A watertight check says whether a slicer will need to repair it.
+ * Pure: the page gathers the triangles from the GLB (three.js) and hands them here.
+ */
+
+/** Triangles as flat xyz positions (glTF axes: Y up, metres or no unit) and the vertex index of each corner. */
+export interface TriMesh {
+ positions: Float32Array | number[];
+ indices: Uint32Array | number[];
+}
+
+export type PrintFormat = "stl" | "3mf";
+export const PRINT_FORMATS: { id: PrintFormat; label: string; hint: string }[] = [
+ { id: "stl", label: "STL", hint: "Every slicer opens it" },
+ { id: "3mf", label: "3MF", hint: "Keeps the size in millimetres" },
+];
+
+export const MIN_HEIGHT_MM = 5;
+export const MAX_HEIGHT_MM = 2000;
+export const DEFAULT_HEIGHT_MM = 100;
+
+/** A height a printer can take (5 mm to 2 m), else the default. */
+export function printHeight(v: unknown): number {
+ const n = typeof v === "number" ? v : typeof v === "string" && v.trim() ? Number(v) : NaN;
+ if (!Number.isFinite(n) || n <= 0) return DEFAULT_HEIGHT_MM;
+ return Math.min(MAX_HEIGHT_MM, Math.max(MIN_HEIGHT_MM, Math.round(n * 10) / 10));
+}
+
+/**
+ * Vertices at the same place merged (a GLB splits them at UV seams and hard normals, which would read as holes),
+ * within `tolerance` of the model's size; triangles that collapse to a line or a point are dropped.
+ */
+export function weld(mesh: TriMesh, tolerance = 1e-6): { positions: Float64Array; indices: Uint32Array } {
+ const p = mesh.positions;
+ const n = Math.floor(p.length / 3);
+ let size = 0;
+ for (let i = 0; i < p.length; i++) size = Math.max(size, Math.abs(p[i]));
+ const q = (size || 1) * tolerance;
+ const map = new Map<string, number>();
+ const remap = new Uint32Array(n);
+ const out: number[] = [];
+ for (let i = 0; i < n; i++) {
+ const key = `${Math.round(p[3 * i] / q)},${Math.round(p[3 * i + 1] / q)},${Math.round(p[3 * i + 2] / q)}`;
+ let at = map.get(key);
+ if (at === undefined) {
+ at = out.length / 3;
+ map.set(key, at);
+ out.push(p[3 * i], p[3 * i + 1], p[3 * i + 2]);
+ }
+ remap[i] = at;
+ }
+ const idx: number[] = [];
+ const src = mesh.indices;
+ for (let t = 0; t + 2 < src.length; t += 3) {
+ const a = remap[src[t]], b = remap[src[t + 1]], c = remap[src[t + 2]];
+ if (a === b || b === c || a === c) continue;
+ idx.push(a, b, c);
+ }
+ return { positions: Float64Array.from(out), indices: Uint32Array.from(idx) };
+}
+
+export interface WatertightReport {
+ /** Every edge is shared by exactly two triangles: no holes, no extra sheets. */
+ watertight: boolean;
+ triangles: number;
+ /** Edges on one triangle only: the rims of holes. */
+ openEdges: number;
+ /** Edges on three or more triangles: places a slicer can't tell inside from outside. */
+ nonManifoldEdges: number;
+}
+
+/** Whether a (welded) mesh is closed, by counting how many triangles share each edge. */
+export function watertightCheck(mesh: { indices: Uint32Array | number[] }): WatertightReport {
+ const counts = new Map<number, number>();
+ const idx = mesh.indices;
+ let max = 0;
+ for (let i = 0; i < idx.length; i++) max = Math.max(max, idx[i]);
+ const stride = max + 1;
+ for (let t = 0; t + 2 < idx.length; t += 3) {
+ for (const [u, v] of [
+ [idx[t], idx[t + 1]],
+ [idx[t + 1], idx[t + 2]],
+ [idx[t + 2], idx[t]],
+ ]) {
+ const key = Math.min(u, v) * stride + Math.max(u, v);
+ counts.set(key, (counts.get(key) ?? 0) + 1);
+ }
+ }
+ let openEdges = 0;
+ let nonManifoldEdges = 0;
+ for (const c of counts.values()) {
+ if (c === 1) openEdges++;
+ else if (c > 2) nonManifoldEdges++;
+ }
+ const triangles = Math.floor(idx.length / 3);
+ return { watertight: triangles > 0 && openEdges === 0 && nonManifoldEdges === 0, triangles, openEdges, nonManifoldEdges };
+}
+
+/** The model's size along each axis (in its own units). */
+export function bounds(positions: ArrayLike<number>): { min: [number, number, number]; max: [number, number, number]; size: [number, number, number] } {
+ const min: [number, number, number] = [Infinity, Infinity, Infinity];
+ const max: [number, number, number] = [-Infinity, -Infinity, -Infinity];
+ for (let i = 0; i + 2 < positions.length; i += 3) {
+ for (let k = 0; k < 3; k++) {
+ min[k] = Math.min(min[k], positions[i + k]);
+ max[k] = Math.max(max[k], positions[i + k]);
+ }
+ }
+ if (!Number.isFinite(min[0])) return { min: [0, 0, 0], max: [0, 0, 0], size: [0, 0, 0] };
+ return { min, max, size: [max[0] - min[0], max[1] - min[1], max[2] - min[2]] };
+}
+
+/**
+ * The model for the printer: glTF's Y-up turned to Z-up (x, y, z) → (x, −z, y), scaled so it stands `heightMm` tall,
+ * centred on the bed with its lowest point at z = 0. Its footprint in millimetres comes with it.
+ */
+export function toPrintSpace(positions: ArrayLike<number>, heightMm: number): { positions: Float64Array; sizeMm: [number, number, number] } {
+ const n = Math.floor(positions.length / 3);
+ const out = new Float64Array(n * 3);
+ for (let i = 0; i < n; i++) {
+ out[3 * i] = positions[3 * i];
+ out[3 * i + 1] = -positions[3 * i + 2];
+ out[3 * i + 2] = positions[3 * i + 1];
+ }
+ const b = bounds(out);
+ const tall = b.size[2];
+ const k = tall > 0 ? printHeight(heightMm) / tall : 0;
+ const cx = (b.min[0] + b.max[0]) / 2;
+ const cy = (b.min[1] + b.max[1]) / 2;
+ for (let i = 0; i < n; i++) {
+ out[3 * i] = (out[3 * i] - cx) * k;
+ out[3 * i + 1] = (out[3 * i + 1] - cy) * k;
+ out[3 * i + 2] = (out[3 * i + 2] - b.min[2]) * k;
+ }
+ return { positions: out, sizeMm: [b.size[0] * k, b.size[1] * k, b.size[2] * k] };
+}
+
+/** A binary STL (80-byte header, then each triangle's normal and corners as float32, little-endian). */
+export function toStl(positions: ArrayLike<number>, indices: ArrayLike<number>, header = "Fuobe print-ready export, millimetres"): Uint8Array {
+ const tris = Math.floor(indices.length / 3);
+ const buf = new ArrayBuffer(84 + tris * 50);
+ const view = new DataView(buf);
+ const bytes = new Uint8Array(buf);
+ for (let i = 0; i < Math.min(80, header.length); i++) bytes[i] = header.charCodeAt(i) & 0x7f;
+ view.setUint32(80, tris, true);
+ let o = 84;
+ for (let t = 0; t < tris; t++) {
+ const [a, b, c] = [indices[3 * t], indices[3 * t + 1], indices[3 * t + 2]];
+ const pa = [positions[3 * a], positions[3 * a + 1], positions[3 * a + 2]];
+ const pb = [positions[3 * b], positions[3 * b + 1], positions[3 * b + 2]];
+ const pc = [positions[3 * c], positions[3 * c + 1], positions[3 * c + 2]];
+ const u = [pb[0] - pa[0], pb[1] - pa[1], pb[2] - pa[2]];
+ const v = [pc[0] - pa[0], pc[1] - pa[1], pc[2] - pa[2]];
+ const nx = u[1] * v[2] - u[2] * v[1], ny = u[2] * v[0] - u[0] * v[2], nz = u[0] * v[1] - u[1] * v[0];
+ const len = Math.hypot(nx, ny, nz) || 1;
+ for (const f of [nx / len, ny / len, nz / len, ...pa, ...pb, ...pc]) {
+ view.setFloat32(o, f, true);
+ o += 4;
+ }
+ view.setUint16(o, 0, true);
+ o += 2;
+ }
+ return bytes;
+}
+
+const num = (v: number) => (Math.abs(v) < 1e-9 ? "0" : String(Math.round(v * 1e4) / 1e4));
+
+/** The 3MF model part: one object in millimetres. */
+export function threeMfModel(positions: ArrayLike<number>, indices: ArrayLike<number>, name = "Model"): string {
+ const parts: string[] = [];
+ parts.push('<?xml version="1.0" encoding="UTF-8"?>\n<model unit="millimeter" xml:lang="en-US" xmlns="http://schemas.microsoft.com/3dmanufacturing/core/2015/02">\n');
+ parts.push(` <metadata name="Application">Fuobe</metadata>\n <resources>\n <object id="1" name="${name.replace(/[<>&"]/g, "")}" type="model">\n <mesh>\n <vertices>\n`);
+ for (let i = 0; i + 2 < positions.length; i += 3) parts.push(` <vertex x="${num(positions[i])}" y="${num(positions[i + 1])}" z="${num(positions[i + 2])}"/>\n`);
+ parts.push(" </vertices>\n <triangles>\n");
+ for (let t = 0; t + 2 < indices.length; t += 3) parts.push(` <triangle v1="${indices[t]}" v2="${indices[t + 1]}" v3="${indices[t + 2]}"/>\n`);
+ parts.push(' </triangles>\n </mesh>\n </object>\n </resources>\n <build>\n <item objectid="1"/>\n </build>\n</model>\n');
+ return parts.join("");
+}
+
+const CONTENT_TYPES =
+ '<?xml version="1.0" encoding="UTF-8"?>\n<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">' +
+ '<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>' +
+ '<Default Extension="model" ContentType="application/vnd.ms-package.3dmanufacturing-3dmodel+xml"/></Types>\n';
+const RELS =
+ '<?xml version="1.0" encoding="UTF-8"?>\n<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">' +
+ '<Relationship Target="/3D/3dmodel.model" Id="rel0" Type="http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel"/></Relationships>\n';
+
+/** A 3MF: the package (a zip) with its content types, the relationship to the model, and the model. */
+export function toThreeMf(positions: ArrayLike<number>, indices: ArrayLike<number>, name?: string): Uint8Array {
+ const enc = new TextEncoder();
+ return storeZip([
+ { name: "[Content_Types].xml", data: enc.encode(CONTENT_TYPES) },
+ { name: "_rels/.rels", data: enc.encode(RELS) },
+ { name: "3D/3dmodel.model", data: enc.encode(threeMfModel(positions, indices, name)) },
+ ]);
+}
+
+let crcTable: Uint32Array | undefined;
+export function crc32(data: Uint8Array): number {
+ if (!crcTable) {
+ crcTable = new Uint32Array(256);
+ for (let n = 0; n < 256; n++) {
+ let c = n;
+ for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
+ crcTable[n] = c >>> 0;
+ }
+ }
+ let c = 0xffffffff;
+ for (let i = 0; i < data.length; i++) c = crcTable[(c ^ data[i]) & 0xff] ^ (c >>> 8);
+ return (c ^ 0xffffffff) >>> 0;
+}
+
+/** A zip of stored (uncompressed) files: what a 3MF needs, with no compression library. */
+export function storeZip(files: { name: string; data: Uint8Array }[]): Uint8Array {
+ const enc = new TextEncoder();
+ const locals: Uint8Array[] = [];
+ const centrals: Uint8Array[] = [];
+ let offset = 0;
+ for (const f of files) {
+ const name = enc.encode(f.name);
+ const crc = crc32(f.data);
+ const local = new Uint8Array(30 + name.length);
+ const lv = new DataView(local.buffer);
+ lv.setUint32(0, 0x04034b50, true);
+ lv.setUint16(4, 20, true);
+ lv.setUint32(14, crc, true);
+ lv.setUint32(18, f.data.length, true);
+ lv.setUint32(22, f.data.length, true);
+ lv.setUint16(26, name.length, true);
+ local.set(name, 30);
+ const central = new Uint8Array(46 + name.length);
+ const cv = new DataView(central.buffer);
+ cv.setUint32(0, 0x02014b50, true);
+ cv.setUint16(4, 20, true);
+ cv.setUint16(6, 20, true);
+ cv.setUint32(16, crc, true);
+ cv.setUint32(20, f.data.length, true);
+ cv.setUint32(24, f.data.length, true);
+ cv.setUint16(28, name.length, true);
+ cv.setUint32(42, offset, true);
+ central.set(name, 46);
+ locals.push(local, f.data);
+ centrals.push(central);
+ offset += local.length + f.data.length;
+ }
+ const centralSize = centrals.reduce((n, c) => n + c.length, 0);
+ const end = new Uint8Array(22);
+ const ev = new DataView(end.buffer);
+ ev.setUint32(0, 0x06054b50, true);
+ ev.setUint16(8, files.length, true);
+ ev.setUint16(10, files.length, true);
+ ev.setUint32(12, centralSize, true);
+ ev.setUint32(16, offset, true);
+ const out = new Uint8Array(offset + centralSize + 22);
+ let at = 0;
+ for (const part of [...locals, ...centrals, end]) {
+ out.set(part, at);
+ at += part.length;
+ }
+ return out;
+}
+
+export interface PrintExport {
+ data: Uint8Array;
+ mime: string;
+ ext: PrintFormat;
+ report: WatertightReport;
+ sizeMm: [number, number, number];
+}
+
+/** The whole export: weld, check, scale to the height, write the file. */
+export function printExport(mesh: TriMesh, o: { heightMm: number; format: PrintFormat; name?: string }): PrintExport {
+ const welded = weld(mesh);
+ const report = watertightCheck(welded);
+ const placed = toPrintSpace(welded.positions, o.heightMm);
+ const data = o.format === "3mf" ? toThreeMf(placed.positions, welded.indices, o.name) : toStl(placed.positions, welded.indices);
+ return { data, mime: o.format === "3mf" ? "model/3mf" : "model/stl", ext: o.format, report, sizeMm: placed.sizeMm };
+}
+
+/** The check in words, for the dialog. */
+export function watertightLine(r: WatertightReport): string {
+ if (!r.triangles) return "This model has no surfaces to print.";
+ if (r.watertight) return "Watertight: ready for your slicer.";
+ const parts = [r.openEdges ? `${r.openEdges.toLocaleString("en")} open edge${r.openEdges === 1 ? "" : "s"}` : "", r.nonManifoldEdges ? `${r.nonManifoldEdges.toLocaleString("en")} shared by more than two faces` : ""].filter(Boolean);
+ return `Not watertight (${parts.join(", ")}): most slicers repair this when they import it; check the preview before you print.`;
+}
diff --git a/src/server/assist/tools.ts b/src/server/assist/tools.ts
index 14c1bc62..5a76992f 100644
--- a/src/server/assist/tools.ts
+++ b/src/server/assist/tools.ts
@@ -1,4 +1,5 @@
import "server-only";
+import { HI3D_CHAIN_PARAM, HI3D_MODEL, HI3D_OP, HI3D_PARAM } from "@/lib/av/hi3d";
import type Anthropic from "@anthropic-ai/sdk";
import { nanoid } from "nanoid";
import { z } from "zod";
@@ -97,7 +98,7 @@ const searchModels = defineTool({
.string()
.optional()
.describe(
- "Operation id to filter by, e.g. t2i, edit, t2v, i2v, flf2v, ref2v, extend, lipsync, avatar, tts, upscale-image, layers, text-layers, trim, transcribe, captions, mux, separate-audio, translate, write, image-to-3d.",
+ "Operation id to filter by, e.g. t2i, edit, t2v, i2v, flf2v, ref2v, extend, lipsync, avatar, tts, upscale-image, layers, text-layers, trim, transcribe, captions, mux, separate-audio, translate, write, image-to-3d, refine-3d.",
),
query: z.string().optional().describe("Words to match in the model name, vendor or description, e.g. 'kling', 'cheap', 'photoreal'."),
}),
@@ -258,7 +259,7 @@ const Job = z.object({
.string()
.optional()
.describe(
- "Operation id (t2i, edit, t2v, i2v, flf2v, ref2v, extend, tts, layers, transcribe, translate, write, trim, captions, mux, separate-audio, image-to-3d…). Usually inferred from the inputs; set it when ambiguous.",
+ "Operation id (t2i, edit, t2v, i2v, flf2v, ref2v, extend, tts, layers, transcribe, translate, write, trim, captions, mux, separate-audio, image-to-3d, refine-3d…). Usually inferred from the inputs; set it when ambiguous.",
),
images: z.array(ref).optional().describe("Input images: the image to edit, the start frame, or references, in order."),
end_image: ref.optional().describe("End frame (first-and-last-frame video)."),
@@ -266,6 +267,13 @@ const Job = z.object({
audio: ref.optional().describe("Input audio (lipsync, avatar, transcribe, separate-audio, mux; for voice-change the recording to re-voice)."),
background_audio: ref.optional().describe("Mux: a second track mixed under the audio — the background stem from separate-audio, or a music bed."),
voice_audio: ref.optional().describe("A recording of the voice to speak with (voice-cloning text to speech) or to change into (voice-change)."),
+ model3d: ref
+ .optional()
+ .describe("A 3D model (.glb) to work on: rig-3d rigs it; refine-3d (oss-hi3d-refine, Hi3D 1.0, the user's GPU only) refines its geometry from the photo in images (the photo it was made from)."),
+ mesh_resolution: z
+ .union([z.literal(512), z.literal(1024), z.literal(1536)])
+ .optional()
+ .describe("refine-3d: Hi3D's detail, 512 (one pass), 1024 (two, the default) or 1536 (three). On an open image-to-3d model, setting it also refines the model after it is built. The result is geometry only."),
aspect_ratio: z.string().optional().describe("e.g. 16:9, 9:16, 1:1 — one the model lists."),
resolution: z.string().optional().describe("e.g. 1080p, 2K — one the model lists."),
duration: z.number().optional().describe("Seconds, for video and music — one the model lists."),
@@ -331,6 +339,7 @@ function asRequest(j: JobInput): GenerationRequest {
...(j.audio && { audio: j.audio }),
...(j.background_audio && { audio2: j.background_audio }),
...(j.voice_audio && { voiceAudio: j.voice_audio }),
+ ...(j.model3d && { model3d: j.model3d }),
};
const shots = j.shots && j.shots > 1 ? shotList(getModel(currentModelId(j.model_id)), j.shots) : undefined;
return {
@@ -354,7 +363,13 @@ function asRequest(j: JobInput): GenerationRequest {
endTime: j.end_time,
numLayers: j.num_layers,
...(shots && { shots }),
- ...(j.system && { extra: { system: j.system } }),
+ ...((j.system || j.mesh_resolution) && {
+ extra: {
+ ...(j.system && { system: j.system }),
+ // Hi3D: the refine's own resolution, or on an image-to-3D model the refine step after it.
+ ...(j.mesh_resolution && { [j.model_id === HI3D_MODEL || j.op === HI3D_OP ? HI3D_PARAM : HI3D_CHAIN_PARAM]: j.mesh_resolution }),
+ },
+ }),
},
};
}
@@ -366,7 +381,7 @@ function slotFor(kind: MediaKind, op: Operation | undefined): ChainSlot {
// tts clones the earlier audio's voice; voice-change re-voices the earlier audio (its target voice is voice_audio);
// a join takes it as one of its clips.
if (kind === "audio") return { slot: op === "tts" ? "voiceAudio" : op === "audio-join" ? "audios" : "audio" };
- // A mesh goes on to be rigged.
+ // A mesh goes on to be rigged or refined.
if (kind === "model3d") return { slot: "model3d" };
return { slot: "images", position: "first" };
}
diff --git a/src/server/chains.ts b/src/server/chains.ts
index 441b1755..9be2a3c2 100644
--- a/src/server/chains.ts
+++ b/src/server/chains.ts
@@ -2,6 +2,7 @@ import "server-only";
import { nanoid } from "nanoid";
import { getModel, supportsOp } from "@/lib/catalog";
import { MODEL3D_STEP_FEATURE, stillPromptFor3d } from "@/lib/av/model3d";
+import { HI3D_CHAIN_PARAM, HI3D_MODEL, HI3D_OP, HI3D_PARAM, chainedRefine } from "@/lib/av/hi3d";
import { chainTiming, chainedWaitMessage, frameTimes, framesWait, planKeyframeClips, spread } from "@/lib/catalog/keyframes";
import { faceMosaicStep } from "@/lib/catalog/open-tools";
import { dualEngine, onEngine } from "@/lib/catalog/engines";
@@ -425,6 +426,54 @@ export function createStillTo3d(original: GenerationRequest, model: ModelDef, ro
}
}
+/**
+ * Image to 3D's "Refine detail · Hi3D 1.0" (params.extra.hi3dRefine, open engine only): the model the user picked builds
+ * the coarse mesh from the photo, then Hi3D refines that mesh's geometry with the same photo (chain slot model3d) at the
+ * resolution asked for. Both results stay (the refined one is geometry only), in one batch.
+ */
+export function createRefinedModel(original: GenerationRequest, model: ModelDef): Generation[] {
+ const resolution = chainedRefine(original);
+ if (resolution === null) throw new Error("No refine step was asked for");
+ // Hi3D runs on your GPU only (nobody hosts the open model): the model before it runs there too.
+ if (model.engine !== "open") throw new Error("Refine detail runs on your GPU only: pick an open model, or turn Refine detail off");
+ const photo = original.inputs?.images?.[0];
+ if (!photo) throw new Error("Add a photo of the object: Hi3D refines the model from it");
+ const op = original.op ?? "image-to-3d";
+ assertOneMode([
+ { label: model.name, modelId: model.id, op, engine: "open" },
+ { label: "Hi3D 1.0", modelId: HI3D_MODEL, op: HI3D_OP, engine: "open" },
+ ]);
+ const extra = { ...original.params?.extra };
+ delete extra[HI3D_CHAIN_PARAM];
+ const params: GenParams = { ...original.params, extra };
+ if (!Object.keys(extra).length) delete params.extra;
+ const batchId = nanoid(10);
+ const built = createGenerations(
+ { ...original, op, ...(Object.keys(params).length ? { params } : { params: undefined }), step: { label: "3D model", index: 0, of: 2 } },
+ { batchId },
+ )[0];
+ try {
+ const seed = original.params?.seed;
+ const refined = createGenerations(
+ {
+ feature: original.feature,
+ modelId: HI3D_MODEL,
+ op: HI3D_OP,
+ engine: "open",
+ inputs: { images: [photo] },
+ params: { extra: { [HI3D_PARAM]: resolution }, ...(seed !== undefined && { seed }) },
+ chain: [{ slot: "model3d" }],
+ step: { label: "Refined detail", index: 1, of: 2 },
+ },
+ { batchId, dependsOn: built.id },
+ )[0];
+ return withAsked([refined, built], original, "open");
+ } catch (e) {
+ void cancelGeneration(built.id);
+ throw e;
+ }
+}
+
/**
* Fuobe DoP's relight effects (Silhouette, Window, Practicals…): the start frame is relit first (Qwen-Image-Edit 2509
* with its Relight LoRA, on the engine the clip runs on), then animated with the effect's words. One batch of two steps.
diff --git a/src/server/generations.ts b/src/server/generations.ts
index ac0bbfc1..f947f438 100644
--- a/src/server/generations.ts
+++ b/src/server/generations.ts
@@ -55,7 +55,8 @@ import { qwen21Gpu } from "./qwen21-gpu";
import { DETAILS_MAX_IMAGES, GPU_PARAM, QWEN21_SPEED, speedLora } from "@/lib/qwen21-speed";
import { BLOCKED_CARD_MESSAGE, looksBlocked } from "./safety-card";
import { pollTrainings } from "./training";
-import { createEndFrameClip, createExtendChain, createKeyframeFilm, createMosaicRun, createRelitClip, createShotFilm, createStillTo3d, joinClips } from "./chains";
+import { createEndFrameClip, createExtendChain, createKeyframeFilm, createMosaicRun, createRefinedModel, createRelitClip, createShotFilm, createStillTo3d, joinClips } from "./chains";
+import { chainedRefine } from "@/lib/av/hi3d";
import { createRegenerateRun } from "./regenerate";
import { REGEN_MODEL, regenerateGraphLoras } from "@/lib/catalog/regenerate";
import { enhancePrompt, enhanceSoulWords, ideogramCaption } from "./enhance";
@@ -922,6 +923,10 @@ export function createGenerations(given: GenerationRequest, opts: CreateOptions
if (filmRoute && inferOperation(shotModel, original) === "keyframes" && (!opts.dependsOn || framesWait(original))) {
return createKeyframeFilm(original, shotModel, filmRoute, { batchId: opts.batchId, dependsOn: opts.dependsOn });
}
+ // Image to 3D's "Refine detail" (open engine): the model, then Hi3D's refine of its mesh with the same photo.
+ if (!opts.dependsOn && shotModel && shotModel.kind === "model3d" && original.op !== "refine-3d" && chainedRefine(original) !== null) {
+ return createRefinedModel(original, shotModel);
+ }
// Text to 3D on the open engine: a still first, then the 3D model of it. The operation is read as the planner
// reads it (Assist, MCP and API clients usually leave op out).
const stillTo3d = !opts.dependsOn && shotModel && inferOperation(shotModel, original) === "text-to-3d" ? routesFor(shotModel, "text-to-3d").find((r) => r.chained) : undefined;
diff --git a/src/server/gpu/tools.ts b/src/server/gpu/tools.ts
index b4fb10cd..92062b0a 100644
--- a/src/server/gpu/tools.ts
+++ b/src/server/gpu/tools.ts
@@ -1,5 +1,6 @@
import "server-only";
import { DUB_STEP_MODELS } from "@/lib/av/dub";
+import { HI3D_MODEL } from "@/lib/av/hi3d";
import { SPLIT_MODEL } from "@/lib/av/split";
import { REMOVE_DIALOGUE_MODELS } from "@/lib/av/remove-dialogue";
import { CLEAN_MODEL } from "@/lib/av/clean-voice";
@@ -178,6 +179,16 @@ export const STUDIO_ROWS: StudioRowDef[] = [
],
},
{ href: "/upscale", label: "Upscale", group: "Images", config: S.UPSCALE_STUDIO },
+ // hi3d-refine: Image to 3D with "Refine detail · Hi3D 1.0": the default open model, then Hi3D's refine of its mesh.
+ {
+ href: "/image-to-3d",
+ label: "Image to 3D, refined",
+ group: "Images",
+ steps: [
+ { modelId: "oss-pixal3d", op: "image-to-3d" },
+ { modelId: HI3D_MODEL, op: "refine-3d" },
+ ],
+ },
{ href: "/video", label: "Video", group: "Video", config: S.VIDEO_STUDIO },
{ href: "/motion-control", label: "Motion control", group: "Video", config: S.MOTION_CONTROL_STUDIO },
{ href: "/video-edit", label: "Edit video", group: "Video", config: S.VIDEO_EDIT_STUDIO },
diff --git a/src/server/model3d-finish.ts b/src/server/model3d-finish.ts
index 1f8503cc..63b906af 100644
--- a/src/server/model3d-finish.ts
+++ b/src/server/model3d-finish.ts
@@ -37,9 +37,9 @@ const PROGRESS_EVERY_MS = 2_000;
const isGlb = (o: OutputFile) => o.kind === "model3d" && (o.contentType === "model/gltf-binary" || /\.glb(\?|$)/i.test(o.url));
-/** Which output a finish works on: the first GLB of an image-to-3D job from ComfyUI (not a scene, splat or rig). */
+/** Which output a finish works on: the first GLB of an image-to-3D job (or Hi3D's refine of one) from ComfyUI (not a scene, splat or rig). */
export function modelToFinish(r: { provider: string; op: string }, outputs: OutputFile[]): number {
- if (r.provider !== "comfyui" || r.op !== "image-to-3d") return -1;
+ if (r.provider !== "comfyui" || (r.op !== "image-to-3d" && r.op !== "refine-3d")) return -1;
return outputs.findIndex((o) => isGlb(o) && !!o.assetId && !o.meta?.finish && !o.meta?.role);
}
diff --git a/src/server/providers/comfyui.ts b/src/server/providers/comfyui.ts
index 70a0fb2c..770659e9 100644
--- a/src/server/providers/comfyui.ts
+++ b/src/server/providers/comfyui.ts
@@ -40,6 +40,7 @@ import {
type ManifestOutput,
type ManifestWorkflow,
} from "@/lib/comfy";
+import { HI3D_PARAM, strictHi3dResolution } from "@/lib/av/hi3d";
import { fpsPlan } from "@/lib/av/fps";
import { resolveWorkflowId } from "@/lib/comfy-variants";
import { DECODER_PARAM, editCanvas, GPU_PARAM, LIGHTNING_GRAPHS, lightningSigmas, SPEED_PARAM, ZEN_ADAPTER, ZEN_ENCODER } from "@/lib/qwen21-speed";
@@ -1228,6 +1229,8 @@ export async function prepareWorkflow(endpointTemplate: string, input: GenInput,
video3: clips[2],
video4: clips[3],
audio: input.audio,
+ // A 3D model to work on (Hi3D's refine reads the coarse GLB from ComfyUI's input folder, where it was uploaded).
+ model3d: input.model3d,
seed: input.seed !== undefined && input.seed >= 0 ? input.seed : randomSeed(),
};
// A multi-view 3D model: each photo goes to its side.
@@ -1663,6 +1666,13 @@ export async function prepareWorkflow(endpointTemplate: string, input: GenInput,
const canvas = lightningCanvas(manifest.capability, values, ctx.media?.(String(values.image ?? "")));
if (canvas) values.sigmas = lightningSigmas(canvas.width, canvas.height);
}
+ // Hi3D's refine: the mesh to refine is needed, and the resolution is one the model takes (512, 1024, 1536).
+ if (b.model3d && !values.model3d) throw new ProviderError("Add the 3D model to refine");
+ if (b.meshResolution && extra[HI3D_PARAM] !== undefined) {
+ const r = strictHi3dResolution(extra[HI3D_PARAM]);
+ if (r === null) throw new ProviderError("Hi3D refines at 512, 1024 or 1536");
+ extra[HI3D_PARAM] = r;
+ }
for (const [k, v] of Object.entries(extra)) values[k as BindingKey] = v;
// SeedVR2's `scale` multiplies the picture before one diffusion pass over all of it, and its graph is made for up to
// limits.maxWidth × maxHeight: the multiplier comes down to fit the picture (a 3000 × 2000 photo at the template's 4x
diff --git a/src/server/providers/mock.ts b/src/server/providers/mock.ts
index 1f8bfff4..83a399c9 100644
--- a/src/server/providers/mock.ts
+++ b/src/server/providers/mock.ts
@@ -322,6 +322,9 @@ function demoOutputs(op: Operation | undefined, kind: MediaKind, prompt: string,
return [{ url: "sample:demo-model.glb", kind: "model3d", contentType: "model/gltf-binary", meta: { demo: true, format: "glb", splat: true } }];
case "rig-3d":
return [{ url: "sample:demo-model.glb", kind: "model3d", contentType: "model/gltf-binary", meta: { demo: true, format: "glb", rigged: true } }];
+ // Hi3D's refine: the demo mesh, geometry only as the real one is.
+ case "refine-3d":
+ return [{ url: "sample:demo-model.glb", kind: "model3d", contentType: "model/gltf-binary", meta: { demo: true, format: "glb", refined: true, geometryOnly: true } }];
case "ocr":
return [demoOcr(brief)];
// As many frames as were asked for (max_frames), 4 without a count.
diff --git a/workflows/comfyui/packs.json b/workflows/comfyui/packs.json
index 107f63b9..5dcfed9e 100644
--- a/workflows/comfyui/packs.json
+++ b/workflows/comfyui/packs.json
@@ -296,5 +296,14 @@
"isolated": false,
"subdir": null,
"folders": []
+ },
+ "Comfyui-Hi3d-T8": {
+ "repo": "https://github.com/T8mars/Comfyui-Hi3d-T8",
+ "commit": "73848490976e6a9b0c735ce02984c03866a495e7",
+ "registry": { "id": "hi3d-t8", "version": "" },
+ "requirementsTxt": true,
+ "isolated": false,
+ "subdir": null,
+ "folders": []
}
}