LayerMask: DrawRoundedRectangle
Generate a rounded-rectangle mask
- size_as
- mask
Sometimes you don't need SAM or a segmentation model, you just need a clean rounded rectangle to use as a mask. Rounded-corner thumbnails, a card/frame shape, a vignette base, a soft-cornered crop for compositing - this node generates that mask for you at whatever size you ask, with anti-aliased corners so they don't look like jaggy pixel stairs.
It's a generator, not a filter - there's no image input. You tell it the dimensions and the corner radius and it produces a MASK: white rounded rectangle on black. From there it feeds any of the LayerStyle composite nodes, a Set Latent Noise Mask, an inpaint, whatever wants a mask.
How it works
It draws a white rounded rectangle centered on a black canvas at the width and height you specify, rounding each corner by the radius and smoothing the curve with supersampling (that's the anti-aliasing control). The clever convenience is size_as: hand it any image or mask and the node will match that thing's dimensions automatically, so you don't have to type in numbers that match your working resolution.
The inputs and outputs that matter
rounded_rect_radius(INT, 0–100, default 50) - the corner rounding, as a percentage-style amount. 0 is a hard-cornered rectangle; 100 is maximally rounded (ends up pill/oval-shaped on a non-square canvas). 50 is a nicely rounded card.width/height(INT, default 1024 each) - the mask dimensions, if you're setting them manually.anti_aliasing(INT, 0–16, default 2) - corner smoothing. Leave it around 2–4; 0 gives you visible jaggies, cranking it higher costs a little compute for diminishing returns.size_as(optional, wildcard*) - plug an image or mask in here and the node copies its size, ignoring the width/height fields. This is the input to use in practice so your mask always matches your canvas.
Output is a single mask (MASK) - white shape on black - ready to wire downstream.
How to install it
ComfyUI Manager: search ComfyUI Layer Style, install, restart. Or clone it:
cd ComfyUI/custom_nodes
git clone https://github.com/chflame163/ComfyUI_LayerStyle
Restart to install requirements. This node is pure drawing - no models involved.
Common issues & troubleshooting
If the node doesn't show up, that's the pack-wide IMPORT FAILED issue rather than anything about this node. Check startup logs for it on ComfyUI_LayerStyle. The two usual causes: an old install from before the pack split into ComfyUI_LayerStyle and ComfyUI_LayerStyle_Advanced (delete the stale folder, reinstall), or a broken dependency upstream in your environment breaking the import. A clean reinstall via Manager fixes most cases.
Node-wise: if your mask comes out the wrong size, you probably set width/height by hand and forgot they get overridden the moment you connect size_as - pick one approach. If the corners look crunchy, bump anti_aliasing a notch. And remember the output is a mask (grayscale), not an image - if you want it as a visible shape, run it through an image conversion or use it where a MASK belongs.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| rounded_rect_radius | INT | 500–100 | — |
| anti_aliasing | INT | 20–16 | — |
| width | INT | 10248–100000000 | — |
| height | INT | 10248–100000000 | — |
| size_asopt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |