Nodes/ComfyUI-ComfyUI-Hunyuan3DWrapper/Hy3D Set Mesh PBR Textures
ComfyUI Node

Hy3D Set Mesh PBR Textures

Swap in your own PBR maps — base color, metallic/roughness, normal, the lot

By kijai·Created 2 years ago·Updated 5 months ago· 1,033
Hy3D Set Mesh PBR Textures
  • trimesh
  • image
  • trimesh
texture

Hy3DSetMeshPBRTextures lets you write your own texture channels onto a Hunyuan3D mesh. Give it a TRIMESH and an IMAGE, pick which PBR slot you're filling - base color, emissive, metallic/roughness, normal, or occlusion - and it stamps that image into the mesh's material. The result stays a TRIMESH, ready to keep flowing through the graph or out to export.

This is the node that makes the wrapper's PBR story actually editable. The whole selling point of Hunyuan3D 2.1's texturing is that it doesn't hand you one baked diffuse map - it hands you physical material channels a game engine can relight. But the baked result is rarely perfect. This node is how you fix it: replace the base color with your own paint, drop in a hand-tuned normal map, or swap the roughness channel so that metal reads as metal.

How it works

One small but nice detail: if the mesh's material is a plain SimpleMaterial, the node auto-converts it to a PBR material first, so you never hit a "can't set that on this material" wall. Then it takes your IMAGE, converts it to a PIL image (RGBA if it has an alpha channel, RGB otherwise), and assigns it to the chosen slot on a copy of the mesh.

The texture dropdown is the whole interface:

  • base_color - the albedo/diffuse map
  • metallic_roughness - the combined metal/roughness map
  • normal - tangent-space normal map
  • emissive - the glow map
  • occlusion - ambient occlusion

Pair it with Hy3DSetMeshPBRAttributes for the scalar factors (metallic factor, roughness factor, etc.) that scale these maps - same material, different knob. And Hy3DGetMeshPBRTextures is the read-side sibling if you want to pull a channel back out as an image to edit.

Where it sits

After the bake/apply stages and before export, in the polish pass:

Hy3DApplyTexture → Hy3DSetMeshPBRTextures (base_color) → Hy3DExportMesh

It's pure material surgery - no model load, no VRAM, instant. Run it as many times as you like, on as many channels as you like, and each call layers another edit onto the mesh.

Install

Pack-level: Manager search "Hunyuan3DWrapper", or git clone https://github.com/kijai/ComfyUI-Hunyuan3DWrapper, then pip install -r requirements.txt. This node itself needs nothing beyond trimesh; the render/bake stages upstream are the ones with the compiled custom_rasterizer wheel requirement on Windows.

Common issues

  • The image doesn't stick - the IMAGE you fed is the wrong shape or channel count for the slot (e.g. feeding an RGB image where the material expects RGBA). Most maps are fine as RGB; if something looks off after export, check the channel count.
  • Mesh still renders gray - you set a texture but the material's scalar factors (via Hy3DSetMeshPBRAttributes) are telling the renderer to ignore it, e.g. metallicFactor 0 + no baseColor in the shader. Set the attributes to match.
  • "SimpleMaterial" confusion - if you see the auto-conversion log line, that's normal and expected; it's working, not erroring.
CategoryHunyuan3DWrapper

Inputs (3)

NameTypeDefaultDescription
trimeshTRIMESH
imageIMAGE
textureCOMBO5 options: base_color, emissive, metallic_roughness, normal, occlusion

Outputs (1)

NameTypeDescription
trimeshTRIMESH