Extensions/ComfyUI-Direct3D-V3
ComfyUI Extension

ComfyUI-Direct3D-V3

ComfyUI nodes for Direct3D-V3: refine a coarse mesh into a detailed one from a reference image (INT8 weights supported).

By visualbruno·Created 5 days ago·Updated about 16 hours ago· 0
visualbruno/ComfyUI-Direct3D-V3
Nodes—
On cloudLocal install
Stars0
Updatedabout 16 hours ago
Readme

ComfyUI-Direct3D-V3

ComfyUI nodes for Direct3D-V3. Direct3D-V3 turns a coarse mesh that is aligned with a reference image into a detailed one. It refines the shape in stages: 512³, then 1024³, then 1536³.

The default model is the INT8 version, MostAadTech/Direct3D-V3-INT8. Each stage is 1.3 GB instead of 5 GB, and the output is very close to FP16. Meshes use ComfyUI's native MESH type. They come in directly from VecShape Image to Mesh or Get 3D Components, and go out to Save 3D Model (SaveGLB) and the core mesh nodes.

Requirements

  • An NVIDIA GPU that FlashAttention 2 supports, and flash-attn 2.x installed in the ComfyUI environment. On Windows, use a prebuilt wheel that matches your Python, torch and CUDA versions.

  • The two CUDA extensions, fillhole_cpp and cudavoxelize. Prebuilt wheels are in wheels/:

    | Folder | Python | torch | CUDA | | --- | --- | --- | --- | | wheels/windows | 3.13 | 2.10 | 13.0 | | wheels/windows | 3.13 | 2.11 | 12.8 | | wheels/linux (x86_64) | 3.13 | 2.11 | 12.8 |

    A wheel only works with the torch minor version and CUDA major version it was built for; the file name says which (e.g. +torch2.11.cu128). The wheels target every GPU architecture torch supports (sm_75 to sm_120).

    install.py installs the wheel that matches the running Python, torch and CUDA build. ComfyUI-Manager runs it on install, and the node pack also runs it at startup if an extension can't be imported. You can also run it by hand with the ComfyUI Python. For other versions, build wheels with third_party/build_wheels.py; its docstring explains how. Use a CUDA toolkit with the same major version as torch, and on Windows run it from an "x64 Native Tools" prompt.

  • Python dependencies:

    pip install -r requirements.txt
    

Models

Models live in ComfyUI/models/direct3d_v3/<name>/, laid out like the Hugging Face repositories (model_index.json, shape_transformers_512/, …_1024/, …_1536/, optionally image_encoder/). Load Direct3D-V3 Model lists every such folder, plus two models it can download:

| Name | Repository | Size | | --- | --- | --- | | Direct3D-V3-INT8 (default) | MostAadTech/Direct3D-V3-INT8 | 3 × 1.3 GB + 1.6 GB image encoder | | Direct3D-V3 | wushuang98/Direct3D-V3 | 3 × 5 GB (FP32) + image encoder |

A folder may hold only some stages, for example just shape_transformers_1536/ for 1536-only use. The loader uses whatever is present.

The DINOv3 image encoder comes from the model's image_encoder/ folder. If that folder is missing, a cached facebook/dinov3-vith16plus-pretrain-lvd1689m is used. If that isn't cached either, the folder is downloaded from the model's repository. BiRefNet (ZhengPeng7/BiRefNet) downloads to the Hugging Face cache the first time it's needed. Once everything is cached, loading doesn't contact the Hub.

Nodes

| Node | Purpose | | --- | --- | | Load Mesh | Loads an OBJ, GLB, glTF, PLY, STL or OFF file as a MESH, for example a coarse mesh made in another tool, without VecShape. Pick a file from ComfyUI/input/ (subfolders such as input/3d included), upload one with the button, or type an absolute path in path. Scene parts are merged with their transforms; coordinates are kept as stored. The node reloads when the file changes on disk. | | Load Direct3D-V3 Model | Prepares the pipeline. Stage weights are read only when a generation needs them. | | Direct3D-V3 Refine Mesh (Multiview) | Same as Refine Mesh, plus optional back, left, right, top and bottom images, each with an optional mask. See Multiview. | | Direct3D-V3 Refine Mesh | Takes an image, a coarse MESH and an optional mask. Outputs a detailed MESH, plus the conditioning_image the model saw. |

Loader options

  • precision
    • auto (default) keeps the stored format: INT8 stays INT8 in memory and is expanded to FP16 layer by layer, and full-precision checkpoints run in FP16.
    • fp16 expands INT8 to FP16, which uses about 1 GB more VRAM.
    • fp8 stores full-precision weights in FP8. It's only for the original model, and it is less accurate than INT8.
  • offload
    • model (default) keeps models in RAM and moves only the active one to the GPU.
    • disk reads each model from disk when it's needed and frees it afterwards. This uses the least RAM.
    • none keeps every stage on the GPU.
  • image_encoder: see Models.

