Save 4 hours! We auto-setup your workflow! Free!

Drop your workflow.json — we handle every dependency, custom node, and model. Just open the link and run.

Auto-Setup Workflow Json (Free) Now!
ComfyUI > Nodes > ComfyUI-WanAnimatePreprocessV2 > Wan SH Lighting Transfer (V2)

ComfyUI Node: Wan SH Lighting Transfer (V2)

Class Name

WanSHLightingTransferV2

Category
🐺 C2C/🧍 Wan Animate Preprocess/Lighting
Author
code2collapse (Account age: 0days)
Extension
ComfyUI-WanAnimatePreprocessV2
Latest Updated
2026-11-12
Github Stars
0.02K

How to Install ComfyUI-WanAnimatePreprocessV2

Install this extension via the ComfyUI Manager by searching for ComfyUI-WanAnimatePreprocessV2
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI-WanAnimatePreprocessV2 in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Wan SH Lighting Transfer (V2) Description

Estimates smooth image lighting with spherical harmonics to reconstruct, transfer, or rotate it.

Wan SH Lighting Transfer (V2):

WanSHLightingTransferV2 estimates the broad lighting in an image and uses that estimate to reconstruct the image, apply its lighting to another image, or turn the estimated lights around a vertical axis. It uses second-order spherical harmonics: a compact model with nine lighting terms for each of the red, green, and blue channels. This method is suited to smooth, overall changes in illumination rather than precise shadows or small, sharp light sources. When surface-color information is available, the node can separate color from shading more directly; otherwise, it makes an approximation from the images. You can use it to explore lighting direction, compare a reconstruction with its original, or give a target image the broad lighting character of a source.

Wan SH Lighting Transfer (V2) Input Parameters:

source_image

Required IMAGE. This is the image whose lighting the node estimates in every operation. It must contain RGB images in (B,H,W,3) format, where B is the number of frames. The node fits a separate set of lighting coefficients to each source frame. Its height and width must match source_normal; when the source has multiple frames, a single matching normal frame can be reused across them. No numeric minimum, maximum, or default is defined for this input.

source_normal

Required IMAGE. This is an RGB normal map describing which way the visible surfaces in source_image face. The node converts its color values from [0,1] to three-dimensional directions and uses those directions to estimate how the surfaces are lit. An incorrect or misaligned normal map can therefore produce an inaccurate lighting fit or reconstruction. It must have RGB (B,H,W,3) format and matching spatial dimensions; one normal frame may be reused for multiple source frames. No numeric minimum, maximum, or default is defined.

operation

Required option selector. Choose fit_only to estimate lighting and reconstruct the source, transfer to apply source lighting to a target, or rotate_lights to rotate the estimated lighting while relighting the source. The default is fit_only. In transfer mode, both target_image and target_normal must be connected. rotate_yaw_deg affects the result only in rotate_lights mode. No numeric minimum or maximum applies to this selector.

rotate_yaw_deg

Required FLOAT. In rotate_lights mode, this turns the fitted lighting around the vertical Y axis before rendering it on the source normals. Use a negative or positive value to explore opposite turning directions; 0.0 leaves the fitted lighting unrotated. The allowed minimum is -180.0, the maximum is 180.0, the default is 0.0, and the control step is 1.0 degree. The code does not use this setting in fit_only or transfer.

intensity

Required FLOAT. This scales the final relit image and shading map in every operation. 1.0 leaves their calculated brightness unscaled, 0.0 makes both outputs black, and values above 1.0 brighten them. Output image values are clipped to [0,1], so high settings can remove visible highlight detail rather than preserve ever-brighter values. The minimum is 0.0, the maximum is 4.0, the default is 1.0, and the control step is 0.05.

source_albedo

Optional IMAGE. This supplies an estimate of the source’s surface colors without lighting, allowing the node to divide source color by surface color when fitting the lights. In fit_only and rotate_lights, it is also multiplied by the calculated shading to form the image. Without it, the lighting fit uses the source image directly; rotate_lights instead approximates surface color by dividing the source by its fitted shading. Provide an RGB image aligned with each source frame the node will process; the code does not broadcast or resize this input. No numeric minimum, maximum, or default is defined.

target_image

Optional IMAGE. In transfer mode, this identifies the image receiving the source lighting and is required alongside target_normal. If target_albedo is absent, the node uses the target image and an estimated version of its existing shading to approximate its surface colors before applying source shading. If there are fewer target frames than source frames, the node reuses the last target-image frame. This input is not used by fit_only or rotate_lights. No numeric minimum, maximum, or default is defined.

target_normal

Optional IMAGE. In transfer mode, this normal map tells the node how the target’s surfaces face so it can render the fitted source lighting on them. It is required alongside target_image and should match the target image’s spatial dimensions and frame coverage. Unlike target_image, the implementation does not explicitly reuse its last frame when source frames outnumber target-normal frames. This input is not used by fit_only or rotate_lights. No numeric minimum, maximum, or default is defined.

target_albedo

