Palette

From SRB2 Wiki
Jump to: navigation, search
"COLORMAP" redirects here. For the colormap linedef special, see Linedef type 606.
ToDoIcon.png To do
Show the reader how to save pictures with the SRB2 palette. The WAD editor method is done, but we still need the graphics editor method.
SRB2's current palette, used for all flats, patches, sprites and other graphics.
The palette is the set of 256 colors that SRB2 can display. Instead of storing the color values directly, the data format used for all of SRB2's graphics stores the color index in the palette for each pixel. Because SRB2 will crash when trying to display a graphic that is not mapped to the palette, graphics that are stored in WAD or PK3 files need to be converted from their native format to the Doom Graphics Format first (except for flats, which are stored in the Doom Flat Format). The textures for MD2 models, which are exclusive to OpenGL, are exempt from this.

Since Version 2.0, SRB2 has differed from the palette that is used in Doom, which means that graphics from earlier versions of SRB2 will have to be converted before they can be used in the current version. (See to the right or above for SRB2's current palette.)

The color cyan, which is present at index 247 in SRB2's palette, is commonly used to designate pixels that are meant to be transparent in the game. This convention was adopted by the Doom community because Doom's original palette included an unused color at index 247 and because such cyan contrasted well with Doom's primarily dark graphics. Some editors, such as XWE, automatically convert all pixels with index 247 to transparent pixels upon converting an image to the palette. SLADE allows the user to choose a different color to be converted to transparency.

On middle textures, or on FOFs without FF_CUTSOLID, palette index 247 will be treated as transparent. Flats are also able to do the same, if used on a translucent FOF (such as linedef type 102), if used with an alpha value of #255.

Technical information

SRB2's default palette is stored in the PLAYPAL lump inside srb2.srb. Related to the palette is the COLORMAP lump, which controls how the colors fade in different light levels. It is possible to replace the palette by loading a WAD or PK3 file that includes different PLAYPAL and COLORMAP lumps with a different palette. This palette will then overwrite the default one. Additionally, there is a level header option called Palette that allows the user to change the palette between levels.

PLAYPAL

The PLAYPAL lump located in srb2.srb stores 14 palettes, the first 5 of which have specific uses in SRB2, and the remainder of which are unused. All except the first are intended for use as flash palettes – i.e. temporary palettes that display in particular situations before returning to display the first palette again. For technical reasons, the OpenGL rendering mode does not directly use these flash palettes, but modifies the screen's display colors to simulate these – for this reason, custom palettes with different color tints will not appear as expected in OpenGL, as the simulated flash palettes' colors are pre-determined in SRB2's source code.

The constants for use in Lua and SOC are also given in the table below:

Palette number Palette name Description
0 none The default palette for SRB2.
1 PAL_WHITE SRB2's palette with a 75% white tint, of RGB(255,255,255). The flash palette used for Attraction Shields shorting out in water and Ideya Capture defeat.
2 PAL_MIXUP SRB2's palette with a 75% white tint, of RGB(255,255,255). The flash palette used for teleports and Teleport Monitors.
3 PAL_RECYCLE SRB2's palette with a 75% white tint, of RGB(255,255,255). The flash palette used for Recycler Monitors.
4 PAL_NUKE SRB2's palette tinted red. The flash palette used for Armageddon Shield explosions.

Note: This palette can be reproduced by tinting SRB2's palette 75% white as with the palettes above, but then changing the green/blue levels of all color indexes to 113.

5–13 n/a Unused palettes, all of SRB2's palette with a 75% white tint, of RGB(255,255,255), by default.

COLORMAP

SRB2's COLORMAP lump.

The COLORMAP lump stored in srb2.srb is a 256×34 graphic lump containing the default set of colormaps used by the game, storing colors in the same manner as flats (storing palette indexes rather than actual pixel colors). Each row in the graphic is a single colormap (an array of 256 palette indexes), which remaps each of the 256 colors from the palette to different indexes. The COLORMAP lump contains 34 different colormaps in total:

  • The first 32 colormaps (0–31) are used for the 32 different sector brightness levels that exist for the Software rendering mode; 0 is the brightest, and 31 is the darkest. These colormaps may also be used for walls, flats and sprites depending on the sectors they are located in and their distance from the camera. Walls additionally have their colormaps modified by what direction they are facing.
  • The remaining two colormaps (32 and 33) are leftovers from Doom and are unused by SRB2.

The first 32 colormaps correspond with the following sector brightness level ranges in Software, where 0 is complete darkness and 255 is maximum brightness:

Colormap # Brightness
0 248–255
1 240–247
2 232–239
3 224–231
4 216–223
5 208–215
6 200–207
7 192–199
Colormap # Brightness
8 184–191
9 176–183
10 168–175
11 160–167
12 152–159
13 144–151
14 136–143
15 128–135
Colormap # Brightness
16 120–127
17 112–119
18 104–111
19 96–103
20 88–95
21 80–87
22 72–79
23 64–71
Colormap # Brightness
24 56–63
25 48–55
26 40–47
27 32–39
28 24–31
29 16–23
30 8–15
31 0–7

PALxxxx and CLMxxxx

These lump names are reserved for custom level palettes (see Level header > Palette), and are identical in function to the PLAYPAL and COLORMAP lumps respectively. xxxx for these is a four-digit number between 0000 and 9999, and determines what palette set number they correspond with – PAL0000 and CLM0000 are reserved for when Palette in a level header is set to 1; PAL9999 and CLM9999 are reserved for when Palette is set to 10000. In general, the value of xxxx should be the intended value for Palette in a level header, minus one.

TRANS10–TRANS90

These lumps are SRB2's translucency maps for the Software rendering mode. These convert the colors of a graphic's pixels to other colors in SRB2's palette, depending on the translucency map being applied and what is being displayed behind them at the time – each row in a translucency map represents a possible palette color for the foreground, each column a possible palette color for the background, and the places a selected row and column meet give the resulting palette color used.

There are nine translucency maps in total, one for each of nine different levels of translucency:

Lump name Image (thumbnail) Description
TRANS10
TRANS10.png
10% translucency
TRANS20
TRANS20.png
20% translucency
TRANS30
TRANS30.png
30% translucency
TRANS40
TRANS40.png
40% translucency
TRANS50
TRANS50.png
50% translucency
Lump name Image (thumbnail) Description
TRANS60
TRANS60.png
60% translucency
TRANS70
TRANS70.png
70% translucency
TRANS80
TRANS80.png
80% translucency
TRANS90
TRANS90.png
90% translucency

Note that these lumps use the same graphics format as flats.

Setting up the palette

In order to use graphics in a WAD or PK3 file, they have to be converted to Doom's graphics format first. By default, lump editors will convert graphics into Doom's palette, but since SRB2's palette is different, this will mess up the graphics' colors. To convert images correctly, the lump editor needs to be directed to SRB2's palette.

SLADE

Unlike other WAD editors, SLADE already includes SRB2's palette in its native selection. To activate it, select "Sonic (SRB2)" in the "Palette" dropdown box in the toolbar. Additionally, if you select srb2.srb as your base resource (the SLADE article explains how to set this up), the "Existing/Global" palette option will also be SRB2's palette.

XWE

When you open XWE, it will default to using the palette included in the IWAD that XWE has been pointed to. Every image you load into a WAD or PK3 file will be converted to that palette. If the file that is currently opened contains a palette lump, you can select the lump and go to Palette → Use Current in the menu bar to make XWE switch to that palette instead. Alternatively, if you have an image lump selected, you can go to Image → Select Palette to choose a palette among a selection of palettes that are saved in the PALETTES folder in the XWE directory. You can switch back to the default palette by selecting the "(auto)" option.

There are two ways to make XWE use SRB2's palette: One is to set XWE's IWAD to srb2.srb so that it will always load SRB2's palette automatically. The other is to save SRB2's palette in the PALETTES folder so you can select it via Image → Select Palette. This is especially useful if you want to switch back and forth between SRB2's palette and other palettes, for examples when converting images between palettes.

Changing XWE's IWAD

  • Find xwe.ini in your XWE folder and open it with a text editor like Notepad.
  • Go to "Edit → Find..." and search for "MainWAD".
  • At the first occurrence of "MainWAD", change the text so that it points to srb2.srb, according to the following format: MainWAD,C:\Folder\Folder with spaces\SRB2\,srb2.srb. Make sure to put the commas in the correct places.

Saving the SRB2 palette in the XWE folder

  • Open XWE and go to "View → Options".
  • Make sure the "Perform Clean Up on exit" option is unchecked. Otherwise, XWE might modify srb2.srb accidentally and the game won't start anymore.
  • Open srb2.srb and select the PLAYPAL lump.
  • Go to "Palette → Save As" and navigate to the PALETTES folder inside your XWE folder.
  • Save the file with a file name you can remember (srb2.act, for example).
  • Now you can switch to SRB2's palette by selecting an image lump, going to "Image → Select Palette" and choosing the palette you saved.

Converting images from v1.09.4 to the current version

SLADE

  • Set the Base Resource to the current version's srb2.srb and the palette to "Existing/Global".
  • Open the file, select all lumps that you want to convert and right-click on one of them.
  • Select "Gfx → Convert to...".
  • In the window that should open now, select "Doom Gfx (Paletted)" as the format to convert to.
  • Select "Doom" as "Current Graphic" and "Existing/Global" as "Converted Graphic". Both pictures should now look the same.
  • Click "Convert All" to convert all selected graphics at once.

You can also select "Sonic (SRB2)" as "Converted Graphic", which allows you to convert images even when you have a different Base Resource and palette loaded.

XWE

To do this, you must have either set XWE's IWAD to srb2.srb (see Changing XWE's IWAD) or saved the SRB2 palette in your XWE folder (see Saving the SRB2 palette in the XWE folder). Afterwards, follow these steps:

  • Open the file that contains the images you want to convert.
  • Select an image in the file and go to "Images → Select Palette → doom" and click OK.
  • Select the images you want to convert, go to "Entry → Save As" and export the images.
  • Go to "Images → Select Palette", select SRB2's palette and click OK. If you have saved SRB2's palette, it should appear in the list. If you have set XWE's IWAD to srb2.srb, you can select "(auto)".
  • Go to "Entry → Load" and import the images that you saved. They will automatically be converted.