Refine Mesh parameters

  • resolution: the final stage.
  • start_from: the first stage. 512 (default) runs the full cascade, 512 → 1024 → 1536, as the model was designed. A higher value skips the lower stages and voxelizes the coarse mesh directly at that stage. That's faster, but the coarse mesh must already be close to the final shape.
  • steps / guidance_scale: these apply to every stage. The defaults, 15 and 4.0, are the model's own. A guidance scale of 1 or less runs one pass per step instead of two.
  • target_faces: the final mesh is simplified to this many triangles with pyfqmr. 0 keeps every triangle.
  • max_tokens (advanced): the maximum number of sparse patches per stage. Lower it if you run out of VRAM.
  • mc_threshold (advanced): the surface-extraction threshold. −1 uses each stage's own value.
  • mask: white is the object. Without a mask or an alpha channel, the node segments the image with BiRefNet. The MASK output of Load Image is inverted alpha, so pass it through Invert Mask first.

Each image in a batch produces one mesh with seed + i.

Multiview

Direct3D-V3 sees a single image, so it has to invent every side that image doesn't show. The back is often smooth and plain. Direct3D-V3 Refine Mesh (Multiview) adds reference images of the other sides:

  • How it works: for each extra view, the sparse voxel grid is turned by a quarter turn, so that view's camera sits where the model expects the front camera. The model then predicts the shape with that view's image, and the prediction is turned back. Quarter turns are exact voxel re-indexings, so nothing is resampled.

  • Blending: at every sampling step, each surface patch blends the views by how directly they face it, using the coarse mesh's normals. The back follows the back image, the front follows the front image, and the sides blend. Because all views share one noisy state, they converge on one consistent shape.

  • Camera conventions: these follow real photos taken around the object, with nothing mirrored.

    | View | Camera | What the image shows | | --- | --- | --- | | back | behind the object | The model's left side is on the image's left. | | left | on the model's left | The model's front is on the image's left. | | right | on the model's right | The model's front is on the image's right. | | top | above | The model's front is at the image's bottom edge. | | bottom | below | The model's front is at the image's top edge. |

  • Image style: views are cropped to their foreground like the front image, so the framing doesn't need to match exactly. The silhouette and proportions should still match the coarse mesh.

  • Cost: each connected view adds about one more full sampling pass. Front + back takes about twice the time of a single view. VRAM barely changes, because the views run one after another.

  • view_sharpness (advanced): how sharply each patch follows the view that faces it most. The default is 2; higher values blend less at the transitions.

  • conditioning_images: shows the front and then each connected view, as the model received them. coarse_mesh can hold one mesh for every image, or one per image.

Performance (RTX 3080 Laptop, 16 GB, INT8, Tavern example)

| Resolution | Peak VRAM | Time | | --- | --- | --- | | 512 (2 steps) | 2.9 GB | 33 s | | 1024 (15 steps, CFG 4) | 7.5 GB | 558 s | | 1024, 8 steps | 7.7 GB | 343 s | | 1024, start_from 1024 | 7.7 GB | 501 s |

These are mean surface distances to the FP16 infer.py mesh (15 steps, full cascade), measured on the 1024 grid. The sampling noise floor is 0.36 voxels.

| Run | Mean distance | | --- | --- | | Default settings | 0.51 voxels | | 8 steps | 0.92 voxels | | start_from 1024 | 1.96 voxels (max 34) |

At 1024, skipping the 512 stage saves little time and changes the shape the most.

The example workflow is in example_workflows/VecShape - SingleView.json: Load Image → VecShape → Direct3D-V3 → Save 3D Model.

Notes

  • direct3d/ is vendored from the Direct3D-V3 repository, with these changes:
    • Lazy loading: stages load only when needed, and the offload modes free memory between stages.
    • Lower activation memory: large token tensors are processed in chunks, and intermediates are freed early.
    • Quantized checkpoints: INT8 (direct3d-v3-w8g32) and FP8 checkpoints are supported.
    • Cheaper guidance: the unconditional CFG pass is skipped on steps outside the model's guidance interval (0.1–0.9), where its weight is 1. Where it does run, its cross-attention over an all-zero image context is replaced by the constant row it always produces. That is bit-identical and makes the pass about 13% faster. Together, 15 steps cost about 16% less.
    • start_resolution: lets the pipeline begin at a higher stage.
    • views: multiview refinement, implemented in direct3d/multiview.py. The idea comes from the multiview node by @MostAadTech; this is a separate implementation.
  • third_party/ holds the sources of the two CUDA extensions. fillhole_kernel.cu includes torch/types.h instead of torch/extension.h, which lets it compile with MSVC 2019 + nvcc.
  • ComfyUI's --fast fp16_accumulation also applies to Direct3D-V3. On one 1024 forward pass, it made the pass about 10% faster and changed the inside/outside sign of 0.37% of samples instead of 0.34% (both measured against FP16 weights), which is negligible.

License

The Direct3D-V3 code and geometry weights are under the MIT license (see LICENSE). The DINOv3 image encoder is under Meta's DINOv3 License.