by Gez » Fri Oct 09, 2020 6:22 am
Graf Zahl wrote:These mods use a palette based map, but those do not work with hardware rendering and deriving a blend color from them is not trivial.
I think most real cases can be covered by looking at the whiteindex and blackindex colors.
- If the blackindex color is lighter than the whiteindex color, it's an inverted ramp.
- The lightest color (blackindex if inverted, whiteindex otherwise) gives you the "pure" blend color since it's applied to a white base.
It's when different color ranges get different blendings that this wouldn't be possible (e.g. a hue change) but I don't remember ever seeing that used. A hue change wouldn't affect black or white (since by definition they have 0% saturation, making them hue irrelevant) but could be detected by looking, for the vanilla Doom palette, at index 176 (pure red) and index 200 (pure blue). So more algorithmically, keeping track of the purest red, green, and blue values in the base palette and looking at if they have an approximately constant hue change in the invuln palette would solve that case, too.
[quote="Graf Zahl"]These mods use a palette based map, but those do not work with hardware rendering and deriving a blend color from them is not trivial.[/quote]
I think most real cases can be covered by looking at the whiteindex and blackindex colors.
[list][*]If the blackindex color is lighter than the whiteindex color, it's an inverted ramp.
[*]The lightest color (blackindex if inverted, whiteindex otherwise) gives you the "pure" blend color since it's applied to a white base.[/list]
It's when different color ranges get different blendings that this wouldn't be possible (e.g. a hue change) but I don't remember ever seeing that used. A hue change wouldn't affect black or white (since by definition they have 0% saturation, making them hue irrelevant) but could be detected by looking, for the vanilla Doom palette, at index 176 (pure red) and index 200 (pure blue). So more algorithmically, keeping track of the purest red, green, and blue values in the base palette and looking at if they have an approximately constant hue change in the invuln palette would solve that case, too.