Dfool of many colors

Production of artwork for the game by regular contributors takes place here.

Moderator: Forum Moderators

Post Reply
Darth Fool
Retired Developer
Posts: 2633
Joined: March 22nd, 2004, 11:22 pm
Location: An Earl's Roadstead

Dfool of many colors

Post by Darth Fool »

Or, how to make jetryl a happy camper in three easy steps:

1) draw a bunch of stick figure poses of wesnoth units.
2) buy and consume a vanilla steamer,
3) implement team color swapping for units.

Below is attached an in-game screen capture of my latest way of procrastinating on getting back to coding up a new AI. Note that there was no additional artwork added, and that the change in colors to the Orcish Sovereign is done using the game engine with WML tags defined in the unit cfg file. The idea is quite old and I finally got around to updating and getting to work my half-written code from the pre-1.0 era.

The image would be considerably nicer if the HP bar disappeared when units were at MAXHP, like the XP bar disappears when a unit is at 0XP.

The two team-red sovereigns are not actually identical on careful inspection. One uses the orignal image, and the second one uses the in-game replacement of colors for team 1.

The basic WML tag mechanism looks like this:

Code: Select all

flag_red=109,130,130,77,205,160,205,104,137,132
flag_green=2,2,13,2,66,12,68,3,12,9
flag_blue=2,13,2,2,2,12,2,3,12,6
note that if one color's list is longer than the others, the missing number in the other lists will be filled in with 0s. so if artists use a pure red, blue or green to represent the flag color in the unit, only a single line is needed.

The colors are converted based on roughly the following algorithm:
1) the new color with the highest total of all three component colors (call it MAX_OLD)is set equal to the team color.
2) All other replacement colors (call them OLD)are changed into shades of the team color proportional to the ratio of OLD/MAX_OLD

Things that still need to be done before I commit:
1) clean up code and make the back end a little bit more generic
2) verify that changes work for animations and halos...
3) make changes to the reports.cpp and display.cpp to allow the unit image in the side bar to reflect color changes.

Things that I may work on in the near future:
1) Enabling modifications to units that will replace arbitrary colors(including changing alpha). For example, you could have an item with the effect of changing Konrad's blue garments to purple ones. Such an effect will need to be carefully tested by anyone who uses it, or weird results will likely happen.

2) Enable units to have in their config a set of random color changes that would be applied when they are first recruited. For example, units might be given random hair colors which would partially distinguish them.

3) Enable similar color changes to be defined in WML for item images.

4) Enable similar effects to be done to terrain.

5) use the above effect on terrain to enable simple color indexing animations (often used for animating water in older games.)
Attachments
colors.png
colors.png (266.97 KiB) Viewed 10369 times
User avatar
Kestenvarn
Inactive Developer
Posts: 1307
Joined: August 19th, 2005, 7:30 pm
Contact:

Post by Kestenvarn »

This looks very interesting... not sure i understand how you're deciding which parts of the image use the team colors, though. Does it involve channels or something?
User avatar
Eleazar
Retired Terrain Art Director
Posts: 2481
Joined: July 16th, 2004, 1:47 am
Location: US Midwest
Contact:

Re: Dfool of many colors

Post by Eleazar »

This is pretty exciting! :shock:
Darth Fool wrote:The basic WML tag mechanism looks like this:

Code: Select all

flag_red=109,130,130,77,205,160,205,104,137,132
flag_green=2,2,13,2,66,12,68,3,12,9
flag_blue=2,13,2,2,2,12,2,3,12,6
note that if one color's list is longer than the others, the missing number in the other lists will be filled in with 0s. so if artists use a pure red, blue or green to represent the flag color in the unit, only a single line is needed.

The colors are converted based on roughly the following algorithm:
1) the new color with the highest total of all three component colors (call it MAX_OLD)is set equal to the team color.
2) All other replacement colors (call them OLD)are changed into shades of the team color proportional to the ratio of OLD/MAX_OLD
Ok, i understand that the "code" contains 10 RGB color values. (right?)
But which are the "original" values and which are the replacement values?
Darth Fool wrote:2) Enable units to have in their config a set of random color changes that would be applied when they are first recruited. For example, units might be given random hair colors which would partially distinguish them.
I like that! Also horses could have some variety of color.

This would be a great way to distiguish "Hero" units instead of that blue "q" icon that floats near their head.

I propose that we reserve bright magenta* as the "team color" All recruitable units could have parts colored magenta. I.e. shields, capes, feathers in caps, or banners they might carry etc. Then the magenta would automatically be replaced with their team color as in D. Fools' example. Maybe then we can get rid of the "Team hula-hoop" (except to show selection. I "drew" the current "hula-hoop" but i wouldn't be sad to see it go.

AND, can we use something like this to do a better recoloring of the unreachable terrain, that is currently turned greyscale?

