Making an optimized set of 8-bit textures with PSP 4.1x

Post tutorials for working with image editing in Photoshop and other apps.

Moderators: scallenger, Rebel, Sky, madppiper, TresCom Support Team

User avatar
machf
T-Rex Killer
T-Rex Killer
Posts: 12368
Joined: Thu Apr 24, 2003 11:20 pm
Location: Lima, Peru
Contact:

Making an optimized set of 8-bit textures with PSP 4.1x

Post by machf »

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.
Visit The Carnivores Saga - a forum devoted to modding Action Forms' Carnivores, Carnivores 2 and Carnivores: Ice Age games
Tres WIP: updated T-Script Reference and File Formats documents
Sound name listings for the Demo (build 117), Retail (build 116), Beta 103, Beta 99, Beta 97, Beta 96, Build 55, PC Gamer Alpha (build 32) and E3 1998 Alpha (build 22) TPA files
chronzerg
Albertosaurus
Albertosaurus
Posts: 2087
Joined: Mon Jan 10, 2005 10:13 pm

Post by chronzerg »

Ok, please explain to us humble American's, what the heck you just did and explained there. :?:
User avatar
machf
T-Rex Killer
T-Rex Killer
Posts: 12368
Joined: Thu Apr 24, 2003 11:20 pm
Location: Lima, Peru
Contact:

Post by machf »

Just read the first paragraph and the last two ones...
Visit The Carnivores Saga - a forum devoted to modding Action Forms' Carnivores, Carnivores 2 and Carnivores: Ice Age games
Tres WIP: updated T-Script Reference and File Formats documents
Sound name listings for the Demo (build 117), Retail (build 116), Beta 103, Beta 99, Beta 97, Beta 96, Build 55, PC Gamer Alpha (build 32) and E3 1998 Alpha (build 22) TPA files
chronzerg
Albertosaurus
Albertosaurus
Posts: 2087
Joined: Mon Jan 10, 2005 10:13 pm

Post by chronzerg »

If 24-bit textures are imported correctly, then how did they do it with Tc-Isle.
User avatar
machf
T-Rex Killer
T-Rex Killer
Posts: 12368
Joined: Thu Apr 24, 2003 11:20 pm
Location: Lima, Peru
Contact:

Post by machf »

The TC_Isle 24-bit textures DO have that problem. It's only that in that particular case it doesn't get too noticed.
machf wrote:
**The reason tc_isle's b29 had problems I think was because of
the fact that the model was mixed with std. 8bit and semi-trans-
parents. Separated, a problem doesn't really seem to exist.
I need to check those B-29 textures too. Didn't you people have any problems when importing them?

EDIT: Apparently, the answer is 'yes'. Check this 8x enlargement of the lower-left portion of the colormap and the opacity map:

Image

Apparently, the 'solution' was to similarly displace the opacity map...
I guess it's not critical in this particular mesh, but trust me, on a car, 8 pixels to the right can make a difference...
Also, any muzzle flashes that have been re-imported into 3rd-party levels will show the same problem... but it isn't too critical there, either.
Visit The Carnivores Saga - a forum devoted to modding Action Forms' Carnivores, Carnivores 2 and Carnivores: Ice Age games
Tres WIP: updated T-Script Reference and File Formats documents
Sound name listings for the Demo (build 117), Retail (build 116), Beta 103, Beta 99, Beta 97, Beta 96, Build 55, PC Gamer Alpha (build 32) and E3 1998 Alpha (build 22) TPA files
Slugger
-=TresCom Developer=-
-=TresCom Developer=-
Posts: 4720
Joined: Sat Jun 12, 2004 6:52 pm
Antispam: No
Location: Atlanta

Post by Slugger »

This actually might solve a problem that I have been expierencing with textures, and thus this nifty effect I've been fideling with...when I get back from the beach, I'll have to try that.

Thanks machf.
0066521C: 'Cannot create local swap file - Is Trespasser installed??',0Ah,0
"Cold lino was the driving force behind world power!"
User avatar
Draconisaurus
T-Rex Killer
T-Rex Killer
Posts: 14011
Joined: Mon Dec 06, 2004 5:21 pm
Antispam: No
Location: Isla Sorna
Contact:

Post by Draconisaurus »

There is no problem with 24-bit textures....? You just have to save the
originals and use them the repopulate the swp file when you do
"update SWP". I believe it was Rebel who told me about this, it's
really quite simple... you'll need empty swp/pid files to do it, though.


I'm not really sure what this color indexing thing is.. I've never had
issues with it. Can't you just create new palettes with a spec of that
blue somewhere so it gets included?
User avatar
machf
T-Rex Killer
T-Rex Killer
Posts: 12368
Joined: Thu Apr 24, 2003 11:20 pm
Location: Lima, Peru
Contact:

Post by machf »

Draconisaurus wrote:There is no problem with 24-bit textures....? You just have to save the
originals and use them the repopulate the swp file when you do
"update SWP". I believe it was Rebel who told me about this, it's
really quite simple... you'll need empty swp/pid files to do it, though.
Hmmm... I haven't tried that, but if the problem is in the routine that loads the 24-bit images (I'm assuming that is a common one), the problem will still exist even if you do that. (Did they try solving the B-29 textures' problem with that? Because, if they did, it didn't work...)
I'm not really sure what this color indexing thing is.. I've never had
issues with it. Can't you just create new palettes with a spec of that
blue somewhere so it gets included?
Not really, GeomAdd will automatically make palette index 1 blue, re-assign all pixels that were originally assigned to the first color to some other entry, and leave your 'other' blue (for example, palette entry 192 - I've tested it) untouched. So, the best option is to do what I suggest: force a convesion from 24-bit to a new 256-color palette with the first entry unused in the picture.
Visit The Carnivores Saga - a forum devoted to modding Action Forms' Carnivores, Carnivores 2 and Carnivores: Ice Age games
Tres WIP: updated T-Script Reference and File Formats documents
Sound name listings for the Demo (build 117), Retail (build 116), Beta 103, Beta 99, Beta 97, Beta 96, Build 55, PC Gamer Alpha (build 32) and E3 1998 Alpha (build 22) TPA files
User avatar
Draconisaurus
T-Rex Killer
T-Rex Killer
Posts: 14011
Joined: Mon Dec 06, 2004 5:21 pm
Antispam: No
Location: Isla Sorna
Contact:

Post by Draconisaurus »

machf wrote:Hmmm... I haven't tried that, but if the problem is in the routine that loads the 24-bit images (I'm assuming that is a common one), the problem will still exist even if you do that. (Did they try solving the B-29 textures' problem with that? Because, if they did, it didn't work...)
Why do you say that? If you are sighting the textures looking wrong
after export, that's because TresEd doesn't always export them cor-
rectly I think.. but not sure, I will need to check.
So, the best option is to do what I suggest: force a convesion from 24-bit to a new 256-color palette with the first entry unused in the picture.
Hmmmm what if you imported the texture, without the blue, then ex-
ported it? Would it not then have that blue color as the new first in-
dexed color? (and btw how does that work, adding a color, if the
palette was already 256 colors??)
User avatar
machf
T-Rex Killer
T-Rex Killer
Posts: 12368
Joined: Thu Apr 24, 2003 11:20 pm
Location: Lima, Peru
Contact:

Post by machf »