Creating custom palettes

Custom palettes may be wanted sometimes to change the appearance of graphics in SRB2, or to fit custom graphics being added in a custom modification. These can be made using SLADE's palette editing features:

  • To start off with SRB2's base palette, either the PLAYPAL lump from srb2.srb itself can be imported into the required WAD or PK3 file, or a new PLAYPAL lump can be generated by going to "Archive → New → PLAYPAL" and selecting "Sonic (SRB2)" from the dropdown box in the window that pops up (or "Existing/Global" if srb2.srb has been set as your base resource). Note that the latter method will only include the first of SRB2's palettes (see above for further information).
  • To modify specific colors in the palette, right click on them to bring up the window for modifying a color and apply the changes.
  • Other changes can be made to the whole of or part of the palette; the available options are:
    • "Colorize" – converts all palette colors to shades of a specific color
    • "Tint" – applies a tint of a specific color and amount to all palette colors
    • "Tweak" – adjusts Hue shift, Saturation and Luminosity settings
    • "Invert" – allows a selected range of the palette colors to be inverted
  • Further palettes can be created if needed, and can be switched between and such. Relevant options include:
    • "Generate Palettes" – will automatically generate the remaining palettes depending on the option selected (should be "Doom (14 Palettes)"). However, by default these will generate the relevant palettes modifications required for Doom rather than for SRB2; see above for how palettes should be colored in SRB2.
    • "Duplicate" – will automatically duplicate the currently selected palette in a new slot after all currently existing palettes.
    • "Pull Ahead" – will move the palette back a slot number. If the current palette is the first palette, the new slot given will be the last palette number.
    • "Push Back" – will move the palette forward a slot number. If the current palette is the last palette, the new slot given will be the first palette number.
    • "Remove" – will delete the currently selected palette and switch to viewing the next palette in the list.
    • "Remove Others" – will delete all palettes except the palette currently selected.
  • Options available after finishing the palette:
    • "Test Palette" – temporarily adds the palette to the list of selectable palettes for SLADE to display graphics with. The palette will be removed from the list when SLADE itself is closed.
    • "Add to Custom Palettes" – same as above, except the palette is permanently added to SLADE's palette list.
    • "Palette → Generate Colormaps" – automatically generates a COLORMAP lump for the selected palette lump.

See also