Wednesday, October 5, 2011

Using sloth86's Ambient Occlusion Tools in SF4

In the course of making skins for SF4, you might have toggled off an unwanted model, such as Chun Li's spiked bracelets, only to find an unsightly darkening, similar to a shadow, where the object used to be. This darkening is part of what's known as an "ambient occlusion (AO) map," which is used by the game to fake some self-shadowing by the models and thus reduce the amount of shadows your computer needs to draw dynamically to look realistic. However, once the offending model is gone, the AO isn't really appropriate anymore, so we need to do something about it.

For this tutorial, you'll need to download some of sloth86's tools: AOExtractor, AOInject and EMG Swapper, as well as piecemontee's Asset Explorer (aka, SF4Viewer). You'll also need a paint program that can view/edit EPS files, such as Photoshop. UPDATE (6/20/2012): the links for sloth86's tools are dead. You can now get the AO tools here and the EMG Swapper here.

Once you have your tools, open your desired costume file (*.obj.emo) in the Asset Explorer. I'm going to be using Chun Li's default costume (CNL_01.obj.emo):

As you can see in the picture above, I've already toggled off her 'Ring' model, which has left the visible AO darkening on her 'Skin_arm' model, which I intend to fix.

So, next we'll want to select that darkened model, right-click and choose 'raw dump' to get the raw EMG model. Name it something informative with the .emg file extension and click 'save.'

While we're here, take note of which EMG model we're extracting, counting from the top. For me, it's the 10th one. We'll need this information later, so write it down or something.

Next, open the AOExtract tool. You should see a window like this pop up:

In the first field, put in whatever you just saved your dumped model as. In my case, 'skin_arm.emg.' The other options can be left at the default values, unless you just feel like changing them. (Subdividing triangles will make your EPS file look a little nicer, but it takes longer and is unnecessary)

Click 'Extract' and you should end up with a new file, in my case 'new.eps.'

Open your new EPS file in Photoshop and you should see something like this:

Those triangles you see correspond to the triangles used to make the model (just like the UV map, if you're familiar with those). As you can see, some of them are particularly dark, while others are lighter, just like we saw in the Asset Explorer window.

So, using the dropper tool, pick a medium color (we don't want a dark shadow, but we don't want it all bright like a highlight, either). If you're familiar with using hex color values, EFEFEF is a pretty good, generic match.

Once you have your color, you can either use the paint bucket tool to change each triangle by hand, or you can just paint over the whole thing, like I did.

Once you're all finished, we need to 'Save As...' and choose the bitmap (BMP) format, with OS/2 compatibility, 24-bit and no compression.

Next, open the AOInject tool. You should see a window like this:

In the first field, enter the name of your dumped EMG model, in my case, skin_arm.emg. In the second field  enter the name of our modified, blank AO map, in .bmp format. The third field can keep its default value.

Click 'Go' and you should be left with a new EMG model that we can view in the Asset Explorer:

As the pic shows, it's all one uniform gray color, instead of having light and dark areas.


However, now we need to actually get this unshadowed model back into our character model. For this, we turn to the EMG Swapper tool.

Open it up and you should see a window like this:

In the first field, enter the name of the character model you're working with, in my case, CNL_01.obj.emo. In the second field, enter the number of the model we're replacing (remember the thing we wrote down earlier??), in my case it's number 10. In the third field, enter the name of your modified model (the one we injected the new AO map into), in my case 'blank.emg.' The last field can be left with the default value, unless you want to name it something else.

Click 'Go' and you should be left with a new EMO file, which we can view in the Asset Explorer:

Our model fits right in and doesn't have any messy shadows for nonexistent objects anymore. Mission accomplished!

Unfortunately, you can see that her hands still have darkening, which creates a seam next to our modified object, but using your newly found AO mapping expertise, I'm sure you can fix it on your own. ;-)

That's it. Good luck, share your work and ALWAYS MAKE BACKUPS!

Analytics Tracking Footer