* Magenta is an unnatural color which shouldn't appear anywhere in Wesnoth. No one will miss it.
Feel free to PM me if you start a new terrain oriented thread. It's easy for me to miss them among all the other art threads.
-> What i might be working on
Attempting Lucidity
User avatar
Kestenvarn
Inactive Developer
Posts: 1307
Joined: August 19th, 2005, 7:30 pm
Contact:

Post by Kestenvarn »

Good choice... it would have to be several different shades of magenta, though.

This system looks vastly superior to using the colored discs at the base of each unit, by the way. Good thing there's an option to turn them off.
User avatar
Eleazar
Retired Terrain Art Director
Posts: 2481
Joined: July 16th, 2004, 1:47 am
Location: US Midwest
Contact:

Post by Eleazar »

In honor of this advance, i hereby grant you this limited-edition achievement avatar:
:wink:
Attachments
ManyColors.png
ManyColors.png (8.83 KiB) Viewed 10271 times
Feel free to PM me if you start a new terrain oriented thread. It's easy for me to miss them among all the other art threads.
-> What i might be working on
Attempting Lucidity
User avatar
Tomsik
Posts: 1401
Joined: February 7th, 2005, 7:04 am
Location: Poland

Post by Tomsik »

:lol:
Darth Fool
Retired Developer
Posts: 2633
Joined: March 22nd, 2004, 11:22 pm
Location: An Earl's Roadstead

Post by Darth Fool »

Ok, this is now in the trunk of SVN with the following changes:

1) in addition to using flag_red, flag_green, and flag_blue, you can now also define
a flag_rgb which should be a commas seperated list of triplets. ie:

Code: Select all

flag_rgb=77,2,2,104,3,3,109,2,2,130,2,13,130,13,2,137,12,12,132,9,6
2)the ellipses are now also done using this technique, so there is no longer a need for more than the ellipse images for team 1 in the images/misc directory. Also this means that if we later decide to change the team colors, or make them WML configurable, the ellipses will still match the team colors.

3) The HP bar has been removed from units when the HP= MAX_HP

4) I adjusted the colors used in the orcish_sovereign WML so that the flag would be as bright as the team colors.

To answer Eleazer's question, the current version only does a replacement of the colors with the team's flag color, so all of them are colors to replace. The team flag_color is currently hard coded in the game. I have thought about adding some WML to allow scenario designers to define it. Currently scenario designers can only choose one of the current colors ("colour=3" in a [side] tag sets the side to use team 3's color scheme.) I haven't yet added the arbitrary color swapping wml yet, but it shouldn't be too hard since the back end is in place. The arbitrary replacement will probably be in some form like:

Code: Select all

[recolor]
new_rgb=23,155,12
old_rgb=12,115,15,16,134,145,1,6,0
[/recolor]
But that is far from final. I need to implement it, test it to make sure it makes sense, etc...

edit: added new screenshot
Attachments
colors.png
colors.png (163.29 KiB) Viewed 10214 times
Darth Fool
Retired Developer
Posts: 2633
Joined: March 22nd, 2004, 11:22 pm
Location: An Earl's Roadstead

Post by Darth Fool »

Eleazar wrote:In honor of this advance, i hereby grant you this limited-edition achievement avatar:
:wink:
Thanks, gratefully accepted and all that. It has been quite awhile since I used an avatar. Hmm...now if I could just get a title to go with it...
User avatar
Kestenvarn
Inactive Developer
Posts: 1307
Joined: August 19th, 2005, 7:30 pm
Contact:

Post by Kestenvarn »

I'd go with 'Taste the Rainbow' myself...
User avatar
Eleazar
Retired Terrain Art Director
Posts: 2481
Joined: July 16th, 2004, 1:47 am
Location: US Midwest
Contact:

Post by Eleazar »

Darth Fool wrote:Thanks, gratefully accepted and all that. It has been quite awhile since I used an avatar. Hmm...now if I could just get a title to go with it...
Glad your using it. I don't do titles, though.

Some further thoughts on Team-branding the units:

Perhaps Wesnoth will use Magenta as the team color, unless there is a flag_rgb line in the unit.cfg. That way we can have magenta units if neccesary. The current Arch-mage is the only one i know that comes close to magenta. Unit artists will probably often choose the "flag_RGB" method to on a lot of old units.

I don't know if it's neccesary to say this, but for the team colors i'd reserve something like 255,220,255 <-> 100,0,100 with pure magenta at 255,0,255. If possible i'd make the equation that detects for default team color very strict about changes in hue (like the R+B values becoming unequal) and more generous about changes in value.
Feel free to PM me if you start a new terrain oriented thread. It's easy for me to miss them among all the other art threads.
-> What i might be working on
Attempting Lucidity
Boucman
Inactive Developer
Posts: 2119
Joined: March 31st, 2004, 1:04 pm

Re: Dfool of many colors

Post by Boucman »

Darth Fool wrote: The colors are converted based on roughly the following algorithm:
1) the new color with the highest total of all three component colors (call it MAX_OLD)is set equal to the team color.
2) All other replacement colors (call them OLD)are changed into shades of the team color proportional to the ratio of OLD/MAX_OLD
DFool, I think you might want to reexplain this one, it's important because it allows to do shading for the team colour.

