Making an optimized set of 8-bit textures with PSP 4.1x
Posted: Thu Aug 03, 2006 4:49 am
OK, this is a method for making a set of 8-bit (256 colors) textures that share the same palette and have a 'dummy' color as the first entry, so that when they're used with opacity maps and GeomAdd assigns the first entry for colorkeying, the overall palette isn't affected. I'm doing this using an old version of Paint Shop Pro, but it may work with newer ones too.
1.- Start Paint Shop Pro. Set the Foreground color to, for example, black, and the background color to some color that isn't likely to be used in the textures' color palette. I like to use bright magenta (RGB 255, 0, 255), so I'm going to use it for this example.
2.- Create a new image that is very large, if possible make it a multiple of a power of 2 (for example, 1280x1280), assign the background color to "background color" and select 16.7 million colors. This will be your "master canvas".
3.- Now, open your existing textures. I'm assuming they're in 16 million colors each, if not, use the "Colors->Increase color depth" option and increase them to 16 million.
4.- Now, if any of your textures exceeds 256x256 pixels, try to see if you can cut it into smaller pieces without actually cutting any shape within the texture. If that's not possible, choose "Image->Resample" and set the size to 256x256 pixels, unchecking the "Keep aspect ratio" box. Of course, if only one dimension exceeds 256 pixels, you only need to resample that one to 256 pixels (for the other one, see the next step).
5.- Similarly, if your texture sizes aren't powers of 2 (1, 2, 4, 8, 16, 32, 64, 128, 256) resample them to the nearest (lower or higher) ones, both horizontally and vertically. Since texture coordinates are relative (from 0 to 1, from one corner to the opposite one), the only thing that will change is the resolution.
6.- Now start copying and pasting each of your textures into the "master canvas". I tend to do that placing them next to each other without any gaps in between, but leaving a portion of the "master canvas" where the "dummy" color (magenta) can still be seen. If you run out of space while still having textures to paste, use "Image->Enlarge Canvas" and set a new width and height (for example, if 1280x1280 wasn't enough, now make it 1536x1536). Leave the "Center image" box unchecked. With 1280x1280 you should be able to place up to 25 256x256-pixels textures on it, with 1535x1536 it would be up to 36.
7.- After you're done pasting your textures into the "master canvas", you can close them, making sure you don't save the changes you made before copying them. Of course, you may prefer to do this whole process (steps 3-6) one texture at a time - I know I do, that way there aren't that many images all open at once.
8.- Now you can save the "master canvas" to keep it safe. Select "BMP - OS/2 or Windows Bitmap" and "Windows RGB Encoded". Use a name like "RGBtextures.bmp".
9.- Now, select "Colors->Decrease Color Depth->256 Colors (8 bit)". Choose "Optimized" and "Nearest Color". Any other options should be unchecked. Click on "OK". DO NOT SAVE THE IMAGE AFTER THIS!
10.- Now, select "Colors->Save Palette". Choose "PAL - Jasc Palette". Enter a name like "8bitPpalette.pal" and click on "Save".
11.- Now, without having saved the "master canvas", select "Edit->Undo" (or press CTRL+Z, or select "File->Revert" and click on "Yes" at the prompt), to keep the "master canvas" with all the textures in 16.7 million colors.
12.- Using your favorite text editor (Notepad, Wordpad, DOS's EDIT, whatever), open the palette file you saved on step 10 (8bitPalette.pal or whatever you called it). Search for the string "255 0 255" (those are the RGB values for magenta, remember?). Cut the whole line that contains that sting, go to the start of the file, and paste the line you cut right below the line that says "256" (in other words, you should be pasting the line with the magenta code as the 4th line in the file). Save the changes and close the file.
13.- Back on Paint Shop Pro, select "Colors->Load Palette". Select the option "Nearest color matching" and open the palette file you just edited. This will convert the whole "master canvas" to an 8-bit image with the first entry of the palette set to the "dummy" color. Select "File->Save as", choose "BMP - OS/2 or Windows Bitmap" and "Windows RGB Encoded", and save it under a different name, for example, "8bitTextures.bmp".
14.- Now you can start cutting each individual texture from the "master canvas" and paste them as new images ("Edit->Paste->As New Image"). Make sure you're selecting them carefully, without omitting any pixels or taking any from the neighboring ones - that's why I like to leave no boundaries between them, that way they're going to go from, for example, (0,0) to (256,256), (256,0) to (512,256), etc. Save each one as an individual .bmp file.
Done! Now you have a set of several textures that share the same palette, and won't change if they're combined with opacity maps. You could also use bright blue (RGB 0, 0, 255) instead of bright magenta for the "dummy" color - that's what GeomAdd (and Trespasser) usually uses when there's an opacity map involved.
Why all this fuss? Well, remember, 24-bit textures aren't handled properly bt GeomAdd at the moment, so until that problem is fixed, you may find it better to stick with 8-bit textures... and while doing so, it's good if several of them share the same palette, as there's a limit for them.
1.- Start Paint Shop Pro. Set the Foreground color to, for example, black, and the background color to some color that isn't likely to be used in the textures' color palette. I like to use bright magenta (RGB 255, 0, 255), so I'm going to use it for this example.
2.- Create a new image that is very large, if possible make it a multiple of a power of 2 (for example, 1280x1280), assign the background color to "background color" and select 16.7 million colors. This will be your "master canvas".
3.- Now, open your existing textures. I'm assuming they're in 16 million colors each, if not, use the "Colors->Increase color depth" option and increase them to 16 million.
4.- Now, if any of your textures exceeds 256x256 pixels, try to see if you can cut it into smaller pieces without actually cutting any shape within the texture. If that's not possible, choose "Image->Resample" and set the size to 256x256 pixels, unchecking the "Keep aspect ratio" box. Of course, if only one dimension exceeds 256 pixels, you only need to resample that one to 256 pixels (for the other one, see the next step).
5.- Similarly, if your texture sizes aren't powers of 2 (1, 2, 4, 8, 16, 32, 64, 128, 256) resample them to the nearest (lower or higher) ones, both horizontally and vertically. Since texture coordinates are relative (from 0 to 1, from one corner to the opposite one), the only thing that will change is the resolution.
6.- Now start copying and pasting each of your textures into the "master canvas". I tend to do that placing them next to each other without any gaps in between, but leaving a portion of the "master canvas" where the "dummy" color (magenta) can still be seen. If you run out of space while still having textures to paste, use "Image->Enlarge Canvas" and set a new width and height (for example, if 1280x1280 wasn't enough, now make it 1536x1536). Leave the "Center image" box unchecked. With 1280x1280 you should be able to place up to 25 256x256-pixels textures on it, with 1535x1536 it would be up to 36.
7.- After you're done pasting your textures into the "master canvas", you can close them, making sure you don't save the changes you made before copying them. Of course, you may prefer to do this whole process (steps 3-6) one texture at a time - I know I do, that way there aren't that many images all open at once.
8.- Now you can save the "master canvas" to keep it safe. Select "BMP - OS/2 or Windows Bitmap" and "Windows RGB Encoded". Use a name like "RGBtextures.bmp".
9.- Now, select "Colors->Decrease Color Depth->256 Colors (8 bit)". Choose "Optimized" and "Nearest Color". Any other options should be unchecked. Click on "OK". DO NOT SAVE THE IMAGE AFTER THIS!
10.- Now, select "Colors->Save Palette". Choose "PAL - Jasc Palette". Enter a name like "8bitPpalette.pal" and click on "Save".
11.- Now, without having saved the "master canvas", select "Edit->Undo" (or press CTRL+Z, or select "File->Revert" and click on "Yes" at the prompt), to keep the "master canvas" with all the textures in 16.7 million colors.
12.- Using your favorite text editor (Notepad, Wordpad, DOS's EDIT, whatever), open the palette file you saved on step 10 (8bitPalette.pal or whatever you called it). Search for the string "255 0 255" (those are the RGB values for magenta, remember?). Cut the whole line that contains that sting, go to the start of the file, and paste the line you cut right below the line that says "256" (in other words, you should be pasting the line with the magenta code as the 4th line in the file). Save the changes and close the file.
13.- Back on Paint Shop Pro, select "Colors->Load Palette". Select the option "Nearest color matching" and open the palette file you just edited. This will convert the whole "master canvas" to an 8-bit image with the first entry of the palette set to the "dummy" color. Select "File->Save as", choose "BMP - OS/2 or Windows Bitmap" and "Windows RGB Encoded", and save it under a different name, for example, "8bitTextures.bmp".
14.- Now you can start cutting each individual texture from the "master canvas" and paste them as new images ("Edit->Paste->As New Image"). Make sure you're selecting them carefully, without omitting any pixels or taking any from the neighboring ones - that's why I like to leave no boundaries between them, that way they're going to go from, for example, (0,0) to (256,256), (256,0) to (512,256), etc. Save each one as an individual .bmp file.
Done! Now you have a set of several textures that share the same palette, and won't change if they're combined with opacity maps. You could also use bright blue (RGB 0, 0, 255) instead of bright magenta for the "dummy" color - that's what GeomAdd (and Trespasser) usually uses when there's an opacity map involved.
Why all this fuss? Well, remember, 24-bit textures aren't handled properly bt GeomAdd at the moment, so until that problem is fixed, you may find it better to stick with 8-bit textures... and while doing so, it's good if several of them share the same palette, as there's a limit for them.