Draconisaurus wrote:
machf wrote:Hmmm... I haven't tried that, but if the problem is in the routine that loads the 24-bit images (I'm assuming that is a common one), the problem will still exist even if you do that. (Did they try solving the B-29 textures' problem with that? Because, if they did, it didn't work...)
Why do you say that? If you are sighting the textures looking wrong
after export, that's because TresEd doesn't always export them cor-
rectly I think.. but not sure, I will need to check.
I think the export function works fine. At least, original muzzle flash textures exported with TresEd look fine, it's only after re-importing and re-exporting them that they get corrupted. Check this:
machf wrote:
Rebel wrote:
What 'original' levels have 16-bit textures? I'd like to take a look at them to see why thy don't cause problems with software mode while user-made ones do...
Check the muzzleflashes --
Hmmm... it seems they have the same problems (after I've exported and re-imported them). A 'freshly exported' (from an original level) colormap doesn't have those problems.

Image
So, the best option is to do what I suggest: force a convesion from 24-bit to a new 256-color palette with the first entry unused in the picture.
Hmmmm what if you imported the texture, without the blue, then ex-
ported it? Would it not then have that blue color as the new first in-
dexed color? (and btw how does that work, adding a color, if the
palette was already 256 colors??)
Upon importing it, GeomAdd will reassign any pixels that used palette index 1 to some other index (merging them), and re-assign any pixels matching the opacity map's transparent areas to index 1, and change palette entry 1 into blue. So, your original 256-color palette is converted into a 255-color palette + blue for transparency as entry 1. But if your original palette didn't use entry 1 for anything, it won't be affected by this process.
Visit The Carnivores Saga - a forum devoted to modding Action Forms' Carnivores, Carnivores 2 and Carnivores: Ice Age games
Tres WIP: updated T-Script Reference and File Formats documents
Sound name listings for the Demo (build 117), Retail (build 116), Beta 103, Beta 99, Beta 97, Beta 96, Build 55, PC Gamer Alpha (build 32) and E3 1998 Alpha (build 22) TPA files
User avatar
Draconisaurus
T-Rex Killer
T-Rex Killer
Posts: 14011
Joined: Mon Dec 06, 2004 5:21 pm
Antispam: No
Location: Isla Sorna
Contact:

Post by Draconisaurus »

So my last idea should work? Cool I'll just use that instead.

BTW the transparent oceans in BE and JR are also 24-bit bitmaps,
could check them out as well if you wanted. And, that image above is
nothing, lol tomorrow maybe I will post some of the more amusing
overlaps I have encountered..
User avatar
machf
T-Rex Killer
T-Rex Killer
Posts: 12368
Joined: Thu Apr 24, 2003 11:20 pm
Location: Lima, Peru
Contact:

Post by machf »

Draconisaurus wrote:So my last idea should work? Cool I'll just use that instead.
No, it won't work. It will change your palette without asking you. So you better adjust your palette previously making entry 1 an unused color. That way the colors of your image are preserved.
BTW the transparent oceans in BE and JR are also 24-bit bitmaps,
could check them out as well if you wanted.
Since they are original levels, they don't have any probelms. Has anybody imported those textures into some other level, or is intending to do it?
And, that image above is
nothing, lol tomorrow maybe I will post some of the more amusing
overlaps I have encountered..
Waiting to see that...
Visit The Carnivores Saga - a forum devoted to modding Action Forms' Carnivores, Carnivores 2 and Carnivores: Ice Age games
Tres WIP: updated T-Script Reference and File Formats documents
Sound name listings for the Demo (build 117), Retail (build 116), Beta 103, Beta 99, Beta 97, Beta 96, Build 55, PC Gamer Alpha (build 32) and E3 1998 Alpha (build 22) TPA files
User avatar
Draconisaurus
T-Rex Killer
T-Rex Killer
Posts: 14011
Joined: Mon Dec 06, 2004 5:21 pm
Antispam: No
Location: Isla Sorna
Contact:

Post by Draconisaurus »

machf wrote:
Draconisaurus wrote:So my last idea should work? Cool I'll just use that instead.
No, it won't work. It will change your palette without asking you. So you better adjust your palette previously making entry 1 an unused color. That way the colors of your image are preserved.
Well my idea was to use the CHANGED palette that TresEd/GeomAdd
made for all textures originally of that palette.. I would simply have to
paste all textures using the original palette into the texture exported
by TresEd. :)
BTW the transparent oceans in BE and JR are also 24-bit bitmaps,
could check them out as well if you wanted.
Since they are original levels, they don't have any probelms. Has anybody imported those textures into some other level, or is intending to do it?
Well not me but I am going to be making a few new ones like that,
for a flowing river.... (rather than mangling with an animated series of
textures). I checked out the texture and it's interesting to note that
the resulting image has fewer colors than the 8-bit bmp version of it,
something I also noticed with my Zapper muzzel flash texture.
And, that image above is
nothing, lol tomorrow maybe I will post some of the more amusing
overlaps I have encountered..
Waiting to see that...
Be patient I'll find um soon ;)
User avatar
machf
T-Rex Killer
T-Rex Killer
Posts: 12368
Joined: Thu Apr 24, 2003 11:20 pm
Location: Lima, Peru
Contact:

