Common palette tutorial
The easy way to use Bright183

The Dark Engine has a limit of about 248 different colour palettes which can be in use at any given time. Each unique colour palette that you use, be it for an object texture or for a terrain texture, counts towards this limit.
In the original Thief, all the textures used the same 256 colour palette (the 'txt' palette), and as such the total number of palettes used was 1 (even though the engine supported far more; this was a limit in place to keep support for Software rendering).
Thief 2, however, uses a lot of different palettes; as you probably know, each texture family has its own palette, and 'txt16' object and mesh textures can use any palette they want.
When loading object textures from txt16, the Dark Engine will actually check to see if an image uses a palette which has already been loaded, and if it does then the palette will not be loaded twice. In other words, any number of images with identical palettes only count one towards the palette limit.

When creating custom objects and textures, it is easy to use a unique palette for each texture, but if you use a lot of custom resources, you can easily hit this limit.
As such, you should always try to give a common palette to textures which use similar colours.

The best program for converting several images to use a common palette is Bright183. (It can be downloaded here, among other places).

This tutorial will explain how to use Bright to easily repalettise groups of textures, by using some batch files I've written, and a new folder for each texture set.
(I know that Telliamed has written a GUI front-end for Bright, but I find my method much easier...)

You will need Bright183 and IrfanView.

You have two choices; you can either download these batch files in a zip here, or you can do things manually and copy each of the three code blocks at the bottom of this tutorial and paste them into your favourite text editor, then save them as batch (.bat) files. The suggested file name for each one is just above it.

With either method, you will need to change the line 'set BrightPath=C:\Games\DromEd\Bright183' of each batch file to point to the correct path for your Bright folder.
You may also need to set the correct path for IrfanView; I think that the location I've specified is the installation default, but you should double-check it.
Do not include the actual program name (or a final backslash) in either path.

Using these batch files is very simple.
First, create a new folder, and copy your texture files into it. They should be saved in Bitmap (.bmp) format using valid Thief dimensions (any combinations of 2, 4, 8, 16, 32, 64, 128, or 256). I would always use copies, and not the texture originals (in most cases your originals will probably be at higher resolution in another format, anway.)
Next, copy one of the batch files into the folder; you can determine which one is appropriate as follows:

Convert everything in this folder to a common palette.bat
This one converts all the bmp files in the current folder to a new common palette, and outputs the new files in .gif format.

Convert everything in this folder to a specific palette.bat
This one converts all the bmp files in the current folder to the palette used by the image Full.??? (where ??? is either .gif, .pcx, .bmp, or .pcx). Outputs the new files in .gif format. Note that the original palette file is converted to .pcx and renamed to Full.pal; the original format file is not kept, so always use a copy of a texture as the palette source. If no new 'full.???' file exists, then the previous one (now 'Full.pal') is used.
You can also use this batch file by dragging-and-dropping any valid image onto it; this image will then be used as the palette source. The dropped file will not be modified or deleted.

Repalettise to Texture Family.bat
This one converts all the bmp files in the current folder to a new common palette, and outputs the new files as a texture family (in .pcx format, with a Full.pcx file to display the newly created palette.)

Once you have chosen the correct batch file, simply run it, and the textures will be repalettised.
If you set an output path in the batch file (using set OutputPath=(path)), the newly created textures will be automatically moved to that location, replacing any existing files.

And that's it. Happy repalettising!

 

The code blocks for the batch files follow. If you have chosen to download them, you can safely ignore this:

 

