Linear sRGB blending for layers
- Dominant language
- C++
- Stars
- 12.9k
- Forks
- 2k
- Avg merge
- 4h 27m
- Merged PRs (30d)
- 8
Description
**Current issue**:
It seems that Tiled is doing color blending in sRGB gamma space and while this might be the expected behavior for a lot of users, it can cause quality issues (wrong/undesired color behaviors) and problems when trying to match the render of a game engine.
The issue mainly arise when blending layers together in the editor's viewport, when having semi-transparent pixels.
**Describe the solution you'd like**:
Having an option to choose how to blend colors, via a simple boolean setting in the preferences to choose between Linear sRGB and sRGB, would be just enough. :smile:
There are plenty of resource on while blending colors this is better (for example [this](https://ninedegreesbelow.com/photography/linear-gamma-blur-normal-blend.html) and [this](https://bottosson.github.io/posts/colorwrong/) or [this as well](https://www.shadertoy.com/view/lscSzl)).
I would understand if this option would be off by default (and even limited to hardware acceleration mode) given that not all applications behave like this by default and to not break existing users workflows. For example Photoshop blends color in sRGB by default too but you can change that in the preferences.
Game engines like Unity or Unreal Engine, but also mine, on the other hand work in Linear sRGB color space and therefore the look in-editor cannot be 100% matched with the engine.
**Example**:
The best and most obvious example is when trying to blend a pure red and green color together with a gradient as the mask. In sRGB this produce a darkening in the middle of the transition while in Linear sRGB we get the orange/yellow color.
Here is the gradient example with on the left my game engine and on the right Tiled's viewport:

**Describe alternatives you've considered**
No alternative possible. This is a color management issue and cannot really be solved by a pipeline/workflow change on my side. Linear color blending is needed for other steps in my game engine (like bloom) and therefore sRGB blending is not possible.
**Misc**:
I have looked around but it seems nobody requested this before, either here or on the forums.
Also if anybody has technical questions, feel free to ask.
Contributor guide
Research direction
The issue names no files, tests, or entry points. Start by locating Tiled's viewport compositing and preferences code, then compare the existing sRGB result with linear sRGB blending; done means a selectable preference produces the expected red-to-green gradient while preserving the current default behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics, desktop-dev, game-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100