Post by machf »

Draconisaurus wrote:
machf wrote:
Draconisaurus wrote:So my last idea should work? Cool I'll just use that instead.
No, it won't work. It will change your palette without asking you. So you better adjust your palette previously making entry 1 an unused color. That way the colors of your image are preserved.
Well my idea was to use the CHANGED palette that TresEd/GeomAdd
made for all textures originally of that palette.. I would simply have to
paste all textures using the original palette into the texture exported
by TresEd. :)
Oh, I see. That would work. Anyway, if originally, you had for example, RGB 0,0,0 as entry 1, any pixels that were originally that color would have been remapped to either entry 2 or the entry with the closest color (for example, RGB 1,1,1), I'm not sure which of the two options GeomAdd uses. With some palettes, the results may not be too nice (for example, if your entry 1 was black and all the rest were browns, greens, reds and yellows - you'd lose the black altogether).
BTW the transparent oceans in BE and JR are also 24-bit bitmaps,
could check them out as well if you wanted.
Since they are original levels, they don't have any probelms. Has anybody imported those textures into some other level, or is intending to do it?
Well not me but I am going to be making a few new ones like that,
for a flowing river.... (rather than mangling with an animated series of
textures). I checked out the texture and it's interesting to note that
the resulting image has fewer colors than the 8-bit bmp version of it,
something I also noticed with my Zapper muzzel flash texture.
With things like muzzle flashes, water surfaces, or glass windows, the problem isn't too noticeable. But try applying a 24-bit texture to something that uses the same texture map for several surfaces, like a dinosaur, for example, and see what it looks like!
And, that image above is
nothing, lol tomorrow maybe I will post some of the more amusing
overlaps I have encountered..
Waiting to see that...
Be patient I'll find um soon ;)
Visit The Carnivores Saga - a forum devoted to modding Action Forms' Carnivores, Carnivores 2 and Carnivores: Ice Age games
Tres WIP: updated T-Script Reference and File Formats documents
Sound name listings for the Demo (build 117), Retail (build 116), Beta 103, Beta 99, Beta 97, Beta 96, Build 55, PC Gamer Alpha (build 32) and E3 1998 Alpha (build 22) TPA files
User avatar
machf
T-Rex Killer
T-Rex Killer
Posts: 12368
Joined: Thu Apr 24, 2003 11:20 pm
Location: Lima, Peru
Contact:

Re: Making an optimized set of 8-bit textures with PSP 4.1x

Post by machf »

I've been using a slightly different method with a couple of steps less:
machf wrote: 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.
Here it becomes different.

7.- Don't close your textures yet, keep them minimized or something.
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.
And here it becomes different again:


13.- Back on Paint Shop Pro, you can close the "Master canvas" now, it isn't needed anymore. Don't save the changes.
14.- Now, go through each of your textures (I told you not to close thm - if you did, reopen them), and select "Colors->Load Palette". Select the option "Nearest color matching" and open the palette file you just edited. This will convert the texture 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. Repeat it for all the other textures. (Of course, oing so you're overwritingg your old textures, so if you don't want to, make backup copies first, or use a different filename when saving, like "TextureN_8bit.bmp".)
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.
Visit The Carnivores Saga - a forum devoted to modding Action Forms' Carnivores, Carnivores 2 and Carnivores: Ice Age games
Tres WIP: updated T-Script Reference and File Formats documents
Sound name listings for the Demo (build 117), Retail (build 116), Beta 103, Beta 99, Beta 97, Beta 96, Build 55, PC Gamer Alpha (build 32) and E3 1998 Alpha (build 22) TPA files
Post Reply