| title | Segment Masks |
|---|---|
| hide |
Segment masks add per-segment clipping. A mask defines which virtual pixels a segment is allowed to draw. Pixels outside the mask are left untouched, which makes foreground and background layering easy with overlapping segments.
Segment masks do not remap LEDs. They clip after the segment's normal mapping (start/stop, 2D layout, panel layout, ledmap, etc.).
Mask files live on the filesystem and follow the same upload flow as ledmaps:
- Upload via
/edit - File name pattern:
segmask1.json,segmask2.json, ... segmask0.jsonis reserved (0 means no mask)
{"w":4,"h":4,"inv":false,"mask":[0,0,1,0,0,1,1,0,0,1,1,0,0,0,1,0]}Fields:
wandhdefine the mask dimensions in virtual pixels.maskis a flat array of0or1values, length must equalw*h.invis optional and inverts the mask (true or false only).
Notes:
- Index order is row-major:
index = x + (y * w)with(0,0)at the top-left. - Parsing is strict: only
0and1are accepted inmask, andinvaccepts onlytrueorfalse. - If
wandhdo not match the segment's virtual size, the mask is ignored.
- Create a file like
segmask1.jsonwithw = segment lengthandh = 1. - Upload it via
/edit. - Reboot WLED to load the new mask files.
- In the segment UI, pick the mask file in the Mask dropdown.
- (Optional) enable Invert mask to draw outside the shape instead of inside.
Tip: Use two overlapping segments for a clean foreground/background effect.
- Segment 0: full length, background effect/palette
- Segment 1: same bounds, mask enabled, foreground effect/palette
- Choose a segment that spans the desired matrix area.
- Ensure the mask dimensions match the segment's virtual size.
- Example: a 32x16 matrix mask needs
w = 32,h = 16.
- Example: a 32x16 matrix mask needs
- Upload
segmaskX.jsonvia/edit. - Reboot WLED to load the new mask files.
- Pick the mask file in the segment Mask dropdown.
You can still use Expand 1D FX for 1D effects on 2D segments; the mask clips the final output.
- Mask selection does not disable segment bounds or geometry options; they still apply to the masked output.
- Ledmaps and panel layout still define physical wiring order.
- Masks only clip what the segment draws; they do not change LED order.
- JSON Mapping (jmap) is still applied before the mask.
Masks use 1 bit per pixel in the segment's virtual space. Example: a 32x32 mask uses 1024 bits (128 bytes). Clipping is performed with bitwise operations for efficiency. Performance impact will be highest when layering complex effects, many segments, or large masks.
Segment state includes:
"mask": mask id (0 disables)"minv": invert mask (true or false)
Example:
{"seg":[{"id":0,"start":0,"stop":512},{"id":1,"start":0,"stop":512,"mask":1,"minv":false}]}