Nodes/Avatar Graph/Object Bake
ComfyUI Node

Object Bake

Flattening Avatar Graph's 3D mesh into a 2D texture

By avatechai·Created 3 years ago·Updated 2 years ago· 264
Object Bake
  • BPY_OBJ
  • BPY_OBJ
type
pass_filter
filepath
width512
height512
margin16
margin_type
use_selected_to_activefalse
max_ray_distance0.00
cage_extrusion0.00
cage_object
normal_space
normal_r
normal_g
normal_b
target
save_mode
use_clearfalse
use_cagefalse
use_split_materialsfalse
use_automatic_namefalse
uv_layer

This is the most parameter-dense single-purpose node in the pack, and it's doing real work: Object Bake takes whatever's happening on a 3D mesh - lighting, ambient occlusion, normals, a combined render - and flattens it down into a 2D texture image, using the mesh's UV layout to decide where each part of the surface lands on the texture. In Avatar Graph's actual pipeline, this is how you'd generate a texture that accounts for the mesh's own shading (say, baked ambient occlusion for extra depth) rather than only ever painting flat, unlit textures onto your avatar's mesh layers.

How it works

It wraps Blender's full Bake operator, which is why there are so many options - Blender's own bake panel has this many settings too. The core idea: pick a type of data to bake (COMBINED for a full lit render, AO for ambient occlusion, NORMAL for a normal map, UV, ROUGHNESS, and several more), point it at where to write results (target: IMAGE_TEXTURES or VERTEX_COLORS), and Blender projects that data onto the mesh's UV space and writes it out.

The inputs and outputs that matter

The handful that actually drive most bakes:

  • type - what you're baking: COMBINED, AO, NORMAL, DIFFUSE, EMIT, and others. This is the single most important setting - everything else configures how the bake happens, this decides what gets baked.
  • width / height (both default 512) - output texture resolution. Bump these up for a final asset, keep them low while iterating to bake faster.
  • margin (default 16) - padding in pixels around each UV island, so texture bleeding doesn't leave visible seams where UV islands meet.
  • use_selected_to_active (default false) - bakes from one or more selected source objects onto a single active target, the setup you'd use for baking detail from a high-poly reference mesh onto a simpler one.
  • normal_space, normal_r, normal_g, normal_b - only relevant if type is NORMAL, controlling the normal map's coordinate convention.
  • filepath - where to write the result if you're saving externally rather than baking into an existing image texture (save_mode: INTERNAL vs EXTERNAL).

Output is a single BPY_OBJ, the object the bake was applied to - note that the baked result itself is written to a texture/image, not returned as a separate IMAGE output on this node, so pull the result via whatever texture or file path you configured.

How to install it

ComfyUI Manager, search "Avatar Graph" and install, or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/avatechai/avatar-graph-comfyui

then pip install -r requirements.txt and restart. Needs Blender's bpy module, pinned to Python 3.10.x - a dedicated conda environment on macOS/Linux, or Avatech's prebuilt Python-3.10 ComfyUI zip on Windows with the pack installed through Manager afterward.

Common issues & troubleshooting

If the node won't load, that's the pack's Python-version pin - check ComfyUI's startup console for an import error and confirm a clean Python 3.10.x environment with requirements.txt installed.

If the bake produces a blank or mostly-empty texture, the two usual causes are a missing or overlapping UV layout (bake results land wherever UVs put them, so bad UVs mean a bad bake - run UV Copy or fix the unwrap first) or picking the wrong type for what you actually wanted (a COMBINED bake on an unlit scene produces very different results than AO). Since Blender's bake is also genuinely CPU/GPU-render-engine dependent, a bake that produces nothing at all is also worth checking against whatever render engine and device your headless Blender instance is actually configured to use, rather than assuming this node is broken.

Categoryblender

Inputs (23)

NameTypeDefaultDescription
BPY_OBJoptBPY_OBJ
typeoptCOMBO12 options: COMBINED, AO, SHADOW, POSITION, NORMAL, UV, +6
pass_filteroptCOMBO8 options: NONE, EMIT, DIRECT, INDIRECT, COLOR, DIFFUSE, +2
filepathoptSTRING
widthoptINT5121–2147483647
heightoptINT5121–2147483647
marginoptINT160–2147483647
margin_typeoptCOMBO2 options: ADJACENT_FACES, EXTEND
use_selected_to_activeoptBOOLEANfalse
max_ray_distanceoptFLOAT0.000–3.402823466385289e+38
cage_extrusionoptFLOAT0.000–3.402823466385289e+38
cage_objectoptSTRING
normal_spaceoptCOMBO2 options: OBJECT, TANGENT
normal_roptCOMBO6 options: POS_X, POS_Y, POS_Z, NEG_X, NEG_Y, NEG_Z
normal_goptCOMBO6 options: POS_X, POS_Y, POS_Z, NEG_X, NEG_Y, NEG_Z
normal_boptCOMBO6 options: POS_X, POS_Y, POS_Z, NEG_X, NEG_Y, NEG_Z
targetoptCOMBO2 options: IMAGE_TEXTURES, VERTEX_COLORS
save_modeoptCOMBO2 options: INTERNAL, EXTERNAL
use_clearoptBOOLEANfalse
use_cageoptBOOLEANfalse
use_split_materialsoptBOOLEANfalse
use_automatic_nameoptBOOLEANfalse
uv_layeroptSTRING

Outputs (1)

NameTypeDescription
BPY_OBJBPY_OBJ