it also mean that we can't just reserve a colour, but we need a whole "range" of colour...


and, DFool, btw, how does it handle the alpha channel ? doe sit work ?
Fight key loggers: write some perl using vim
Darth Fool
Retired Developer
Posts: 2633
Joined: March 22nd, 2004, 11:22 pm
Location: An Earl's Roadstead

Re: Dfool of many colors

Post by Darth Fool »

Boucman wrote:
Darth Fool wrote: The colors are converted based on roughly the following algorithm:
1) the new color with the highest total of all three component colors (call it MAX_OLD)is set equal to the team color.
2) All other replacement colors (call them OLD)are changed into shades of the team color proportional to the ratio of OLD/MAX_OLD
DFool, I think you might want to reexplain this one, it's important because it allows to do shading for the team colour.

it also mean that we can't just reserve a colour, but we need a whole "range" of colour...

and, DFool, btw, how does it handle the alpha channel ? doe sit work ?
Ok, here goes at another explanation

first, some definitions

Code: Select all

REP  = the list of colors in the original to replace
REP[i].r =  the red value of the i-th replacement color
REP[i].g = the green value  
REP[i].b = the blue value
REP[i].total = REP[i].r+REP[i].g+REP[i].b
MAX = the i-value that has the largest REP[i].total
TEAM = the rgb value of the team's color
NEW[i] = the rgb value that we will replace REP[i] with.

NEW[i].r = TEAM.r * REP[i].total / REP[MAX].total
NEW[i].g = TEAM.g * REP[i].total / REP[MAX].total
NEW[i].b = TEAM.b * REP[i].total / REP[MAX].total
So, I would agree that reserving a range of colors in the code is a bad idea. However,
we can make a macro for different reserved ranges that an artist could use and then
the only addition to the unit file might be something like:

Code: Select all

{FLAG_MAGENTA}
or maybe

Code: Select all

flag_rgb={FLAG_MAGENTA}
If this route is taken, it should also be possible to provide a pallete graphic that has these colors in them so that artists can simply sample from the pallete without having to carefully select colors that match the rgb value.

currently there is no limit on the number of colors that can be declared in flag_rgb, but there was some interest from other developers to limit the number to something reasonable. It seems to me that 256 is a reasonable maximum # of colors to have, as that enables the artist to span the complete colorspace that might be replaced by the team color, allthough it probably should never ever get that large. Perhaps 64 would be just as good. Do artists have an opinion about how many shades of a color they need?

edit: re alpha values. Currently the code does not change the alpha value at all. I thought about it and came to the conclusion that for the team colors this would needlessly complicate things. I am planning that the more generic modifcation effect will allow unit-designers to tweak alpha values as well.
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin »

Interesting... IMHO you applied it to too many units. Imho, the Dark Adept line and Orcish Sovereign (at least, not to the degree it has it) should not have this added to them... the Dark Adepts just don't look evil when they're wearing, for example, yellow. Also, the rest of the Sovereign line needs changing, since the first two levels will be indistinguishable for a green team. ;)
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
MadMax
Posts: 1792
Joined: June 6th, 2004, 3:29 pm
Location: Weldyn, Wesnoth

Post by MadMax »

Darth Fool wrote:Also this means that if we later decide to change the team colors, or make them WML configurable, the ellipses will still match the team colors.
They are already: [side] takes a colour= attribute. Also, can you PLEASE keep it so that colour=100 will still force a unit to be without an ellipse?
"ILLEGITIMIS NON CARBORUNDUM"

Father of Flight to Freedom
http://www.wesnoth.org/wiki/FlightToFreedom
Darth Fool
Retired Developer
Posts: 2633
Joined: March 22nd, 2004, 11:22 pm
Location: An Earl's Roadstead

Post by Darth Fool »

MadMax wrote:
Darth Fool wrote:Also this means that if we later decide to change the team colors, or make them WML configurable, the ellipses will still match the team colors.
They are already: [side] takes a colour= attribute. Also, can you PLEASE keep it so that colour=100 will still force a unit to be without an ellipse?
I meant that you could define a color other than the 9 or ten that are predefined in the code.
In other words, if you want the color to be some mix of blue-green that is not the current cyan, you could specify it as an rgb value. This is very different from what the current colour=attribute which simply replaces the teams color with the color of a different (still predefined) team color. What I am proposing would enable you to have more than ten team colors.

As for the colour=100 Hmm... I didn't know about this and it seems to me to likely have been an oversight in the original scheme, but perhaps not. Would you consider it acceptable if a colour=-1 has that effect?
Post Reply