Feature: Canvas Blend and Boolean modes#8661
Feature: Canvas Blend and Boolean modes#8661dunkeroni wants to merge 27 commits intoinvoke-ai:mainfrom
Conversation
…menu; support per-layer globalCompositeOperation in compositor; UI to toggle and select color blend modes (multiply, screen, darken, lighten, color-dodge, color-burn, hard-light, soft-light, difference, hue, saturation, color, luminosity).
|
Just tested this and it works as expected. I did find a minor bug however:
|
lstein
left a comment
There was a problem hiding this comment.
There's a minor bug when the user performs an undo and redo. See comment above.
- Blend Modes are not right click menu options anymore. Instead they rest above the layer panel as they do in other art programs readily available for each layer. - Blend Modes have been resorted to match the listings of other art programs so users can avail their muscle memory. - Blend Mode now defaults to `Normal` for each layer as it should. - The extra layer operations have now been moved down to the `Operations Bar` at the bottom of the layer stack. This is to increase familiarity again with other art programs and also to make space for us in the top action bar. - The Operations Bars operations have been resorted in order of usage that makes sense.
|
Trying out some adjustments to the boolean operations. Now it does a special merge that results in a new layer and disables the inputs, but doesn't delete them. That helps make it a little clearer to the user what happened, and is less destructive in case they wanted to perform further operations with the original layers. |
|
The new layer is definitely preferred. Keeps things non-destructive but I noticed a few issues.
Apart from that functionality seems fine. |
blessedcoolant
left a comment
There was a problem hiding this comment.
We good to go on this. @lstein
|
@dunkeroni If possible can you find a better icon or fix the spacing with |






Summary
Adds Blend Modes and Boolean merge operations to the canvas raster layers.
Both of these are handled with the globalCompositeOperation feature, and due to some technical limitations on how we render things, blend modes are implemented as a non-destructive state of the raster layer and boolean merges are a destructive action.
Blend Modes are a common feature of other image creation platforms, used for easy creation of light, shadows, textures, and recoloring objects.
Technical Info:
Because we're using the features built into Konva and CSS rendering already, the effect fits nicely into the pipeline after all pixel information is resolved (e.g. Adjustments panel) and before layer transparency is applied. This means that users can enable a blend mode, and then continue to adjust the brightness and tone, and also leverage the layer transparency to control the strength of the effect. Users can also draw and erase on a layer with an active blend mode without any additional overhead.
We use and interact with raster layer information supported as Konva objects; and when merging or combining layers for img2img actions this PR uses the Konva global composite operation to resolve those layers. However, the live view is handled through the HTMLCanvasElement's mixBlendMode, which is functionally identical for the color modes we are using but doesn't support the boolean operations. Hence booleans are an independent action submenu instead.
Some caveats of using the HTML mixBlendMode:
QA Instructions
Create some layers and mash them together.
Boolean Operations:
Booleans are accessible via the right click menu. They work on the current layer and the layer directly below it (similar to "Merge Down").

Intersect: Returns the top layer where it overlaps the bottom layer.
Cut Out: Returns the bottom layer where it overlaps the top layer.
Cut Away: Returns the top layer where it does not overlap the bottom layer.
Exclude: Returns both layers where they do not overlap.
Blend Modes:
Blend mode is accessible via the right click menu.



Example: Adding glow effect

Example: Adding half-tone dot matrix texture

Texture got from: https://texturelabs.org/textures/grunge_265/ and applied with Overlay mode.
Merge Plan
Ready to merge. Most of the PR is just new menus that interact with our existing features.
Checklist
What's Newcopy (if doing a release after this PR)