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.

Great!

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!

9 comments:

Anonymous said...

I know this may be the wrong place for my search, but I'm on a quest for the best homemade beer ever brewed. If you can help me in my quest, email me at ianalbertbutler at yahoo dot com. Then I can tell you the not too long story of why I'm trying to contact you like this.

Anonymous said...

I was trying to get your email. Have something you might be interested in.

Anonymous said...

not in regards to that random beer question...no idea who that is

Hunter K. said...

@Anonymous
I'm not going to post my email address here (spam concerns, you see), but you can use this 'contact me' applet and it will go to my email:
http://aemods.pbworks.com/w/contact-owner

Hụy82 said...

hey pro, can you up load (AOExtractor, AOInject and EMG Swapper, as well as piecemontee's Asset Explorer (aka, SF4Viewer).) again for me ?

Hụy82 said...

Thanks, please check it as soon as possible , my yahoo is quanghuy13582@yahoo.com, i have a problem with it.
Thanks so much.

Hunter K. said...

Hi Huy82,
I updated the post with new links to sloth86's tools. The SF4Viewer link is still good.

Anonymous said...

Hello Hunter

Okay, actually this comes closest to what I am trying to do:
I get what needs to be done to change some of the blackened out areas on the model to make them an even shade. But in the case I toggle the visibility of a bigger clothing item off, like eg the top or sodekubi (to use your above chun li example), the upper torso is invisible from the upper arm and the neck. Is it possible to make these areas visible?

Hunter K. said...

Yeah, that happens a lot when you toggle visibility. To correct it, you'll either have to export the model as obj and adjust the vertices in misfit model 3d (this works for very small holes; you don't want to do it for big ones, though, because it distorts the texture and looks bad) or by using EMGSwap to swap in a piece from another costume that doesn't have the hole(s). For example, Chun's second costume.

Analytics Tracking Footer