News:

Simutrans Tools
Know our tools that can help you to create add-ons, install and customize Simutrans.

Green discoloration in transparent player color

Started by Leartin, December 10, 2017, 01:55:18 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Leartin

This is a bit weird. Transparent player colors work in general, but sometimes they completely bug out - depending on the player color chosen. Here is an example of how it looks in game:

As you can hopefully see, it looks fine when using red player color. Switching player colors cause discoloration in different areas.

Flemmbrav

Agree, please fix this!
Really annoyes me when I do some testing after spending endless hours on a station just to see this ;) Also I don't think I will create something in transparent player colour since it's fixed, since this just looks so **** weird...

Ters

This might be "impossible" to fix without a drastic performance hit. The color blending routines are quite simple in order to be fast enough. Alpha blending was even unthinkable until recently.

Leartin

So, what is the cause?
This is not the 'normal' discoloration you get with pretty much everything due to the reduced color range, it's more as if the color to be mixed with is wrong in the first place.

Dwachs

Is there supposed to be a screenshot? How could I test this?
Parsley, sage, rosemary, and maggikraut.

DrSuperGood

QuoteThis is not the 'normal' discoloration you get with pretty much everything due to the reduced color range, it's more as if the color to be mixed with is wrong in the first place.
It is wrong in the first place. There is no sRGB to linear conversion of the base colours before blending and the results of blending are not converted from linear to sRGB. The blend maths only works in linear colour space as opposed to displays which are in the sRGB colour space, or have an sRGB like response to them.

Where as modern GPU hardware can do all this as good as for free, it is extremely computationally intensive for a CPU.

Leartin

#6
Attached are a PNG and a dat-file - pak them in 128 size, and you'll find the test image as a track.



Quote from: DrSuperGood on December 10, 2017, 05:43:58 PM
It is wrong in the first place. There is no sRGB to linear conversion of the base colours before blending and the results of blending are not converted from linear to sRGB. The blend maths only works in linear colour space as opposed to displays which are in the sRGB colour space, or have an sRGB like response to them.

Yeah, yeah, I know how that part works. That explains why the colors would be off, depending on what colors you mix together, especially with bright colors. But there is an issue with this theory:
1) It would not matter which of the color is "background" and which is transparent in the foreground. But with player colors, you only get problems if the player color is transparent, not if you blend something with solid player color.
2) For the blending, it would not matter whether it's player color or a normal color, but these results only come up with player colors.
3) The discoloration would be a result of the blend, meaning it would occur if the background and the foreground don't play along well. But here, the discoloration is always the same, independent of the background.