SFTtech / openage

Free (as in freedom) open source clone of the Age of Empires II engine 🚀
http://openage.dev
Other
12.63k stars 1.11k forks source link

Implement "player color palettes" #112

Closed franciscod closed 9 years ago

franciscod commented 9 years ago

I don't think age2 used fancy shaders for coloring... so... from http://steamcommunity.com/sharedfiles/filedetails/?id=190070326:

"The player color means which color you used in your bmp as player color. This is important as the AoE palette has 8 exactly defined values for every players color shades. When extracting a bmp, every pixel that is supposed to change it's color according to players color will be colored in the chosen player color (default is blue). To convert a real color back to the undefined player color one, you have to set this. If you choose red for example, no red pixel - even if it matches a red player color value - will be interpreted as player color but shown as red - for every player.

On the other hand, every pixel that changed to a color shade of the chosen player color while converting - even if it wasn't meant to have players color - will have it ingame. And every pixel supposed to have the players color but doesn't have the right color value after converting - will not change its color ingame."

franciscod commented 9 years ago

...or is this already done via shaders? are we keeping the shaders?

zuntrax commented 9 years ago

The parts of the texture that should have player colors are marked with an alpha value of 254 or 253 (I think the other one was for outlines). When rendering, a shader replaces these areas with the given player color. Edit: I don't see a reason not to keep this implementation.

mic-e commented 9 years ago

The original age2 renderer used direct draw and SLP files as drawing instructions. Each time it would render a unit it would read the SLP file, which would e.g. say "draw a line with the playercolor from (10,20) to (23, 5)".

IIRC, openage.convert

The engine has a shader that takes the color palette and player id and replaces all marked pixels by the player's color.

Alternatively, one could just create 8 PNG files (one for each player), but that would take 8 times the memory (on the filesystem, in RAM, and in the graphics memory) and would severely limit our ability to introduce new player colors.

TheJJ commented 9 years ago

The palette is placed in $conversiondir/player_palette_50500.docx. You can adjust the color values there, the conversion is done in py/openage/convert/colortable.py.