Comfy Pencil Render Document
Re-render a ComfyPencil document anywhere in the graph
- document
- background_image
- image
- mask
- height
- roughness
- specular
- light
- metadata_json
Comfy Pencil Studio already outputs a rendered image and mask, so why does this node exist? Because it's the studio's render step pulled out into a reusable node - for when your document has traveled through other ComfyPencil nodes and you need a fresh composite somewhere it isn't wired, or when you want to re-render a saved document into the graph without touching the studio UI at all.
Think of it as the "present" node of the pack. Anything that hands you a PENCIL_DOCUMENT - the Studio node, Import Layer's document output, even a document you saved earlier and are re-opening - can be dropped into Render Document to get standard ComfyUI tensors back out.
The mechanism is honest, old-school compositing done in Python. The node resolves the document (loading the layer bitmaps from disk when the payload is the lightweight pointer version), composites all visible layers in stack order using each layer's blend mode and opacity via PIL alpha compositing, and - if you ask - flattens the background. Then it derives the material maps: height, roughness, and specular are read from the per-layer material channels, and the light map is computed from the height field with a simple normal-mapping and directional-light calculation (_derive_light_map in the source). It's not physically perfect PBR - it's a fast, deterministic approximation - but as a starting point for texture work it's genuinely usable.
Inputs: just document, plus flatten_background and an optional background_image. That last one is the sleeper feature: wire any IMAGE in and the render composites over it, which makes the node handy for matte work or for compositing a painting onto a generated backdrop you didn't paint.
Outputs: image, mask, then the four material maps (height, roughness, specular, light), and metadata_json for inspection or sidecar use.
A typical chain: Studio → Import Layer (drop a generated base into the painting) → Render Document → your img2img or ControlNet branch. Because everything here is just IMAGE/MASK/STRING on the way out, it plays with the rest of the ComfyUI ecosystem without any special handling.
Install is the same as the rest of the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/criskb/Comfypencil ComfyPencil
Restart ComfyUI and hard-refresh the browser. No model downloads, no API keys, no extra Python dependencies beyond ComfyUI's bundled torch and Pillow; the pack targets ComfyUI >= 0.16.0.
One honest caveat: the render here matches what the studio node produces, but both can differ slightly from the browser's live blend preview - the author flags that the preview and the backend render are "close, but not perfectly identical yet." So if you're judging colors against what you saw in the studio, expect a hair of difference once it hits the graph. Not a bug, just the state of the pack.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| document | PENCIL_DOCUMENT | — | |
| flatten_background | BOOLEAN | false | — |
| background_imageopt | IMAGE | — |
Outputs (7)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| height | IMAGE | — |
| roughness | IMAGE | — |
| specular | IMAGE | — |
| light | IMAGE | — |
| metadata_json | STRING | — |