Monday, May 24, 2021

Creating alpha channels for the car textures with GIMP

(download offline version here)


Note: this tutorial has been written for GIMP 2.6 and 2.8; since version, 2.10 GIMP has a different color space for alpha channels, said values for this version are included.

NFSHS (and NFS3) car textures (car00.tga) do have something called "alpha channel", which tells the game what kind of colors are assignated for the car. To edit them, people usually has Photoshop or Paint Shop Pro to do the job, but if you are broke (and want to stay legal), there's a third way: GIMP.

GIMP is basically the free, open-source alternative to Photoshop, with some interesting features. But when it comes to editing alpha channels, it could be a royal PITA to accomplish the task. Luckly, I figured it out and I'm going to tell you how to do it.

Step 1: Meeting GIMP and asking her out

The first time you fire up GIMP, it would look like this:

  1. Toolbox: This is the place where are located the painting and selection tools, mostly. The foreground/background color selection is also in there.
  2. Tool Options: Here you can adjust the selected tool parameters.
  3. Layers/Channels/Paths Undo: Here you will see the images layers for edition. We´re are going to focus only on the Layers and Undo (in case you screw up).
  4. Brushes/Patterns/Gradients: IMO these are redundant, since they can be setted up from their respective tools. In fact, the only use I found for them was adding/editting brushes, but we won't make that kind of stuff in here right now.
The toolbars can be customized to your liking, but we're going to use the default layout for this tutorial.

Step 2: Let's put the channel together

At this point, I will assume you will have your shiny new texture map ready for this. But you don't want to risk your precious job in case you screw up, right? Well, I packed a testing texture map file (test.bmp) attached to this tutorial in here.

The map as you see, is weird (since it's a test map, don't try make sense of it, unless you want to become insane)

Alright, let's put our hands to work.
  • Go to File > Open (or Ctrl+O, if you regonize the keyboard as the supreme speed king) and look for the "test.bmp" file. Open it (duh).
    Your GIMP screen will look like this:


  • Go to the the layers panel and right click the current layer we're working on (Background) and select "Add Layer Mask...". In the following dialog, under the "Initialize Layer Mask to:" section,  select "White (full opacity)"and hit OK. The layer window will change to this:


    The image thumbnail's clone next to the original image thumbnail's, is the mask layer. When you create (or import) one, GIMP will automatically switch to it, so you can start to work on it right away. When you work on the mask layer, the layer's thumbnail corresponding to the mask layer will have a white outline (well, currently we can't tell that at first glance since the mask is currently white, lol), and the same applies if you work on the image itself. Now click the image's thumbnail to work on the image, we need to select the areas for the colors.


  • Use the Fuzzy Select Tool (keyboard: U) and select the gray area with the white stripe (you can use the Free Select Tool -keyboard: F- as well, that's useful if you want to select a part of the image from it´s surroundings), we´ll pretend this is the main body color. Now switch to the mask layer and click the foreground color in the toolbox. This dialog will pop-up:


  • Write 224 on the R, G and B spaces, then hit OK. That shade of gray you will get is the alpha color for the main body color of the car (RGB: 224,224,224 / HSV: 0,0,88 / HTML:  e0e0e0).
    • If you're using GIMP 2.10, use RGB: 240,240,240 / HSV: 0,0,94 / HTML:  f0f0f0 instead
  • Now select the Bucket Fill tool and click in the selected area. Your image will look like this:


  • Now, since I'm too damn lazy, I will let you finish the alpha channel; the parts remaining are:
    • White stripe: secondary body color (RGB: 96,96,96 / HSV: 0,0,38 / HTML: 606060) [RGB: 165,165,165 / HSV: 0,0,64.7 / HTML: a5a5a5) for GIMP 2.10]
    • Gray drops area: interior color (RGB: 160,160,160 / HSV: 0,0,63 / HTML: a0a0a0) [RGB: 207,207,207 / HSV: 0,0,81 / HTML: cfcfcf) for GIMP 2.10]
    • Gray rectangle: driver's hair color (RGB: 32,32,32 / HSV: 0,0,13 / HTML: 202020) [RGB: 100,100,100 / HSV: 0,0,39 / HTML: 646464) for GIMP 2.10]
    • Blue rectangle: anything you want transparent (RGB: 0,0,0 / HSV: 0,0,0 / HTML: 000000)
  • For NFS3 the following colors should be used:
    • Body color: RGB 100,100,100 / HSV 0,0,39 / HTML 646464 [RGB: 168,168,168 / HSV: 0,0,66 / HTML: a8a8a8 for GIMP 2.10]
    • Secondary body color: RGB 200,200,200 / HSV 0,0,78 / HTML c8c8c8 [RGB: 229,229,229 / HSV: 0,0,89.5 / HTML: e5e5e5 for GIMP 2.10]
    • Transparent: RGB 0,0,0 / HSV 0,0,0 / HTML 000000
You should have got something like this:

Now let's proceed to the last step.

Step 3: Saving the alpha (and the file)

Now that we have the alpha ready, it's time to save it, alongside the file. Right-click the "Background" layer and select "Apply Layer Mask". Now the alpha will merge with the image. Then go to File > Save / Save As... (keyboard: Ctrl+S / Ctrl+Shift+S) and save it as car00.tga.

A dialog will appear. Set it this way:


For NFS3 either you should flip the image vertically with Image > Transform > Flip Vertically or in the Save as TGA dialog you should set the origin to Top left.

And you're done. Is not that difficult, isn't?

Additional notes

If you want to edit an existng file's alpha channel, right-click the "Background" layer, select "Add Layer Mask", check the "Transfer Layer's Alpha Channel" option. Edit as you desire and save as described in Step 3.

I hope this tutorial will be useful to you. AJ signing out