Palette Tutorial

User avatar
Kyran
Posts: 499
Joined: Sat Dec 31, 2011 5:19 pm
Location: Australia
Contact:

Palette Tutorial

Postby Kyran » Tue Dec 18, 2012 11:40 am

A short palette HOW-TO.

1) There is a global palette used as default and for general things,
linedraws. This global palette depends on the tileset, to keep
compatibility.

Some colors are currently used, but could be made configurable:

ColorBlack = 0
ColorDarkGreen= 149
ColorBlue = 206
ColorWhite = 246
ColorNPC = 247
ColorGray = 248
ColorRed = 249
ColorGreen = 250
ColorYellow = 251
ColorBlinkRed = 252
ColorViolett = 253

This colors cycles for water in the tileset:
ColorWaterCycleStart = 38, - ColorWaterCycleEnd = 47,
This colors cycles for icons:
ColorIconCycleStart = 240, - ColorIconCycleEnd = 244

This colors must be fixed:

#0 general background (RGB = 0,0,0)

#208 replaced by player color (brightest shade)
#209 replaced by player color (next brightest)
#210 replaced by player color (darker shade)
#211 replaced by player color (darkest shade)

#253 general editors color (should NEVER be used in any image,
RGB = 255,50,255)
#255 general transparency color (RGB, 255,255,255)

2) Each graphic object (unit, decoration) could have its
private palette (8bit or 16bit)

This colors must be fixed for 8bit:

#0 general background (RGB = 0,0,0)

#208 replaced by player color 1
#209 replaced by player color 2
#210 replaced by player color 3
#211 replaced by player color 4

#253 general editors color (should NEVER be used in any image,
RGB = 255,50,255)
#255 general transparency color (RGB, 255,255,255)

For 16bit palette we shouldn't change this, than we didn't need to save
(store) a complete palette.

Private palettes didn't support color cycling, this must be simulated with
animation's.

Notes:
Same palettes should be shared, reducing the memory use.
The correct palette must be saved with the units.

(c) 2001 by Lutz Sammer,
you can redistribute it and/or modify it under the terms of the GPL.
04:27 jim4 why haven't you added wc1 support? this project sucks. i'm only going to use freecraft
05:06 jim4 finished wc1 support yet? i've been waiting for 6 years
05:10 jim4 new things scare me
User avatar
jarod42
Posts: 101
Joined: Fri Jan 20, 2012 7:43 pm

Re: Palette Tutorial

Postby jarod42 » Wed Dec 19, 2012 12:10 am

See following lua functions for configuration.

Code: Select all

DefinePlayerColorIndex(208, 4)
DefinePlayerColors(...)

Code: Select all

SetColorCycleAll(true)
ClearAllColorCyclingRange()
AddColorCyclingRange(38, 47) -- water
AddColorCyclingRange(205, 207) -- building
AddColorCyclingRange(240, 244) -- icon
User avatar
b_o
Posts: 328
Joined: Sun Jan 01, 2012 12:07 pm

Re: Palette Tutorial

Postby b_o » Sat Jul 20, 2013 10:50 am

So are we still limited to using a 256 color palette?
User avatar
Andrettin
Posts: 433
Joined: Sun Jun 30, 2013 9:58 pm
Location: Vienna, Austria
Contact:

Re: Palette Tutorial

Postby Andrettin » Sat Jul 20, 2013 8:14 pm

b_o wrote:So are we still limited to using a 256 color palette?
My understanding is that we are limited to using a 256 color palette, but contrary to how WC2 worked, we can use a specific palette for each unit (if I remember correctly, in WC2 there was one palette per tileset which would be applied to everything if that tileset were being used).
User avatar
b_o
Posts: 328
Joined: Sun Jan 01, 2012 12:07 pm

Re: Palette Tutorial

Postby b_o » Sun Jul 21, 2013 12:24 pm

What about the tilesets? those get separate palettes as well? I'm working on a new tileset now.
User avatar
Andrettin
Posts: 433
Joined: Sun Jun 30, 2013 9:58 pm
Location: Vienna, Austria
Contact:

Re: Palette Tutorial

Postby Andrettin » Sun Jul 21, 2013 6:45 pm

b_o wrote:What about the tilesets? those get separate palettes as well? I'm working on a new tileset now.
Basically, as I understand it, each graphics file can have its separate palette. One thing to watch out for is that a certain quantity of color numbers are used for color cycling (that's what makes water move and the dark portal whirl, despite there being only one frame for those graphics) and colors 208-211 (IIRC) are used. You can easily turn off color cycling for units (but maintain it for tilesets) in stratagus.lua, though, in order to have more possible colors for units (set SetColorCycleAll(true) to false).
User avatar
DinkyDyeAussie
Posts: 259
Joined: Fri Feb 10, 2012 10:39 am
Location: Australia

Re: Palette Tutorial

Postby DinkyDyeAussie » Wed Jul 24, 2013 2:03 pm

Andrettin wrote:(if I remember correctly, in WC2 there was one palette per tileset which would be applied to everything if that tileset were being used)
This is true. I discovered this when I tried to enter the lua code to make the water/shore cycle for each tileset, and the portal cycle for each tileset. So glad this works for each tileset now, but I had to put scripting in each "tileset".lua file. before that I was just placing the "AddColorCyclingRange(##, ##) properties in the stratagus.lua.

That worked for certain things on one tileset, say winter, but if I tested any other tileset using the code that worked for winter, everything would cycle (rocks, grass, trees, etc) - eventually I figured out that any color cycling properties I wanted to implement for each tileset would need to go in it's respective "tileset.lua" file, and now each tileset color cycling works as it should and as it did in WC2.

So if you want to change or add color cycling for units, just add another "AddColorCyclingRange" line to the respective "tileset".lua file and experiment with the two numerical values - that's what I did to get the portal and water and other things to cycle correctly.
User avatar
b_o
Posts: 328
Joined: Sun Jan 01, 2012 12:07 pm

Re: Palette Tutorial

Postby b_o » Thu Jul 25, 2013 1:11 am

DinkyDyeAussie wrote:
Andrettin wrote:(if I remember correctly, in WC2 there was one palette per tileset which would be applied to everything if that tileset were being used)
This is true. ... So if you want to change or add color cycling for units, just add another "AddColorCyclingRange" line to the respective "tileset".lua file and experiment with the two numerical values - that's what I did to get the portal and water and other things to cycle correctly.
So in stratagus, the units do not get their own palettes, but rather each tileset palette limits which colors the units can use? Or does it just limit the functions of certain index numbers in the palette? So are there only 256 colors on the entire screen at any given time, or can there be more if the units private palette differs from the tileset palette? Are the interface graphics also limited by the tileset palette?
User avatar
jarod42
Posts: 101
Joined: Fri Jan 20, 2012 7:43 pm

Re: Palette Tutorial

Postby jarod42 » Thu Jul 25, 2013 6:44 am

Some index in the palette are special (according to DefinePlayerColorIndex, AddColorCyclingRange).
or reserved. (#255 general transparency colour (RGB, 255,255,255)).

Each "graphic file" may have its own palette.
Note that some files may contain several "graphics" as tileset, "units animations".
(so each tile can't have its own palette).
User avatar
b_o
Posts: 328
Joined: Sun Jan 01, 2012 12:07 pm

Re: Palette Tutorial

Postby b_o » Thu Jul 25, 2013 11:29 am

ok, that makes sense.

What kind of palette editing tools do you guys use? I like irfanview , it's the best thing I've found to decrease color depth without distorting images, and the palette editor seems decent enough.

Who is online

Users browsing this forum: No registered users and 3 guests