Dfool of many colors

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

Moderator: Forum Moderators

Post Reply
yobbo
Art Contributor
Posts: 151
Joined: September 16th, 2005, 6:31 am
Location: New Zealand

Post by yobbo »

Jetryl wrote:
Darth Fool wrote:Now, the question I have is, can this easily be done in RGB space, or should I do it in HSV space? I can imagine that in HSV space one could reduce the number of parameters since presumably the hue should not change, so you would only need to specify the range for the Saturation and Value(or should I say Brightness?)
Yobbo, do you want to figure this out, or shall I commence to ciphering?
Let's see...

Assuming we want to define 3 colours from the TBRS: Rmin, R and Rmax; and 3 colours for the team colour: TCmin, TC and TCmax...

The simplest way to convert a colour X from the TBRS to a colour Y in the TCS would be to map from the value of X. So RGB space should be fine - I think this is pretty much the method Darth Fool's used so far (right?):

Code: Select all

val(Z) = max(Zr, Zg, Zb) # red, green, blue

if val(X) < val(Rmin):
  X = Rmin
if val(X) > val(Rmax):
  X = Rmax

case val(X) <= val(R):
  A = ( val(X) - val(Rmin) ) / ( val(R) - val(Rmin) )
  Yr = [TCmin]r + A * ( [TC]r - [TCmin]r )
  Yg = [TCmin]g + A * ( [TC]g - [TCmin]g )
  Yb = [TCmin]b + A * ( [TC]b - [TCmin]b )

case val(X) > val(R):
  A = ( val(X) - val(R) ) / ( val(Rmax) - val(R) )
  Yr = [TC]r + A * ( [TCmax]r - [TC]r )
  etc for Yg, Yb
This would ignore the saturation of X - but it would allow the highlights and lowlights to be manually defined for each team colour.

Oh - if you want absolute limits of white and black for the TBRS, just hard-code Rmin to (0,0,0) and Rmax to (255,255,255) :). It might be useful to have these colours editable in WML somehow, though...
Darth Fool
Retired Developer
Posts: 2633
Joined: March 22nd, 2004, 11:22 pm
Location: An Earl's Roadstead

Post by Darth Fool »

Well, my current plan is to define three rgb values, the minimum, the maximum, and the team color. For original colors where the total color (r+g+b) is less than the first total, the new color will be a linear combination of the team color and the minimum color, weighted by the ratio of the original color to the first color. Ok, the code might be easier to understand:

Code: Select all

  const Uint16 old_avg = (Uint16)(((Uint16) old_r +
                                                (Uint16) old_g +
                                                (Uint16) old_b) / 3);

              if(reference_avg && old_avg <= reference_avg){
                float old_rat = old_avg/reference_avg;
                new_r=(Uint8)( old_rat * new_red   + (1 - old_rat) * min_red);
                new_g=(Uint8)( old_rat * new_green + (1 - old_rat) * min_green);                new_b=(Uint8)( old_rat * new_blue  + (1 - old_rat) * min_blue);
              }else if(255 - reference_avg){
                float old_rat = (255-old_avg)/(255-reference_avg);
                new_r=(Uint8)( old_rat * new_red   + (1 - old_rat) * max_red);
                new_g=(Uint8)( old_rat * new_green + (1 - old_rat) * max_green);                new_b=(Uint8)( old_rat * new_blue  + (1 - old_rat) * max_blue);
              }else{
                //should never get here
                //would imply old_avg > reference_avg = 255
              }
now, this will work reasonably when the min color is black, and the max color is white. Other colors will work as well as long as the min is a darker version of the team color, and the max is a lighter version. Strange things will happen for arbitrary min and max. It, will, for example, be possible to invert the lighting by setting max to black and the min to white, or do stranger things by setting the team color to red, the max to green, and the min to blue. This might be too much freedom, but it is the easiest thing to code and still allow flexibility to change the color range. By default black and white will be used for the min and max respectively. In addition, the fact that the team color range default values will all be WML configurable should allow jetryl and Eleazer enough flexibility to come up with reasonable values.
yobbo
Art Contributor
Posts: 151
Joined: September 16th, 2005, 6:31 am
Location: New Zealand

Post by yobbo »

Darth Fool wrote:Well, my current plan is to define three rgb values, the minimum, the maximum, and the team color. For original colors where the total color (r+g+b) is less than the first total, the new color will be a linear combination of the team color and the minimum color, weighted by the ratio of the original color to the first color.
Yeah, using the sum/average of r/g/b like you are is better than what I said :).
Strange things will happen for arbitrary min and max. It, will, for example, be possible to invert the lighting by setting max to black and the min to white, or do stranger things by setting the team color to red, the max to green, and the min to blue.
I like the idea of the Inverted Psychadelic Rainbow team... please leave this possibility in ;).
Darth Fool
Retired Developer
Posts: 2633
Joined: March 22nd, 2004, 11:22 pm
Location: An Earl's Roadstead

Post by Darth Fool »

