|
PalMod: Importing sprites
This is a quick guide to importing arbitrary images from the internet to be used by PalMod for sprite preview display. PalMod has many previews built in already, but you can extend and improve PalMod's support by importing pretty much anything. Success of that import process will vary depending the image, which we'll discuss below.
Tools You Need For This
- PalMod
- PalMod itself: a tool used to modify palettes in game ROMs or files.
×
Background: Concepts You Need to Kinda Understand
Sprites: Sprite-based video games work through applying the palette - which PalMod hopefully already knows about - to a known paint-by-numbers map called a texture or preview. (If PalMod doesn't know about the palette yet, you can figure it out fairly efficiently - see the other guides on that.) Color tables are limited to 255 color slices, but if you are using 255 colors or less - or can slice your image up to do so - that is remarkably more storage-efficient than using normal colorized images. Plus, and this is very critical, by just swapping out the palette applied to that texture you can support a different color scheme very easily. That's how you can have both Ken P1 and Ken P2 colors, and so forth.
Images: for our purposes, there are two classes of images. There are "indexed color" images and there are "true color" aka "colorized" aka "RGB" images. For our purposes we will call these "indexed color" and "RGB" images.
Indexed color images: An indexed color image contains a header that has a table of colors, called the color table. The image data is then simply references to that color table, and the images are then renedered via paint-by-number. Video games will have the color table in a very specific order and that is important. Note that almost every image editor except for Adobe Photoshop (Elements) fucks up indexed color support.
RGB images: There is no color table: each individual pixel in the image specifies exactly what color to use there. This avoids the 255 color limitation of color tables but makes swapping colors for that "P2" version almost impossible. Video games will almost never use RGB images for anything they plan on swapping colors for. Note that some modern tools introduce lossiness (image degradation/corruption) to their image handling: use Adobe Photoshop (Elements) to avoid that.
Lossy vs Lossless: You don't have to think about this too much. Smart compression is lossless: what you store via that compression is exactly what you get back. This requires more space than lossy methods, but ensures complete data retention. PNG, GIF, and BMP are lossless. You can be remarkably more efficient in compression if you just don't care about data quality: this is called "lossy" because you are throwing away data. Each compression pass with a lossy compression scheme destroys data. So you are never going to fully recover the data you once had. JPEG is lossy. Don't use JPEG, it sucks.
Matching Colors/Color Conversions: This is simple but bears consideration. Older games often use different color formats than modern games do. This web browser is using 32bit color - RGB888. That lets you select up to 16.7 million colors (256 * 256 * 256). But back in ye olden days of old hardware, most games used 16bit color at most, and RGB444 was very common. That only allows for 4096 colors (16 * 16 * 16). In order to convert from RGB444 (game storage) to RGB888 (display) you need to multiple each RGB444 bit set by about 16. So rgb444(1,3,1) is about equivalent to rgb888(16,48,16). When want to convert an rgb888/modern color back to rgb444/old colors, we have to divide by about 16. So rgb888(32,64,32) becomes rgb444(2,4,2). All rgb444 colors can be correctly mapped to rgb888 space. All rgb888 colors can not be mapped back to rgb444 space. If you have an rgb888 screenshot of a game that has color rgb888(32,64,32), that can be used in a rgb444 context safely. If it uses color rgb888(20,70,10) - those colors can not be guaranteed to map correctly back to rgb444 space and thus the screenshot won't work. Happily, PalMod will do all the conversion math for you. If a color does not match, that means that it was either not correct or it got distorted along the way.
Color Distortion: Sometimes programs like to "spice up" their display by sharpening, dithering, brightening, darkening, or other distorting the source pixel color. This is unusable for our logic. If your emulator is trying to do things like that, turn that functionality off. If you cannot turn that functionality off, you may be able to use that image by forcing it to use the actual game's color table in GIMP or Photoshop. It will have made your life a lot lot harder than it needed to be.
With that being said, there are now TWO paths for you to choose from here.
PATH ONE: Indexed images (with a color table inside the file)
Indexed PNG, GIF, BMP
PATH TWO: RGB images (no color table is available)
Other PNGs, JPEG, screenshots, etc
If you don't know which type of file you have, just keep reading and if you hit a roadblock switch to Path Two. Discussions of potential issues and solutions will follow the basics of those two paths.
Importing an Indexed Image
Over time, PalMod has become easier to use. To have PalMod use the sprite from an indexed image, just drag and drop that image onto PalMod's Preview window. PalMod will update use the sprite shown in that indexed image to use the current palette colors, ignoring the colors already in the indexed image. If you also want PalMod to use the palettes from that indexed image, drag and drop that indexed image onto the main PalMod window first.
So you can import this indexed PNG image of Jotaro:
Let's say I start with the Alex palette in SFIII:3rd Strike, which looks like this:
And then I drag and drop the above Jotaro indexed PNG onto PalMod's preview and thus get this:
Yes, it's that simple. Note that on the main PalMod window the status bar at the bottom it says "Loaded ... indexed PNG as a preview." That means that you indeed dropped an Indexed Image onto PalMod and we knew how to handle it correctly. If that status bar says "Loaded ... RGB PNG preview", you're using an RGB PNG and should follow those steps instead.
For all previews that use the palette table "correctly" - as it is shown in PalMod - this will work great and you are done. If the preview does not use the color table layout as shown in PalMod, we may be able to fix that. Follow the "Importing an RGB Image" steps.
Importing an RGB Image
This route may be tricky and have artifacts (errors in the image capture), so this plan can be non-ideal. Capturing a new sprite from the emulator may provide better results in some cases. But! This is possible.
Let's consider this hard-mode image for example, since this process is so delightfully simplified:
This is an RGB PNG with a beautiful but obnoxious backdrop. How will this ever work, we ask rhetorically? Why, just drag and drop that RGB PNG onto PalMod and let us figure it out for you! Here's what it looks like when I drop it onto PalMod when PalMod has the Jojo's "Jotaro" palette up:
PalMod helpfully clips out all the colors that don't match, and only shows the colors that matched. If your image is using the current palette shown in PalMod, you'll see exactly just that sprite! What we do see this in this "challenge mode" image is that there's a lot of artifacting in the image. Because the Jotaro palette uses white, we see a bunch of white dots around the imported preview. This is going to be unavoidable: all pixels that match colors to the palette will be used since we assume they're being used. Thus if you see that type of artifacting you will want to clip the source image down to eliminate that noise. This is an obvious failure but can be pretty easy to solve with some quick image editing.
There is another more subtle issue in the import here. The Jotaro palette uses the same color in multiple places. For example, color table index 31 and 48 are both white rgb555(31,31,31). An RGB image doesn't contain knowledge of which index it wants to use, so we sadly map it back to the first instance of that color in the color table. The text "Use a mapping palette!" in the status bar here is your warning:
This will only show up if the active palette is not mapping safe (does not contain duplicated colors). If you are lucky enough to be working with a mapping-safe palette, you will not get this warning. Thus while this particular new preview is usable, and can be made more usable by clipping out the noise, it can never be a perfect preview due to the unavoidable error in color table mapping.
If key colors in the preview drop out, that means they don't match the current palette. This can happen if the image has been manipulated in some fashion, such as via an emulator brightening or filtering the image or by a dumb image editor dithering the image. A lot of images on the internet aren't great captures so might not work - but a lot of them are great captures. It is very hit and miss.
If you want perfect previews and can't use the above steps to get a great preview, you may need to capture a new preview direct from an emulator: see that guide.
Advanced Imports
Tools You Need For This
- Adobe Photoshop
- Crazy good image editing studio, with a free 7 day trial available. I cannot recommend Adobe Photoshop Elements highly enough. It is a one time fee of $100 (ouch) but does an amazing job. Most other image editors tend to subtly corrupt images: most Microsoft products will dither colors, and most non-Adobe products don't support indexed PNG properly.
- PalMod
- PalMod itself: a tool used to modify palettes in game ROMs or files.
- GIMP
- Optional: Useful for cutting out animation frames from animated GIFs and manually fixing color tables if needed.
Steps:
Task 1: Figure out what character or game element you're interested in. Download a copy of that character sprite.
Task 2: Use PalMod to get the game's color table for that sprite.
- Open the ROM in PalMod.
- Go to the palette that you want to create a preview for.
- Go to the Tools menu and select "Save ACT Palette". We are going to use this to align the sprite colors correctly for PalMod's use.
Task 3: If the sprite you downloaded was an animated GIF, strip out the animation using GIMP. Otherwise move on to Task 4.
- Step 1: Open up that animated GIF in GIMP.
- Step 2: For everything other than the Background frame (Frame 1), right-click on that frame and select "Delete Layer".
- Step 3: Go to File : Export As and export to PNG. Now you have the PNG that we need to work with.
Task 4: Set or validate the color table in Adobe Photoshop.
- Step 1: Open up that PNG in Adobe Photoshop.
- Step 2: Go to Image: "Mode".
- Step 2.1: If the Image Mode is RGB Color, skip to Step 3.
- Step 2.2: If the image is Indexed Color already: go to the Image: Mode : "Color Table..." menu. If that table matches what you see in PalMod for that sprite, skip to Task 5: Exporting.
- Step 2.3: If the Image Mode is Indexed Color and the color orders do not match PalMod's game palette, you need to reorder the palette. This can be a lossy process, so be careful. Go to SubTask 4.1.
- Step 2.4: If everything looks great, change the Image : "Mode" from "Indexed Color" to "RGB Color".
- Step 3: Now that the image is in RGB Color mode, go to Image : "Mode" and change the image to use "Indexed Color...". When the "Indexed Color" dialog pops up, select the "Palette:" listbox and change to "Custom...". On that dialog use "Load..." to load the ACT file you saved out from PalMod previously. Click OK. Click OK.
SubTask 4.1: Reconstructing an incorrect color table.
- Sometimes you have an indexed color PNG that has a mis-sorted color table. You can actually fix this up if you need to. Otherwise skip to the next step.
- Make sure you have the palette of interest open up in PalMod. We're going to be matching that exact palette using GIMP now.
- Step 1: In GIMP, click the "Create Palette" button in the Palettes tab.
- Step 2: Go to the Palette Editor tab.
- Step 3: IGNORE THE FIRST COLOR YOU SEE IN PALMOD. That's the transparency color.
- Step 4: For the second color you see for the palette of interest in PalMod onwards, find that exact color in the PNG. Use the Color Picker Tool to load that color. Then click the "Create a new entry from the foreground color" button in the Palette Editor to add that to the palette.
Once you're done building your own color table, it should look exactly like what you see in PalMod - except missing the first color shown in PalMod.
- Step 5: If the PNG is still using Image : Mode : "Indexed..." color, switch it to Image : Mode : RGB.
- Step 6: Now that we have an RGB PNG, switch it back to Indexed using "Image : Mode : "Indexed...". Click "Use custom palette" and give the name of the palette you created. Make sure you uncheck "Remove unused and duplicate colors from colormap".
- Go to Task 5 now.
Task 5: Export the indexed PNG using Adobe Photoshop
Task 6: You're done! Use that new PNG in PalMod.
- Go to File and choose the option (Load ROM or Load Directory) that lets you load the game you want to edit.
- Use the comboboxes on the right to find the character (or game element) of interest and then the particular palette of interest. For example, the "Kobun" character, the "LP" color, and the "(05) Bull Mover" palette.
- To load the RAW or PNG file we created in Photoshop, just drag and drop it on PalMod's Preview window.
- If this all worked correctly, you should see the current palette used to colorize your sprite. If you are using a RAW and the image shows up screwy, you probably used the wrong W and H values in your RAW file's filename.
Note if you're trying to modify a paired palette (such as Captain America's palette which is displayed in conjunction with his shield palette), you may want to replace both RAWs that PalMod is using. If you just want to replace one of those and not see the other, create an empty/dummy RAW and set that for the sprite that you don't want to see.
If everything checks out here, consider submitting the RAW to the PalMod team for integration so that others can benefit from your work.
×
|