Nodes/ComfyUI-TextureAlchemy/Lighting Extractor (Marigold)
ComfyUI Node

Lighting Extractor (Marigold)

Marigold lighting, unpacked into albedo, shading, and residual

By amtarr·Created 9 months ago·Updated 4 months ago· 58
Lighting Extractor (Marigold)
  • marigold_lighting
  • albedo
  • diffuse_shading
  • non_diffuse_residual
albedo_gamma0.45
diffuse_shading_gamma0.45
non_diffuse_gamma0.45

Here's the situation: Marigold's lighting model is brilliant at separating an image into "what color the thing is" and "how the light hits it." That separation is gold for texture work - you get a clean albedo and a shading layer you can tweak, relight, or throw away entirely. The problem is the output arrives as one batched image and you have to know the slice order. Lighting Extractor is the slice.

It takes the Marigold lighting output and splits it into three IMAGEs: albedo, diffuse_shading, and non_diffuse_residual. The names tell you the whole story - this is a decomposition of a lit photo into its intrinsic components. Albedo is the "paint" color, diffuse shading is the soft light-and-shadow term, and the residual catches everything else (speculars, tricky reflections). Reassemble them with the pack's Basic Lighting Builder and you get your original image back, which means you can edit any of the three in isolation and rebuild - that's how you relight a texture or scrub baked shadows out of an albedo.

How it works

The lighting model outputs three images in a fixed batch order: image 0 is albedo, image 1 is diffuse shading, image 2 is the non-diffuse residual - all in linear space. The node slices them and applies gamma correction per map. The defaults are all 0.4545, which is the inverse of 2.2 - i.e. the value that lifts linear data into display space. If you're saving these maps for a renderer that expects linear, drop the gammas to 1.0 and work in linear the whole way. The tooltips call the space out explicitly so you're never guessing.

The inputs

Only one required input: marigold_lighting, straight from the lighting model in kijai's ComfyUI-Marigold. Feed it the appearance output instead and the slices will be silently wrong - the two models have different layouts, and this node only knows the lighting one. If the batch is missing an image, it falls back to the albedo for the missing slot rather than crashing, which is your sign something's off upstream.

The three gamma inputs (albedo_gamma, diffuse_shading_gamma, non_diffuse_gamma) are all you'll realistically touch. Brightness problems in a map → gamma. It's the whole tuning story.

Where this fits

The canonical use is in the pack's extraction workflow: Marigold appearance gives you roughness/metallic, Marigold lighting gives you albedo and shading, and both feed a PBR Combiner or a saver. If all you care about is a clean albedo from a photo with ugly lighting, this is the node - the albedo output is usually dramatically flatter and more usable than the source image. Community threads on PBR extraction with Marigold v1.1 treat the lighting split as the key step, and this node makes it a single click.

Installation

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

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

You'll also need kijai/ComfyUI-Marigold installed, since it's what actually runs the lighting model and produces the batch input. No extra dependencies for this node itself - the pack runs on ComfyUI's bundled PyTorch.

CategoryTexture Alchemist/Extractors

Inputs (4)

NameTypeDefaultDescription
marigold_lightingIMAGE
albedo_gammaFLOAT0.450.1–3Gamma correction for albedo (linear space)
diffuse_shading_gammaFLOAT0.450.1–3Gamma correction for diffuse shading (linear space)
non_diffuse_gammaFLOAT0.450.1–3Gamma correction for non-diffuse residual (linear space)

Outputs (3)

NameTypeDescription
albedoIMAGE
diffuse_shadingIMAGE
non_diffuse_residualIMAGE