Creating UV maps with gsmhacking

Reskinning a model is made harder when you don't know which parts of the image you should modify. Take this officer's vest for example:

Standard officer vest

Where do you draw on the image if you want to place a logo on the chest, as was done in the [furryclan] uniform?

[furryclan] vest with flag

UV maps

The gsmhacking tool can superimpose triangles on a texture file to help you visualise how the texture is wrapped around the mesh.

The vest with UV maps

It can also write these maps to a new file suitable for loading into Photoshop and using as a guide.

The procedure

You need version 3.1.41 or later of gsmhacking. Earlier versions cannot generate UV maps. The steps are:

  1. Use gsmhacking to find the triangle group ID you wish to map.

    For example, to locate the vest group for SWT_ELEM_HIGH.GSM, you would run:

    gsmhacking -D -v SWT_ELEM_HIGH.GSM
      Triangle group 0004 at 0x8bc0: triangles: 90 from 142 to 231 with 04 VEST

    This tells you that the vest material is mapped to group 4. Note that materials may be mapped to different groups and that the group and material IDs don't have to match. They are both 4 here but in general they may not be.

  2. Find the first texture mapped to that group's material.

    Continuing the output from above, we see:

      Material 04 at 0xa9f8: VEST
        Maps: 1
          Map 00: diffuse map of SWT_VEST2.bmp

    The texture is SWT_VEST2.bmp. Copy this file into the current working directory so gsmhacking can find it when generating the maps. If the material has no texture or if you don't copy the image, gsmhacking will create a black and white UV map file with dimensions 256x256 pixels.

  3. Tell gsmhacking to generate the UV map.

    gsmhacking -uv 4 ffffff
    wrote UV maps for VEST from SWT_ELEM_HIGH.GSM to SWT_ELEM_HIGH.GSM.4.bmp

    The first parameter to the -uv command is the triangle group ID. The second is the colour you wish to draw the UVs with. Specify it in standard hexadecimal RGB format:

    Whiteffffff
    Redff0000
    Green00ff00
    Blue0000ff
    Black000000

    You can also use the special colour "transparent" to tell gsmhacking to ignore the texture file and create a 256x256 black and white mapping. You can very easily mask this image in Photoshop and paste it on top of the image you wish to modify.

    Of course if the model's texture has different dimensions you will need to transform your selection. That's the whole point about UV maps. They are normalised. The actual image's dimensions don't matter.

The advantage

Now you have an image with triangles drawn all over it you can visualise the texture wrapping around the image and thus plan where (and how) to draw on the texture without unduly deforming or cropping your image.

Feedback

Send any comments to swat3@furrycat.net.