{"record":{"id":"f37d13895924decb","repo":"Comfy-Org/ComfyUI","slug":"da3geometrytomesh-produced-an-empty-mesh-try-rais","errorCode":null,"errorMessage":"DA3GeometryToMesh produced an empty mesh. Try raising discontinuity_threshold, lowering confidence_threshold, or disabling use_sky_mask.","messagePattern":"DA3GeometryToMesh produced an empty mesh\\. Try raising discontinuity_threshold, lowering confidence_threshold, or disabling use_sky_mask\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_extras/nodes_depth_anything_3.py","lineNumber":553,"sourceCode":"        E = _da3_get_extrinsic(da3_geometry, batch_index)\n        if E is not None:\n            points = _da3_apply_extrinsic(points, E)\n\n        # Mask invalid pixels by setting them to inf so triangulate_grid_mesh skips them.\n        mask = _da3_build_mask(da3_geometry, batch_index, H, W, confidence_threshold, use_sky_mask)\n        # Also exclude pixels where depth was invalid.\n        mask = mask & (depth_all[batch_index] > 0) & torch.isfinite(depth_all[batch_index])\n        points = points.clone()\n        points[~mask] = float('inf')\n\n        verts, faces, uvs = triangulate_grid_mesh(\n            points,\n            decimation=decimation,\n            discontinuity_threshold=discontinuity_threshold,\n            depth=depth,\n        )\n        if verts.shape[0] == 0 or faces.shape[0] == 0:\n            raise ValueError(\n                \"DA3GeometryToMesh produced an empty mesh. \"\n                \"Try raising discontinuity_threshold, lowering confidence_threshold, \"\n                \"or disabling use_sky_mask.\"\n            )\n\n        # OpenCV (X right, Y down, Z forward) → glTF (X right, Y up, Z back).\n        # Same transform as MoGePointMapToMesh perspective branch.\n        verts = verts * torch.tensor([1.0, -1.0, -1.0], dtype=verts.dtype)\n        faces = faces[:, [0, 2, 1]].contiguous()\n\n        tex = da3_geometry[\"image\"][batch_index:batch_index + 1] if texture else None\n        mesh = Types.MESH(\n            vertices=verts.unsqueeze(0),\n            faces=faces.unsqueeze(0),\n            uvs=uvs.unsqueeze(0),\n            texture=tex,\n        )\n        return io.NodeOutput(mesh)","sourceCodeStart":535,"sourceCodeEnd":571,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_extras/nodes_depth_anything_3.py#L535-L571","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"# estimate rejection rate before meshing\nmask = torch.isfinite(depth) & (depth > 0)\nif 'confidence' in da3_geometry:\n    mask &= da3_geometry['confidence'][batch_index] >= confidence_threshold\nif use_sky_mask and 'sky' in da3_geometry:\n    mask &= da3_geometry['sky'][batch_index] < 0.5\nif mask.float().mean() < 0.02:\n    raise ValueError('filters reject ~all pixels; relax thresholds or disable use_sky_mask')","typeGuard":null,"tryCatchPattern":"try:\n    mesh = build_mesh(geometry, batch_index, decimation, 0.05, 0.3, True, True)\nexcept ValueError as e:\n    if 'empty mesh' in str(e):\n        mesh = build_mesh(geometry, batch_index, decimation, 0.0, 1.0, False, True)  # relaxed retry\n    else:\n        raise","preventionTips":["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."],"tags":["comfyui","depth-anything-3","mesh","filtering"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}