Nodes/ComfyUI-TextureAlchemy/Basic Lighting Builder
ComfyUI Node

Basic Lighting Builder

Put the light back together

By amtarr·Created 9 months ago·Updated 4 months ago· 58
Basic Lighting Builder
  • albedo
  • shading
  • residual
  • composite

If Lighting Extractor tears a lit photo apart into albedo, shading, and residual, Basic Lighting Builder is the node that puts it back together. Its formula is dead simple - composite = albedo * shading + residual - and that formula is the whole point: it's the mathematical inverse of the extraction, so you can edit the parts and rebuild the whole without losing anything.

That round-trip is the actual superpower. Extract → tweak the albedo to remove a baked-in color cast → rebuild. Or extract → darken the shading in one region → rebuild → and you've relit the texture without ever touching the color. It's the "easy mode" of the pack's relighting story.

How it works

Three steps, all plain torch: multiply the shading over the albedo (the "how the light hits the paint" step), add the residual (the specular/non-diffuse stuff), then clamp to 0–1. That's it. The mechanism matters because it explains why the three outputs of Lighting Extractor are the right inputs here: albedo is the paint color, shading is the soft light multiplier, residual is the additive sparkle. Get the order wrong and the math stops being invertible.

The inputs

  • albedo - the base color map.
  • shading - the diffuse shading pass.
  • residual - the non-diffuse residual pass.

All three are required - this node has no optional slots. Output is a single composite IMAGE, which should look like the original photo if the passes are unmodified. If it doesn't, that's your round-trip health check: something upstream altered the passes or the gamma.

Where it fits and what to watch

The intended chain is: Marigold lighting → Lighting Extractor → [Composite Mask Adjuster here if you're doing masked edits] → Basic Lighting Builder → PBR saver or pipeline. The one thing that trips people is gamma. The extractor's gamma knobs default to 0.4545 (lifting linear data to display space), so if you rebuild and the composite looks darker or flatter than the source, the gammas don't match between the extract and rebuild - set them to the same value on both sides and the composite comes back clean. A mismatched gamma is almost always the culprit when the round-trip fails.

Installation

Ships in amtarr/ComfyUI-TextureAlchemy under Add Node → Texture Alchemist → Materials. Install via ComfyUI Manager (search "TextureAlchemy") or:

cd ComfyUI/custom_nodes
git clone https://github.com/amtarr/ComfyUI-TextureAlchemy

Restart ComfyUI. No dependencies, no models - a three-line math operation wearing a node costume.

CategoryTexture Alchemist/Materials

Inputs (3)

NameTypeDefaultDescription
albedoIMAGE
shadingIMAGE
residualIMAGE

Outputs (1)

NameTypeDescription
compositeIMAGE