mapeditor / mapeditor/tiled

Like Tint Color, add a Color Offset or Fog Color to a layer

Open
#2,920 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
12.9k
Forks
2k
Avg merge
4h 27m
Merged PRs (30d)
8

Description

I like the ability to tint a layer with Tint Color, however this can only make colors darker. So I would like to propose a way to add color to layers, which could be done in two ways: either by using a Color Offset, which is added to the color, or by introducing a Fog Color.

**Color Offset**

This is an RGB value that is added to each pixel after the Tint has been applied.

ActionScript has something similar: ColorTransform, which consists of a MultiplyColor (like Tint) and an AddColor (Offset).

Every pixel is calculated by:
Pixel.rgb * Tint.rgb + Offset.rgb

This can be especially useful for background layers to give more depth, like in this example:

Back layer: Tint = 64, 64, 64, Offset = 75, 102, 187
Mid layer: Tint = 128, 128, 128, Offset = 50, 75, 125
Front layer: normal

![image](https://user-images.githubusercontent.com/165285/97032937-da659200-1562-11eb-976f-05e3576a0d0a.png)

That would also make it possible to remove detail from background layers by bringing them down to a single color by setting the Tint to 0, 0, 0 and then setting the Offset to a certain color:

![image](https://user-images.githubusercontent.com/165285/97035205-4695c500-1566-11eb-9c60-e8c822c52a53.png)

The ColorTransform is actually much more flexible because it also allows negative numbers and numbers above 255, but just having an Color Offset would be a big help.

**Fog Color**

Instead, each layer could have a Fog Color. This would use Alpha as the intensity (0 = no fog, 255 = filled with fog color).

Every pixel is calculated by:
(Pixel.rgb * Tint.rgb) * (1 - Fog.a) + Fog.rgb * Fog.a

For the first example that would be:
Back layer: Fog Color = 100, 150, 250, alpha = 192
Mid layer: Fog Color = 100, 150, 250, alpha = 128

In the second example, alpha would be 255

I don't know which option would be better. The Fog Color would probably be easier to use because you'd often set this to be the same as the background color and it would be easier to experiment with different intensities. But the Color Offset would be easier to implement. I don't know if either are supported by game engines, but people can probably easily create a shader to use them.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named. Start by locating the existing layer Tint Color implementation, then resolve whether Color Offset or Fog Color is the intended approach; done means the selected layer color effect works according to the stated pixel formula and has suitable coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics, game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.