Skip to content

feat: Extend Save3D to save vertex colors and textures (CORE-189)#13824

Merged
kijai merged 12 commits into
Comfy-Org:masterfrom
kijai:save_3d_update
May 13, 2026
Merged

feat: Extend Save3D to save vertex colors and textures (CORE-189)#13824
kijai merged 12 commits into
Comfy-Org:masterfrom
kijai:save_3d_update

Conversation

@kijai

@kijai kijai commented May 10, 2026

Copy link
Copy Markdown
Collaborator
  • Split GLB save logic out of nodes_hunyuan3d.py into a new nodes_save_3d.py, and extend the writer to support UVs, per-vertex colors, and embedded baseColor textures.
  • Extend the MESH type with optional uvs, vertex_colors, and texture fields so meshes can carry texture data through the graph.
  • Add pack_variable_mesh_batch / get_mesh_batch_item helpers and switch VoxelToMesh / VoxelToMeshBasic to use them so batches with differing vertex/face counts no longer fail at torch.stack.
@coderabbitai

coderabbitai Bot commented May 10, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR extends the MESH type to carry optional UVs, per-vertex colors, and a texture tensor; adds pack_variable_mesh_batch and get_mesh_batch_item for ragged per-item meshes; implements save_glb to write GLB files (including optional UVs/colors/embedded PNG textures); adds a SaveGLB ComfyUI node and Save3DExtension entrypoint; registers nodes_save_3d.py for startup loading; and updates VoxelToMesh nodes to return either stacked MESH batches or packed variable-size batches when shapes differ.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.69% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: extending Save3D functionality to support vertex colors and textures, which is the primary objective of the PR.
Description check ✅ Passed The description comprehensively covers the PR's changes: refactoring GLB save logic, extending the MESH type with new fields, and adding batch helpers for variable-sized meshes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@comfy_extras/nodes_save_3d.py`:
- Around line 20-57: The pack_variable_mesh_batch helper currently discards
texture data; update pack_variable_mesh_batch to accept a textures parameter
(e.g., textures=None), validate and pack per-item textures analogously to
colors/uvs (compute max_textures, create packed_textures, texture_counts tensor,
copy slices), and attach them to the returned Types.MESH as mesh.texture and
mesh.texture_counts; if mixed texture sizes are not supported, explicitly raise
a clear error inside pack_variable_mesh_batch instead of dropping textures so
SaveGLB.execute and other consumers receive or fail on texture data
consistently.
- Around line 100-118: Before serializing in the block that converts tensors to
numpy (symbols: vertices, faces, uvs, vertex_colors, vertices_np, faces_np,
uvs_np, colors_np), add validation: ensure faces is a 2D integer array with all
indices >=0 and < vertices.shape[0]; ensure uvs (if not None) has first-dim
length equal to vertices.shape[0] (or to faces.shape[0] depending on your UV
convention) and shape[1]==2; ensure vertex_colors (if not None) has first-dim
length equal to vertices.shape[0] and values in [0,1]; if any check fails raise
a clear exception describing the mismatch and which array failed so the exporter
fails fast instead of producing an invalid GLB.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 71d3745e-c0c5-4366-90ab-faa160ccccfe

📥 Commits

Reviewing files that changed from the base of the PR and between aa9d2fc and 16bcf4b.

📒 Files selected for processing (4)
  • comfy_api/latest/_util/geometry_types.py
  • comfy_extras/nodes_hunyuan3d.py
  • comfy_extras/nodes_save_3d.py
  • nodes.py
Comment thread comfy_extras/nodes_save_3d.py Outdated
Comment thread comfy_extras/nodes_save_3d.py
jtydhr88
jtydhr88 previously approved these changes May 11, 2026

@jtydhr88 jtydhr88 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

alexisrolland
alexisrolland previously approved these changes May 12, 2026
@alexisrolland

Copy link
Copy Markdown
Member

Tested and working fine.

@kijai kijai merged commit 8505abf into Comfy-Org:master May 13, 2026
14 checks passed
simonri pushed a commit to simonri/ComfyUI-flash-attention-3 that referenced this pull request May 26, 2026
…mfy-Org#13824)

Split GLB save logic out of nodes_hunyuan3d.py into a new nodes_save_3d.py, and extend the writer to support UVs, per-vertex colors, and embedded baseColor textures.

Extend the MESH type with optional uvs, vertex_colors, and texture fields so meshes can carry texture data through the graph.

Add pack_variable_mesh_batch / get_mesh_batch_item helpers and switch VoxelToMesh / VoxelToMeshBasic to use them so batches with differing vertex/face counts no longer fail at torch.stack.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants