Comfy-Org/ComfyUI · error · ValueError
DA3GeometryToMesh produced an empty mesh. Try raising discon
Error message
DA3GeometryToMesh produced an empty mesh. Try raising discontinuity_threshold, lowering confidence_threshold, or disabling use_sky_mask.
What it means
DA3 mesh node raises this when triangulate_grid_mesh returns zero vertices or zero faces — every candidate triangle was rejected. Rejections come from the validity mask (confidence below threshold, sky pixels with use_sky_mask, invalid/zero/non-finite depth) and from discontinuity_threshold culling across depth edges.
Source
Thrown at comfy_extras/nodes_depth_anything_3.py:553
E = _da3_get_extrinsic(da3_geometry, batch_index)
if E is not None:
points = _da3_apply_extrinsic(points, E)
# Mask invalid pixels by setting them to inf so triangulate_grid_mesh skips them.
mask = _da3_build_mask(da3_geometry, batch_index, H, W, confidence_threshold, use_sky_mask)
# Also exclude pixels where depth was invalid.
mask = mask & (depth_all[batch_index] > 0) & torch.isfinite(depth_all[batch_index])
points = points.clone()
points[~mask] = float('inf')
verts, faces, uvs = triangulate_grid_mesh(
points,
decimation=decimation,
discontinuity_threshold=discontinuity_threshold,
depth=depth,
)
if verts.shape[0] == 0 or faces.shape[0] == 0:
raise ValueError(
"DA3GeometryToMesh produced an empty mesh. "
"Try raising discontinuity_threshold, lowering confidence_threshold, "
"or disabling use_sky_mask."
)
# OpenCV (X right, Y down, Z forward) → glTF (X right, Y up, Z back).
# Same transform as MoGePointMapToMesh perspective branch.
verts = verts * torch.tensor([1.0, -1.0, -1.0], dtype=verts.dtype)
faces = faces[:, [0, 2, 1]].contiguous()
tex = da3_geometry["image"][batch_index:batch_index + 1] if texture else None
mesh = Types.MESH(
vertices=verts.unsqueeze(0),
faces=faces.unsqueeze(0),
uvs=uvs.unsqueeze(0),
texture=tex,
)
return io.NodeOutput(mesh)View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Raise discontinuity_threshold (fewer edge-based rejections).
- Lower confidence_threshold.
- Disable use_sky_mask.
- If still empty, the depth map itself is degenerate — try a different resolution or model.
Defensive patterns
Strategy: fallback
Validate before calling
# estimate rejection rate before meshing
mask = torch.isfinite(depth) & (depth > 0)
if 'confidence' in da3_geometry:
mask &= da3_geometry['confidence'][batch_index] >= confidence_threshold
if use_sky_mask and 'sky' in da3_geometry:
mask &= da3_geometry['sky'][batch_index] < 0.5
if mask.float().mean() < 0.02:
raise ValueError('filters reject ~all pixels; relax thresholds or disable use_sky_mask') Try / catch
try:
mesh = build_mesh(geometry, batch_index, decimation, 0.05, 0.3, True, True)
except ValueError as e:
if 'empty mesh' in str(e):
mesh = build_mesh(geometry, batch_index, decimation, 0.0, 1.0, False, True) # relaxed retry
else:
raise Prevention
- Start with permissive settings (low discontinuity threshold, high/zero confidence threshold, sky mask off) and tighten gradually.
- Sky-heavy images and low-confidence maps are the usual culprits — check mask coverage before meshing.
- Disable use_sky_mask for landscape/sky-dominant frames.
When it happens
Trigger: Aggressive filtering: confidence_threshold near 1.0 on a low-confidence map, use_sky_mask=True on a mostly-sky image, or discontinuity_threshold near 0 discarding all triangles; also fully-invalid depth (all NaN/zero) after the non-finite cleanup.
Common situations: Reusing mesh settings tuned for indoor scenes on sky-dominated landscape images; Small/Base models whose confidence maps read low; extremely noisy depth from out-of-distribution images.
Related errors
- batch_index {batch_index} is out of range; DA3_GEOMETRY has
- DA3GeometryToPointCloud produced zero points after filtering
- multi-view mode requires Small or Base model. The loaded mod
- pose_method='cam_dec' requires a camera decoder, but the loa
- pose_method='ray_pose' requires a DualDPT head, but the load
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/f37d13895924decb.
Report an issue: GitHub.