Level-safe Palette Conversions
By Matt H

Many DF level and component editors out there have had problems with palettes. Sometimes it's annoying little transparent holes in a graphic, trying to use the color black. Sometimes it's extraneous brite-mapped pixels on a wax that only show up once it's placed in a low-light secotor. Sometimes it's a texture that looks great in one level, but can't be used in another because it uses a different palette.

I want to show you a procedure that can end all that a procedure that converts images into a form that is safe to use in all DF palettes and under all lighting conditions.

What you need: An image editing program that loads, saves, and edits palettes. (I usually use Photoshop, but I know this can work in Paint Shop Pro 3 as well.) You can also use these graphics:


SEC-SML.GIF
Image using the secbase palette.
   
DEF-NOBR.GIF
Image using a default, no-brite palette.

[Edit by japh: Matt H later posted this in the forums:]

The first image shows all the colors in the SECBASE palette - the most common palette used in the game. The second image shows which of those colors are 'default' - "The remaining colors are the colors that are consistent throughout all of the Dark Forces levels (and briefings.) If you make your image use just these colors, it will work in any level."

So, the colors that are the same in both are the 'default' colors. If you count, you will see that they are colors #32-207 and color #255 (with the first color being '0'). If you want their exact RGB values, take the time to look at the palette in an image editor.

(By the way, here's a little article I found that helps explains "anti-aliasing".) [Article]

Take a look at the second image. It shows the entire arrangement of this specialized palette. With the exception of the Color 0, all of the brite-mapped colors, the level-custom colors, and the special colors have been set to yellow. Color 0 has been set to bright purple. The remaining colors are the colors that are consistent throughout all of the Dark Forces levels (and briefings.) If you make your image use just these colors, it will work in any level.

The first bit of prep work you need to do is to go into your image editing program and load up these images. Find the colors/palettes section of the image editing program and save the palettes of each image (in Photoshop: Image, Mode, Color Table -> Save; in Paint Shop Pro 3: Colors, Save Palette.) You should probably save the palettes in the image editor's native format (in PS, it's .ACT; in PSP3, it's .PAL (JASC PAL)- notice this is not the same as DF's .PAL.)

Once that is done, you are ready to convert your images to be level-safe.

All transparent parts should be purple. If there are any non-purple parts that you want transparent, use a pencil tool to color them in purple. Any remaining black pixels will be solid. You should also check the edges to fix any anti-aliasing problems that may have occurred. The image editing program should now automatically do the best match of the colors in your image to the default-nobrite palette. One way that I check to see how safe my image is is to load in another default-checking palette used here:

DEF-CHK.GIF
Image using a default checking palette.

With this palette, all of the brite-mapped colors turn cyan, all the custom colors turn yellow, while the background turns purple. This way, I can check my images, and see if there are any potential problem areas and fix them.

   
The guard on the left will have many problems: he will have gaps in his neck, hands, and helmet; if he's placed in a dark sector, parts of his pants will glow bright red; and if he's put in a palette other than secbase (or equivalent), parts of his helmet, face, and gloves may be discolored. The guard on the right, however, will look good in any environment.

The colors here can of course be modified if you modify the palettes. You can also modify the technique so that brite-maps are included, but not the custom colors (or vice-verse.) You could even make something to convert to ONLY the brite mapped colors if you wanted.

The downside to all this is that your image could loose some of its depth, since it is using less colors. Therefore, this technique may not be for everyone, especially with custom textures. But for making general custom components, especially waxes and fmes, this can be extremely useful.

If you are fortunate enough to use Photoshop, I suggest you set this procedure to an Action, so you can quickly use it to convert your files.

One last thing: when you are converting your image into a Dark Forces format, if at all possible do a straight conversion - do not specify any palette to use. Your image has already got the correct color indexes, making palette conversion unnecessary. You also don't have control over how the ->DF program will convert the colors. So it could really screw things up.