LayerStyle

2167
By chflame
Updated 15 days ago
View on GitHub →See Common Issues →

A set of nodes for ComfyUI that can composite layer and mask to achieve Photoshop like functionality.

Available Nodes

LayerMask: MaskGradient

LayerMask: MaskGradient Documentation

Overview

The LayerMask: MaskGradient node is a component of the ComfyUI toolset that allows users to apply gradient effects to image masks. This node provides a way to manipulate masks by adding gradient transitions, which can be crucial for achieving specific visual effects or compositional outcomes in image processing workflows.

Functionality

  1. Gradient Application: The primary function of this node is to apply a gradient to an image mask. This gradient can originate from any of the four sides of the mask (top, bottom, left, or right), allowing for various directional effects.

  2. Mask Inversion: Users can choose to invert the mask before applying the gradient, which can be useful if they need the gradient effect to apply to the opposite area than it would by default.

  3. Scale and Offset: The node provides options to scale the gradient and offset it, which further refines how the gradient blends into the mask.

  4. Opacity Control: The opacity setting allows users to determine the transparency level of the gradient effect, blending it into the mask with varying intensity.

Inputs

The LayerMask: MaskGradient node accepts the following inputs:

  • Mask: The primary input, expected to be an image that serves as the mask to which the gradient will be applied.

  • Invert Mask: A boolean option that, when enabled, inverts the colors of the mask before applying the gradient.

  • Gradient Side: A selection input to determine the side of the mask where the gradient will originate. Options include top, bottom, left, and right.

  • Gradient Scale: An integer value defining the percentage scale of the gradient's size relative to the mask. This can be adjusted to stretch or shrink the gradient's coverage.

  • Gradient Offset: An integer input that offsets the starting position of the gradient, in pixels. This can shift the gradient up, down, left, or right depending on the specified side.

  • Opacity: An integer setting ranging from 0 to 100 that controls the opacity of the gradient, defining how transparent it appears over the mask.

Outputs

The LayerMask: MaskGradient node produces:

  • Mask: The output is a modified mask with the gradient effect applied according to the specified inputs.

Usage in ComfyUI Workflows

In a typical ComfyUI workflow, the LayerMask: MaskGradient node can be used as follows:

  1. Preparation: Before using this node, ensure that the image you want to modify is accurately represented by a mask.

  2. Application: Insert the node into your workflow where the mask needs gradient manipulation. Adjust the settings such as the gradient side, scale, offset, and opacity to achieve the desired effect.

  3. Integration: Connect the output of this node to subsequent nodes that will utilize the modified mask for further image processing or layering.

  4. Experimentation: Due to the variety of settings, experimenting with different configurations can lead to unique visual results, making it a flexible tool in creative workflows.

Special Features and Considerations

  • Flexibility: The ability to control the side, scale, and offset provides significant flexibility in how gradients are applied, allowing for targeted effects.

  • Performance: While the node efficiently processes image masks, complex configurations with high-resolution masks may impact performance. It's advisable to optimize the input for better processing times.

  • Error Handling: If the mask does not have a valid area, the node will log an error and skip processing, ensuring that only valid masks are processed.

By using the LayerMask: MaskGradient node effectively, users can enhance their image processing tasks within ComfyUI, adding sophisticated and customizable gradient effects to their images.