Convert everything in this folder to a common palette.bat
@echo off
rem Bright conversion script
rem for
rem OBJECT TEXTURES
rem
rem by Nameless Voice
rem
rem Usage: First, save the textures (resized if necessary) in BMP format, and place them in a new folder.
rem Next, copy this batch file into the same folder and run it.
rem
rem The textures will be converted to a common palette and then converted to GIF format and moved to
rem the output path specified below.
rem
rem Note: You need IrfanView installed to use this batch file. (Freeware; get it here: http://www.irfanview.com )
rem Note: You need to specify the path to Bright and IrfanView using 'SET' lines below.

rem Settings:
rem The path to Bright:
set BrightPath=C:\Games\DromEd\Bright183
rem The path to IrfanView:
set IrfanViewPath=%programfiles%\IrfanView
rem The path to output files to:
rem use 'set OutputPath=.' to save files to the current folder.
set OutputPath=.

rem The batch script itself:
if exist *.pcx echo All .pcx files in this folder will be lost.
if exist *.pcx echo Press Ctrl-C to abort or
if exist *.pcx pause
if exist *.pcx del *.pcx
"%BrightPath%\bright.exe" -8 -pinkmask -common -o *.bmp
if not exist "%OutputPath%" md "%OutputPath%"
"%IrfanViewPath%\i_view32.exe" *.pcx /convert="%OutputPath%\*.gif"
del *.pcx
pause

 

Convert everything in this folder to a specific palette.cmd

@echo off
rem Bright conversion script
rem for
rem OBJECT TEXTURES
rem
rem by Nameless Voice
rem
rem Usage: First, save the textures (resized if necessary) in BMP format, and place them in a new folder.
rem Next, *COPY* the file containing the source palette and rename it to 'full.???'
rem (Where ??? is the file extension: supported formats are .pcx, .gif, .bmp, and .png)
rem
rem Finally, copy this batch file into the same folder and run it.
rem
rem WARNING: The palette source file is converted to .pcx format and renamed to Full.pal;
rem THE ORIGINAL FILE IS NOT KEPT. Always use a copy of your palette source file.
rem
rem The textures will be converted to a common palette and then converted to GIF format and moved to
rem the output path specified below.
rem
rem Note: You need IrfanView installed to use this batch file. (Freeware; get it here: http://www.irfanview.com )
rem Note: You need to specify the path to Bright and IrfanView using 'SET' lines below.

rem Settings:
rem The path to Bright:
set BrightPath=C:\Games\DromEd\Bright183
rem The path to IrfanView:
set IrfanViewPath=%programfiles%\IrfanView
rem The path to output files to:
rem use 'set OutputPath=.' to save files to the current folder.
rem OutputPath=.
set OutputPath=.

rem The batch script itself:
if exist *.pcx echo All .pcx files in this folder will be lost.
if exist *.pcx echo Press Ctrl-C to abort or
if exist *.pcx pause
if exist *.pcx del *.pcx

if "%1" == "" goto nodrag
"%IrfanViewPath%\i_view32.exe" %1 /convert="%~dp0Full.pcx"
cd /D "%~dp0"
if exist "Full.pcx" goto namepalette
goto nopal
:nodrag

Rem Check if the palette file is in GIF format.
if exist Full.gif echo Using palette: Full.gif
if exist Full.gif if exist Full.pal del Full.pal
if exist Full.gif "%IrfanViewPath%\i_view32.exe" Full.gif /convert="Full.pcx"
if exist Full.gif del Full.gif
if exist Full.pcx goto namepalette

Rem Check if the palette file is in BMP format.
if exist Full.bmp echo Using palette: Full.bmp
if exist Full.bmp if exist Full.pal del Full.pal
if exist Full.bmp "%IrfanViewPath%\i_view32.exe" Full.bmp /convert="Full.pcx"
if exist Full.bmp del Full.bmp
if exist Full.pcx goto namepalette

Rem Check if the palette file is in PNG format.
if exist Full.png echo Using palette: Full.png
if exist Full.png if exist Full.pal del Full.pal
if exist Full.png "%IrfanViewPath%\i_view32.exe" Full.png /convert="Full.pcx"
if exist Full.png del Full.png
if exist Full.pcx goto namepalette

if exist Full.pcx Echo Using palette: Full.pcx

:namepalette
rem Check if Full.pcx exists and rename it.
if exist Full.pcx if exist Full.pal del Full.pal
if exist Full.pcx ren Full.pcx Full.pal

if not exist Full.pal goto nopal

"%BrightPath%\bright.exe" -8 -palette full.pal -o *.bmp
if not exist "%OutputPath%" md "%OutputPath%"
"%IrfanViewPath%\i_view32.exe" *.pcx /convert="%OutputPath%\*.gif"
del *.pcx
goto endhere

:nopal
echo.
echo No palette file specified.
echo Either drag and drop an image onto this batch file, or
echo the palette must be placed in the same folder as this batch file
echo and named Full.???; valid formats are .pcx, .gif, .bmp, and .png
echo.
echo The file will be converted to .pcx and renamed to Full.pal.
echo The original file is NOT kept.

:endhere
pause

 

Repalettise to Texture Family.bat

@echo off
rem Bright conversion script
rem for
rem BRUSH TEXTURE FAMILIES
rem
rem by Nameless Voice
rem
rem Usage: First, save the textures (resized if necessary) in BMP format, and place them in a new folder.
rem Next, copy this batch file into the same folder and run it.
rem
rem The textures will be converted to a common palette and a Full.pcx will be created automatically.
rem
rem Note: You need to specify the path to Bright using 'SET' lines below.

rem Settings:
rem The path to Bright:
set BrightPath=C:\Games\DromEd\Bright183
rem The path to output files to:
rem use 'set OutputPath=.' to save files to the current folder.
set OutputPath=.\Output

rem The batch script itself:
if exist *.pcx echo All .pcx files in this folder will be lost.
if exist *.pcx echo Press Ctrl-C to abort or
if exist *.pcx pause
if exist *.pcx del *.pcx
echo Conversion process started...
"%BrightPath%\bright.exe" -8 -colmask 0 255 0 -common -o -writepal Full.pcx *.bmp
if not exist "%OutputPath%" md "%OutputPath%"
move *.pcx "%OutputPath%"\ >nul
pause