The International Simutrans Forum

Development => Bug Reports => Topic started by: Leartin on December 10, 2017, 01:55:18 PM

Title: Green discoloration in transparent player color
Post by: Leartin on December 10, 2017, 01:55:18 PM
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:
(http://dl.dropbox.com/s/60zxxq3tck8bcod/discoloration.png)
As you can hopefully see, it looks fine when using red player color. Switching player colors cause discoloration in different areas.
Title: Re: Green discoloration in transparent player color
Post by: Flemmbrav on December 10, 2017, 01:59:50 PM
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...
Title: Re: Green discoloration in transparent player color
Post by: Ters on December 10, 2017, 04:24:16 PM
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.
Title: Re: Green discoloration in transparent player color
Post by: Leartin on December 10, 2017, 04:38:22 PM
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.
Title: Re: Green discoloration in transparent player color
Post by: Dwachs on December 10, 2017, 05:25:29 PM
Is there supposed to be a screenshot? How could I test this?
Title: Re: Green discoloration in transparent player color
Post by: DrSuperGood on December 10, 2017, 05:43:58 PM
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.
Title: Re: Green discoloration in transparent player color
Post by: Leartin on December 10, 2017, 05:51:21 PM
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.