First of all, the tools used:
-PSicture: this process requires some trial and error, so it's good to keep an instance of PSicture ready to check the results as you edit the texture file.
-Hex editor: yes, the entire process of editing palettes and textures described here is done through hex editing. In this tutorial, I'll use XVI32.
-MS Windows' calculator: for value conversions. It must be set to developer mode.
Then, the file structure:
-Palettes: located from
0x20 to
0x439F. Each color option in GT2 is composed of 18 palettes of 16 colors each. Each palette is composed of 32 bytes, with two bytes for each individual color. Which pixels are affected by each color is determined by the bitmap that follows. There is enough room for 30 color options, but the most that GT2 seems to make use of is 16. The colors are in the BGR555 color model, which will be explained later in this tutorial.
Palette set sample. The blue squares marks the start/end of the set. The 5th palette (interpreted by PSicture as 6th) is highlighted.
-Texture bitmap: located from
0x43A0 to
0xB39F. If you're
really interested in editing this by hand (there are 57342 pixels!), the rule is simple - each byte determines the colors of two pixels according to the current palette. Pay attention, however, that the digits are reversed, so the first digit determines the second pixel and vice-versa. The digits go from 0 to F, representing from the 1st to the 16th color in the palette.
For example: a byte that reads 'B4' means that the first pixel will receive the 5th (4) color of the active palette, while the second will receive the 12th (B) color.
PS: if someone knows an easier way of editing these bad boys, please let us know!
Raw bitmap sample. The highlighted bytes represent the first 256 pixels of the texture sheet.
And now, the dirty job of palette editing:
1. Open PSicture and, with the "Open as raw..." option, open your decompressed .cdp (daytime textures) or .cnp (nighttime textures) file. Make sure your settings match the following:
-Width: 256px
-Height: 224px
-Bits per pixel: 4
-Offset: 16800
-Number of palette (height): 16
Once the file is open, you can cycle through the palettes by pressing F7 and F8.
Remember: PSicture displays the first 32 bytes of the file as a palette, even though it's just the number of available colors and each individual color code. Due to this, PSicture won't display the actual 16th palette. It won't display the last two palettes either. It also only displays the first color option available, so it's best to work on a separate file - editing the first color option - and then transfer the new palettes to the original file. You can either replace an existing color option or add it to the file, by placing the palettes right after the last set - in this case you have to update the number of colors in 0x0 and place the color code in the end of the list that follows.
2. Open the same file with the hex editor. Go to the palette you want to edit and try to find the pixels you want to recolor. Since we're working with trial and error, try changing the color codes to something like 'FC FC' (displays as pink) to make it easier to see what changed, and memorize/keep note of what you just changed so you can quickly revert it if it's not what you're looking for. Every time you edit something, save the file and refresh PSicture (just press enter) to see the latest edits.
'FC FC' displays as pink, making it easier to see what you're editing.
3. Once you've found what to recolor, it's time to get the correct BGR555 color code. Naturally we work with RGB888, so a bit of math is required here.
-First: choose your color and get its R (red), G (green) and B (blue) values. Pick each of these values and apply the following formula: "
('value' * 31) / 255". Windows' calculator will keep the resulting values rounded for you, given you've enabled developer mode.
-Second: convert these values to binary - Windows' calculator in developer mode is VERY handy here.
-Third: enter the binary values in the calculator in
blue-green-red order - paying attention to zeros at the left ('101' becomes '00101' and so on) - and convert them to hexadecimal. The result is the color code you'll use.
Master example:
RGB888 (original, dec) = 150, 200, 250
RGB555 (1st step, dec) = 18, 24, 30
RGB555 (2nd step, bin) = 10010, 11000, 11110
BGR555 (3rd step, bin) = 111101100010010
BGR555 (3rd step, hex) = 7B12
4. Now that you've found the correct code, replace the relevant bytes in the palette with those from your code - in reverse order. For example, '
7B12' should be inserted as '
12 7B'. Repeat the process with all colors you want to change and have fun!
Ever wanted a Viper GTS-R with RED stripes? Now you can!
Note: once you've recolored the daytime textures, you can just copy most of the custom palettes to the .cnp file. The only noticeable difference between the files is the headlight palettes that might be recolored individually.