Optional IMAGE. In transfer mode, this supplies the target’s surface colors for direct multiplication by the newly rendered shading. When it is absent, the node estimates a surface-color proxy from target_image instead. The implementation reuses the last available target-albedo frame when needed, but each selected frame must still have dimensions compatible with the target shading. This input is not used by fit_only or rotate_lights. No numeric minimum, maximum, or default is defined.

Wan SH Lighting Transfer (V2) Output Parameters:

relit_image

IMAGE output containing one frame for each source frame. With fit_only, it is the source reconstruction from fitted shading, multiplied by source_albedo when provided. With rotate_lights, it shows the source under the rotated lighting; without source albedo, the node uses a surface-color approximation derived from the source. With transfer, it shows the target under source lighting, using target_albedo when provided or an approximation derived from target_image otherwise. intensity is applied and values are clipped to [0,1] in every mode.

sh_coeffs_json

STRING output containing JSON with an operation value and a frames list. Each source frame has an sh array of fitted lighting coefficients, with nine terms for each RGB channel, and an rms_err value measuring average fitting error across the channels; a smaller error means the fitted model more closely reproduces the values it was fitted against. rotate_lights frames additionally contain sh_rotated and yaw_deg; transfer frames contain applied_to set to target. These values are useful for inspecting or recording the fit, but the error is not a guarantee that the relit image will look natural.

shading_map

IMAGE output showing the rendered lighting across the relevant normal map, before multiplication by albedo or a surface-color approximation. It uses source normals for fit_only and rotate_lights, and target normals for transfer. It includes the intensity adjustment and is clipped to [0,1]. Compare it with relit_image to distinguish the calculated lighting pattern from the colors and details supplied by the source or target surface.

Wan SH Lighting Transfer (V2) Usage Tips:

  • Start with fit_only and intensity at 1.0. Compare relit_image with the source and inspect shading_map to judge whether the normal map and smooth lighting model capture the illumination you need.
  • Keep image and normal maps spatially aligned. For a multi-frame source with unchanged geometry, you can connect one source-normal frame; the node repeats it across source frames.
  • Supply source_albedo when you have a suitable surface-color image. For transfer, supply target_albedo as well when available. Without these inputs, the node relies on image-derived approximations that may carry some original lighting into the result.
  • For lighting transfer, select transfer and connect both target_image and target_normal. Make sure the target normal sequence has a frame for every source frame, even if the target image has fewer frames and its last frame will be reused.
  • For directional exploration, select rotate_lights and change rotate_yaw_deg in small increments from 0.0. The control turns the fitted lighting around the Y axis; it does not rotate the image or its geometry.
  • Adjust intensity gradually after checking the shading at 1.0. Raising it can brighten the result, but clipping at 1.0 can flatten bright areas; lowering it can help retain visible variation.

Wan SH Lighting Transfer (V2) Common Errors and Solutions:

Wan SH Lighting Transfer (V2): source_image expected (B,H,W,3); got …

  • Explanation: source_image is not a four-dimensional RGB image batch. The message ends with the shape the node received.
  • Solution: Connect an RGB IMAGE output with batch, height, width, and three color channels. Convert a grayscale or other incompatible image to RGB before connecting it.

Wan SH Lighting Transfer (V2): source_normal expected (B,H,W,3); got …

  • Explanation: source_normal is not a four-dimensional, three-channel image batch.
  • Solution: Connect an RGB normal-map IMAGE output. Check that the normal map has three channels and is supplied in the expected image-batch format.

Wan SH Lighting Transfer (V2): source_image and source_normal must align (B,H,W).

  • Explanation: The source image and normal map differ in frame count, height, or width. The only supported frame-count exception is one normal frame reused across multiple source frames; spatial dimensions must still match.
  • Solution: Align their height and width, and provide either one normal frame or the same number of normal frames as source-image frames.

Wan SH Lighting Transfer (V2): operation 'transfer' needs target_image and target_normal connected (the lighting is moved onto that target).

  • Explanation: transfer was selected without both required target connections.
  • Solution: Connect both target_image and target_normal, or select fit_only or rotate_lights for a task that does not use a target.

IndexError: index … is out of bounds for axis 0

  • Explanation: In transfer mode, a source frame may request a target-normal frame that does not exist. The code can reuse the last target-image frame, but does not do the same for target normals.
  • Solution: Supply at least as many target-normal frames as source frames and keep them aligned with the target images being used.

ValueError: operands could not be broadcast together with shapes …

  • Explanation: Image arrays used together do not have compatible dimensions. This can occur when an optional albedo image or a target image does not match the shading map it is combined with.
  • Solution: Check the height, width, RGB channels, and relevant frame counts of the source and target inputs. Resize and align paired images, normals, and albedo before connecting them.

ValueError: need at least one array to stack

  • Explanation: No source frames were processed, so the node has no image frames to assemble into its outputs.
  • Solution: Provide a nonempty source_image batch with a corresponding source_normal input.

Wan SH Lighting Transfer (V2) Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI-WanAnimatePreprocessV2
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.

Wan SH Lighting Transfer (V2)