The International Simutrans Forum

 

Author Topic: Green discoloration in transparent player color  (Read 1505 times)

0 Members and 1 Guest are viewing this topic.

Offline Leartin

  • Devotee
  • *
  • Posts: 1002
  • PAK-DEV P192C
  • Languages: DE, EN
Green discoloration in transparent player color
« 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:

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

Offline Flemmbrav

  • *
  • Posts: 111
  • Languages: DE, EN
Re: Green discoloration in transparent player color
« Reply #1 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...

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5173
  • Languages: EN, NO
Re: Green discoloration in transparent player color
« Reply #2 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.

Offline Leartin

  • Devotee
  • *
  • Posts: 1002
  • PAK-DEV P192C
  • Languages: DE, EN
Re: Green discoloration in transparent player color
« Reply #3 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.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4447
  • Languages: EN, DE, AT
Re: Green discoloration in transparent player color
« Reply #4 on: December 10, 2017, 05:25:29 PM »
Is there supposed to be a screenshot? How could I test this?
Parsley, sage, rosemary, and maggikraut.

Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2345
  • Languages: EN
Re: Green discoloration in transparent player color
« Reply #5 on: December 10, 2017, 05:43:58 PM »
Quote
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.
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.

Offline Leartin

  • Devotee
  • *
  • Posts: 1002
  • PAK-DEV P192C
  • Languages: DE, EN
Re: Green discoloration in transparent player color
« Reply #6 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.



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.
« Last Edit: December 10, 2017, 06:11:20 PM by Leartin »