Ok, this has now been implemented. team_rgb can now be set to use three rgb values, the first is the team color, the second is the maximum (default white), the third is the minimum (default black). "team_rgb=255,0,0,0,255,0,0,0,255" set in a side tag in a scenario will set the team colors to the psychedelic rainbow. Alternatively, the default values can be set in the new team_colors.cfg. a sample of how to do this for the side=1 has been done. Note that this change also will mean that the first color in flag_rgb in a unit.cfg is now used to set the luminosity used for the team color. Go nuts...
User avatar
Eleazar
Retired Terrain Art Director
Posts: 2481
Joined: July 16th, 2004, 1:47 am
Location: US Midwest
Contact:

Post by Eleazar »

:shock: :D

commencing nut-going....
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
Jetrel
Posts: 7242
Joined: February 23rd, 2004, 3:36 am
Location: Midwest US

Post by Jetrel »

Eleazar wrote::shock: :D

commencing nut-going....
Indeed. #jetryl is nuts about dfool's patch
User avatar
Jetrel
Posts: 7242
Joined: February 23rd, 2004, 3:36 am
Location: Midwest US

Post by Jetrel »

I've updated the macro to use the existing team colors I had already defined for horsemen et. al. correctly.

Once I get more units in, the "thing to do" will be to look at how the team colors are used on these units, and imitate that when team coloring a unit.
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin »

So, uh... which pallette of magenta colors should we use to get tcolor done correctly? :?
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
User avatar
Jetrel
Posts: 7242
Joined: February 23rd, 2004, 3:36 am
Location: Midwest US

Post by Jetrel »

Do-de-do-de-do, uploading screenshots for tutorial....
Attachments
TCPatch-on.png
TCPatch-on.png (190.42 KiB) Viewed 5772 times
TCPatch-off.png
TCPatch-off.png (151.54 KiB) Viewed 5773 times
TCPatch-alone.png
TCPatch-alone.png (37.71 KiB) Viewed 5773 times
User avatar
Jetrel
Posts: 7242
Joined: February 23rd, 2004, 3:36 am
Location: Midwest US

Post by Jetrel »

turin wrote:So, uh... which pallette of magenta colors should we use to get tcolor done correctly? :?
Ahem:
http://www.wesnoth.org/wiki/Team_Color_Shifting

The one linked in there. :)
Woodwizzle
Posts: 719
Joined: December 9th, 2003, 9:31 pm
Contact:

Post by Woodwizzle »

Spifftastic! I can't wait to play with this feature.
Signature dropped due to use of img tag
User avatar
Jetrel
Posts: 7242
Joined: February 23rd, 2004, 3:36 am
Location: Midwest US

Post by Jetrel »

Adding in some more images to be linked by a tutorial...
Attachments
unitShadows1.png
unitShadows1.png (52.63 KiB) Viewed 5670 times
unitShadows2.png
unitShadows2.png (12.09 KiB) Viewed 5669 times
unitShadows3.png
unitShadows3.png (14.72 KiB) Viewed 5670 times
User avatar
Jetrel
Posts: 7242
Joined: February 23rd, 2004, 3:36 am
Location: Midwest US

Post by Jetrel »

More images for a tutorial.
Attachments
unitShadows4.png
unitShadows4.png (15.97 KiB) Viewed 5663 times
unitShadows5.png
unitShadows5.png (12.31 KiB) Viewed 5662 times
unitShadows6.png
unitShadows6.png (42.67 KiB) Viewed 5662 times
User avatar
Viliam
Translator
Posts: 1341
Joined: January 30th, 2004, 11:07 am
Location: Bratislava, Slovakia
Contact:

Post by Viliam »

Darth Fool wrote:Amongst the other changes that I am making, it will be possible to define the default colors in WML.
How about setting the team colors in user preferences? It could be useful for color-blind people... for each form of color-blindness there could be one recommended color scheme where colors look most different. It is not necessary to pick RGB values for each team (this would make UI too difficult), but selecting from a few pre-built color sets could be useful and easy to implement.
Darth Fool
Retired Developer
Posts: 2633
Joined: March 22nd, 2004, 11:22 pm
Location: An Earl's Roadstead

Post by Darth Fool »

I provide attached a new tool for art developers and possibly use on the automated unit web pages. The tool is a perl script that uses the ImageMagic convert program to take an existing file that uses the magenta coloring scheme and convert it into a very close approximation of what wesnoth will do using the default team 1's coloring scheme (red). The tool is used like the following:

Code: Select all

./TeamColorizer.pl colorswatch_200.png colorswatch-red.png 
I attach what happens to the magenta colorswatch. Note that I don't think that this is quite the intention of Jetryl for what the colorswatch should do. The "new attachment" is what happens if I set the middle color(236,0,140) in the swatch to be the team color. I have commented out the line in the perl script that makes the change, however, we might want to consider changing the macro definition in utils.cfg to fix this.
Attachments
colorswatch-new-red.png
colorswatch-new-red.png (350 Bytes) Viewed 5538 times
TeamColorizer.pl.gz
(790 Bytes) Downloaded 517 times
colorswatch-red.png
colorswatch-red.png (326 Bytes) Viewed 5538 times
Post Reply