Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added composition mode to layer #4140

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

bjorn
Copy link
Member

@bjorn bjorn commented Jan 12, 2025

TODO:

  • Serialization in XML, JSON and Lua formats
  • Decide which modes to support
  • Consider what should happen when set on group layers
  • Scripting API
  • Documentation

Closes #3932

@bjorn bjorn added the feature It's a feature, not a bug. label Jan 12, 2025
@bjorn bjorn self-assigned this Jan 12, 2025
@bjorn bjorn force-pushed the composition-modes branch from c60fbae to a142386 Compare January 17, 2025 15:42
bjorn added 2 commits January 17, 2025 18:02
Now the layer blend mode defaults to "Inherit", which means that when set on a
group layer, the blend mode now applies to its children.
@eishiya
Copy link
Contributor

eishiya commented Jan 17, 2025

Draft of docs, to add to https://github.com/mapeditor/tiled/blob/master/docs/manual/layers.rst after the Tinting Layers section.

.. _blend-mode:

Blend Modes
--------------

Tiled supports several common blend modes for Layers, which modify their
appearance by blending them with the layers below in different ways.
The default blend mode is Inherit, which uses the blending mode from
the layer's parent Group. The blend mode inherited by top-level Layers
and Groups is Normal.

Below is the full list of blend modes available in Tiled, along with links
to their equivalents in the SVG Compositing Specification, where you can see
examples and calculation details.

+-------------+--------------------------------------------------------------------------+
| Mode        | SVG equivalent                                                           |
+=============+==========================================================================+
| Inherit     | --                                                                       |
| Normal      | [src-over](https://www.w3.org/TR/SVGCompositing/#comp-op-src-over)       |
| Plus        | [plus](https://www.w3.org/TR/SVGCompositing/#comp-op-plus)               |
| Multiply    | [multiply](https://www.w3.org/TR/SVGCompositing/#comp-op-multiply)       |
| Screen      | [screen](https://www.w3.org/TR/SVGCompositing/#comp-op-screen)           |
| Overlay     | [overlay](https://www.w3.org/TR/SVGCompositing/#comp-op-overlay)         |
| Darken      | [darken](https://www.w3.org/TR/SVGCompositing/#comp-op-darken)           |
| Lighten     | [lighten](https://www.w3.org/TR/SVGCompositing/#comp-op-lighten)         |
| Color Dodge | [color-dodge](https://www.w3.org/TR/SVGCompositing/#comp-op-color-dodge) |
| Color Burn  | [color-burn](https://www.w3.org/TR/SVGCompositing/#comp-op-color-burn)   |
| Hard Light  | [hard-light](https://www.w3.org/TR/SVGCompositing/#comp-op-hard-light)   |
| Soft Light  | [soft-light](https://www.w3.org/TR/SVGCompositing/#comp-op-soft-light)   |
| Difference  | [difference](https://www.w3.org/TR/SVGCompositing/#comp-op-difference)   |
| Exclusion   | [exclusion](https://www.w3.org/TR/SVGCompositing/#comp-op-exclusion)     |
+-------------+--------------------------------------------------------------------------+
.. raw:: html

   <div class="new new-prev">Since Tiled 1.12</div>

It would be nice to include a figure that demonstrates blending modes, perhaps a demo with 3 layers where all are Normal, compared to where the bottom layer is Normal and the other two are Screen and Multiply or something. I don't have any art handy for that, and stock art designed for blending modes is uncommon.

I was a little tempted to include a paragraph with some usage examples, but figured the docs aren't the place. But just in case you do want it, here:

In most cases, you'll want to use the default Inherit or Normal mode,
which is also the default supported by practically all game engines.
Multiply is often used for lightmaps, while Plus or Screen are common for
light cookies. Note that not all engines support all of these blending modes.

It would also be nice to specify exactly which elements are affected by this. I can guess how it works for Tile and Image Layers, but what about non-Tile Objects in Object Layers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature It's a feature, not a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Layer Blend Mode Property
2 participants